通过PPTP将linux服务器连接到VPN服务器

我试图通过PPTP客户端将VPN(Ubuntu 10.04 LST)服务器连接到VPN服务器到VPN服务器。 我在文档中configuration了PPTP客户端。 连接被正确添加为一个接口,但不知何故连接不起作用。 ping -I ppp0 google.com不会返回任何东西, traceroute -i ppp0只显示第一跳,然后什么也不显示。 有什么错误的想法? 路由configuration不正确?

configuration接口的ifconfig输出:

 ppp0 Link encap:Point-to-Point Protocol inet addr:xx.x.xxx.xxx PtP:10.0.0.1 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1 RX packets:415 errors:0 dropped:0 overruns:0 frame:0 TX packets:468 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:31428 (31.4 KB) TX bytes:32394 (32.3 KB) 

route输出

 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface xx.xx1 * 255.255.255.255 UH 0 0 0 ppp0 xx.xxx.xxx.xx sp.ip 255.255.255.255 UGH 0 0 0 eth1 192.168.3.0 * 255.255.255.0 U 0 0 0 eth2 192.168.2.0 * 255.255.255.0 U 0 0 0 eth1 default sp.ip 0.0.0.0 UG 100 0 0 eth1 

您需要在远程服务器上使用iptablesconfigurationNAT IP伪装。 否则,您的客户端服务器无法通过vpn使用远程服务器的单个IP地址访问Internet。

简而言之:

 echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE 

这两行显示了如何设置IP伪装。

如果你不熟悉iptables ,那么在互联网上有很多教程。

仅供参考,tldp提供了一个相当详细的设置ip-masquerading的指令。 http://tldp.org/HOWTO/html_single/Masquerading-Simple-HOWTO/

你怎么能通过ppp0 ping什么,如果你没有这个路线。

首先:将路由添加到VPN服务器

route add $VPN_SERVER_IP gw $GATEWAY_TO_VPN_SERVER

(因为我看到$ GATEWAY_TO_VPN_SERVER = sp.ip)

第二:删除eth1的默认路由

route del default dev eth1

第三:为ppp0添加默认路由

route add default dev ppp0

而从现在开始,所有的软件包将通过dev ppp0进行路由。