0

I have a PC running Xubuntu. I purchased a VPS server and setup PPTP VPN with it. I'd like to achieve the following: for services like google, twitter, etc, I'd like to use the VPN connection. Otherwise, I'd like the traffic to go through eth0. If this achievable? If so, any tip to get it working?

eth0      Link encap:Ethernet  HWaddr ac:22:0b:7f:fa:cf  
          inet addr:192.168.1.7  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ae22:bff:fe7f:facf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:112440 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93253 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:108874194 (108.8 MB)  TX bytes:18286239 (18.2 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:21017 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21017 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2727229 (2.7 MB)  TX bytes:2727229 (2.7 MB)

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:10.0.0.100  P-t-P:10.0.0.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1400  Metric:1
          RX packets:2707 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2589 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:2097695 (2.0 MB)  TX bytes:716566 (716.5 KB)

1 Answer 1

1

You need to set up static routes for the services you want to go through the VPN (assuming you have IP forwarding enabled on the VPN server and have NAT configured).

To add routes on Linux, use the following syntax:

route add -net 192.168.1.0/24 gw 10.0.0.1

Where 192.168.1.0 is the network number you want to route, the /24 is the netmask. So for example for Facebook you would have to add:

route add -net 31.13.64.0/19 gw 10.0.0.1
route add -net 31.13.64.0/24 gw 10.0.0.1
route add -net 31.13.65.0/24 gw 10.0.0.1
route add -net 31.13.66.0/24 gw 10.0.0.1
route add -net 31.13.69.0/24 gw 10.0.0.1
route add -net 31.13.70.0/24 gw 10.0.0.1
route add -net 31.13.71.0/24 gw 10.0.0.1
route add -net 31.13.73.0/24 gw 10.0.0.1
route add -net 31.13.74.0/24 gw 10.0.0.1
route add -net 31.13.75.0/24 gw 10.0.0.1
route add -net 31.13.76.0/24 gw 10.0.0.1
route add -net 31.13.77.0/24 gw 10.0.0.1
route add -net 31.13.78.0/24 gw 10.0.0.1
route add -net 31.13.82.0/24 gw 10.0.0.1
route add -net 31.13.83.0/24 gw 10.0.0.1
route add -net 31.13.84.0/24 gw 10.0.0.1
route add -net 31.13.86.0/24 gw 10.0.0.1
route add -net 31.13.90.0/24 gw 10.0.0.1
route add -net 31.13.91.0/24 gw 10.0.0.1
route add -net 31.13.93.0/24 gw 10.0.0.1
route add -net 31.13.96.0/19 gw 10.0.0.1
route add -net 66.220.144.0/21 gw 10.0.0.1
route add -net 66.220.152.0/21 gw 10.0.0.1
route add -net 69.63.176.0/21 gw 10.0.0.1
route add -net 69.63.184.0/21 gw 10.0.0.1
route add -net 69.171.224.0/20 gw 10.0.0.1
route add -net 69.171.239.0/24 gw 10.0.0.1
route add -net 69.171.240.0/20 gw 10.0.0.1
route add -net 69.171.255.0/24 gw 10.0.0.1
route add -net 173.252.64.0/19 gw 10.0.0.1
route add -net 173.252.96.0/19 gw 10.0.0.1
route add -net 179.60.192.0/24 gw 10.0.0.1

For all the services you want to route through your tunnel you would have to add these static routes. To find all the networks for a specific service it's easiest to find the AS number and look up the related networks on http://www.cidr-report.org/cgi-bin/as-report/as-report?as=AS32934&view=2.0&v=4&filter=drop, replacing AS32934 with the AS number.

As this is a lot of work, you might want to think about using your VPN server as default gateway (thus routing all traffic through the tunnel), and making static routes for traffic you don't want to tunnel through the VPN.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .