Skip to content

Instantly share code, notes, and snippets.

@taylorwin
Forked from mondalaci/openvpn-on-openwrt.sh
Created October 15, 2016 05:08
Show Gist options
  • Save taylorwin/23f6ce50afca5eae5ca3748001f9d017 to your computer and use it in GitHub Desktop.
Save taylorwin/23f6ce50afca5eae5ca3748001f9d017 to your computer and use it in GitHub Desktop.
OpenVPN configuration on OpenWrt
cat >> /etc/firewall << END
iptables -t filter -A input_wan -p udp --dport 1194 -j ACCEPT
iptables -I INPUT 1 -i tun+ -j ACCEPT
iptables -I FORWARD 1 -i tun+ -j ACCEPT
iptables -I OUTPUT 1 -o tun+ -j ACCEPT
iptables -I FORWARD 1 -o tun+ -j ACCEPT
END
/etc/init.d/firewall restart
opkg install openvpn
# I don't wanna convert my OpenVPN config to UCI-like format so I just replace the default init script.
mv /etc/init.d/openvpn /etc/init.d/openvpn.orig
cat >/etc/init.d/openvpn < <END
#!/bin/sh /etc/rc.common
START=99
start() {
openvpn --daemon --config /etc/openvpn/server.conf
}
restart() {
stop
sleep 3
start
}
reload() {
killall -SIGHUP openvpn
}
stop() {
killall openvpn
}
END
chmod 755 /etc/init.d/openvpn
/etc/init.d/openvpn start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment