Linux – Connect linux server to VPN server via PPTP

linuxpptproutingvpn

I'm trying to connect a Linux (Ubuntu 10.04 LST) server to a VPN server via the PPTP client to an VPN server. I configured the PPTP client as said in the documentation. The connection is correctly added as an interface, but somehow the connection dose not work. ping -I ppp0 google.com dose not return anything and traceroute -i ppp0 only shows the first hop, and then displays nothing. Any ideas of what is going wrong? Incorrect routing configuration?

ifconfig output for the configured interface:

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:xx.x.xxx.xxx  P-t-P: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 output

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xx.x.x.1        *               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

Best Answer

You need to configure NAT IP-Masquerading with iptables on the remote server. Otherwise your client server can't access the internet via the vpn with a single IP address of the remote server.

in a nut shell:

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

these two lines show how IP-Masquerading could be setup.

if you are not familiar with iptables, there are plenty tutorials for it on the internet.

FYI, tldp hosts a rather detailed instruction on setting up ip-masquerading. http://tldp.org/HOWTO/html_single/Masquerading-Simple-HOWTO/