请问 centos 下如何设置路由,将所有流量转到 V=P=N?

2018-06-25 20:45:31 +08:00
 zhaoyc2018
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
2122 次点击
所在节点    互联网
3 条回复
billlee
2018-06-25 23:11:17 +08:00
1. 加一条 destination 为 vpn 服务器地址 /32 的路由,通过本地的网关
2. 把默认路由改到 vpn 上
zhaoyc2018
2018-06-25 23:33:14 +08:00
@billlee #vpn 连上的时候好像已经自动添加路由。
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
43.249.37.11 172.31.255.253 255.255.255.255 UGH 0 0 0 eth0
43.249.37.11 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
61.157.50.103 172.31.255.253 255.255.255.255 UGH 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

修改默认路由命令是“ ip route replace default dev ppp0 ”这样吧?但是执行后就是网络不正常
# ping www.qq.com
ping: www.qq.com: Name or service not known
zhaoyc2018
2018-06-26 01:24:28 +08:00
搞定,DNS 设置问题,导致的。。。折腾一晚上。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/465781

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX