root@DD-WRT:~# route | tail -n 10
117.128.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 59.192.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 183.192.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 183.0.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 113.64.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 116.128.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 120.192.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 112.0.0.0 192.168.172.254 255.192.0.0 UG 0 0 0 vlan1 127.0.0.0 * 255.0.0.0 U 0 0 0 lo default 172.28.1.1 0.0.0.0 UG 0 0 0 ppp0
注意最后default gateway就是VPN gateway
cd /tmp mkdir /tmp/myvpn ln -s /usr/sbin/openvpn /tmp/myvpn/myvpn /tmp/myvpn/myvpn --mktun --dev tap0 # initialize tunnel brctl addif br0 tap0 # create a new network-adapter ifconfig tap0 0.0.0.0 promisc up sleep 5 echo \client daemon dev tap0 proto udp # TUN/TAP virtual network device # Set the protocol (udp/tcp) # Set OpenVPN mode to client remote xxx.xxx.xxx 1194 # Set the IP-adress/DNS-entry of the server resolv-retry infinite nobind persist-key persist-tun ca /tmp/myvpn/ca.crt cert /tmp/myvpn/client1.crt key /tmp/myvpn/client1.key ns-cert-type server comp-lzo verb 3 \ipsec.config echo \-----BEGIN CERTIFICATE----- Insert the content of your ca.crt -----END CERTIFICATE----- \ca.crt echo \-----BEGIN RSA PRIVATE KEY----- Insert the content of your client1.key -----END RSA PRIVATE KEY----- \client1.key chmod 600 /tmp/myvpn/client1.key echo \-----BEGIN CERTIFICATE----- Insert the content of your client1.crt -----END CERTIFICATE----- \client1.crt route add -net 192.168.0.0/24 dev br0 sleep 5 /tmp/myvpn/myvpn --config /tmp/myvpn/ipsec.config