Setup OpenVPN on OpenWrt

通过下面的操作, 可以让OpenVPN工作, 实现全局科学上网.

$ opkg update
$ opkg install openvpn-openssl
$ echo '/etc/openvpn/' >> /etc/sysupgrade.conf

$ vi /etc/openvpn/openwrt.ovpn

$ uci set openvpn.client=openvpn
$ uci set openvpn.client.config=/etc/openvpn/openwrt.ovpn
$ uci set openvpn.client.enabled=1
$ uci commit

$ /etc/init.d/openvpn start
$ /etc/init.d/openvpn enable

/etc/openvpn/openwrt.ovpn

client  
nobind  
dev tun  
remote-cert-tls server  
remote 1.2.3.4 1194 tcp  
route 192.168.0.0 255.255.0.0 net_gateway

<key>  
-----PRIVATE KEY-----
</key>

<cert>  
-----CERTIFICATE-----
</cert>

<ca>  
-----CERTIFICATE-----
</ca>

<tls-auth>  
-----OpenVPN Static key V1-----
</tls-auth>

key-direction 1  
redirect-gateway def1  

Create Interface

Create Interface:  
  Name of the new interface: vpn
  Protocol of the new interface: Unmanaged
  Cover the following interface: tun0
  Create / Assign firewall-zone: vpn

Firewall - Zone Settings

Firewall - Zone Settings:  
  lan => vpn, wan
  wan => REJECT
  vpn => ACCEPT

Read More