VPN 已正常连接,但不知道怎么设置路由,将所有流量转到 vpn。
ip route add 108.61.126.150 dev ppp0
curl http://y1.511401.com/IP.php
这样设置后,访问 y1.511401.com 是通过 vpn。
# route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.31.255.253 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.31.240.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.31.255.162 netmask 255.255.240.0 broadcast 172.31.255.255
ether 00:16:3e:02:e4:a4 txqueuelen 1000 (Ethernet)
RX packets 209209 bytes 310576203 (296.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 33972 bytes 3240741 (3.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 107 bytes 23412 (22.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 107 bytes 23412 (22.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1496
inet 10.253.217.1 netmask 255.255.255.255 destination 43.249.37.11
ppp txqueuelen 3 (Point-to-Point Protocol)
RX packets 10 bytes 550 (550.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 235 bytes 44644 (43.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ip route add 108.61.126.150 dev ppp0
curl http://y1.511401.com/IP.php
这样设置后,访问 y1.511401.com 是通过 vpn。
# route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.31.255.253 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.31.240.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.31.255.162 netmask 255.255.240.0 broadcast 172.31.255.255
ether 00:16:3e:02:e4:a4 txqueuelen 1000 (Ethernet)
RX packets 209209 bytes 310576203 (296.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 33972 bytes 3240741 (3.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 107 bytes 23412 (22.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 107 bytes 23412 (22.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1496
inet 10.253.217.1 netmask 255.255.255.255 destination 43.249.37.11
ppp txqueuelen 3 (Point-to-Point Protocol)
RX packets 10 bytes 550 (550.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 235 bytes 44644 (43.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0