我试图创build一个VPN隧道,将本地机器的所有数据转发到VPN服务器。 我使用ppp-2.4.5进行以下configuration:
pty "pptp <VPNServer> --nolaunchpppd" name <my login name> remotename PPTP usepeerdns require-mppe-128 file /etc/ppp/options.pptp persist maxfail 0 holdoff 5
我有一个脚本在if-up.d与以下内容:
route del default eth0 route add default dev ppp0
在启动VPN隧道之前,我的路由如下所示:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.1 0.0.0.0 UG 2 0 0 eth0 127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo 192.168.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
启动隧道(通过pon)后,它看起来像:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0 12.34.56.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0 127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo 192.168.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
现在的问题是,VPN隧道似乎被圈入本身。 如果我几秒钟后运行ifconfig没有任何stream量:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.10 netmask 255.255.0.0 broadcast 192.168.255.255 ether 00:01:2e:2f:ff:35 txqueuelen 1000 (Ethernet) RX packets 39931 bytes 6784614 (6.4 MiB) RX errors 0 dropped 90 overruns 0 frame 0 TX packets 34980 bytes 7633181 (7.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xfbdc0000-fbde0000 ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1496 inet 12.34.56.78 netmask 255.255.255.255 destination 12.34.56.1 ppp txqueuelen 3 (Point-to-Point Protocol) RX packets 7 bytes 94 (94.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 782863 bytes 349257986 (333.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
它表示已经发送了超过300个MiB,ppp0仅在几秒钟内才在线并且连接无法正常工作。
有人可以帮助我修复路由表,这样来自ppp0的stream量不会再通过ppp0发送,而是转到远程服务器?
我终于通过创build以下路线来解决它:
route add -host <VPNServer> gw 192.168.0.1 route add -net default gw 12.34.56.1
所以唯一的错误是我把VPN连接的终点和VPN服务器本身的IP地址混在一起。
仅仅从networking的angular度来看,你仍然需要一条路由走出eth0来获得VPN服务器(它的外部IP)的特定IP地址。
您可以在启动脚本或if-up脚本中为此添加路由。 如果默认路由已经存在,eth0就不存在。
所有其他的数据,然后应该出去ppp0(然后出eth0 ..)