0

I have an Ubuntu Virtualbox guest with two network interface, eth0 (NAT) and eth1 (bridged).

I want to connect to a PPTP VPN using eth1, but I don't know how to specify which interface to use. If i just try:

sudo pon myvpn nodetach

It fails with:

Using interface ppp0
Connect: ppp0 <--> /dev/pts/1
Modem hangup
Connection terminated.

Looking at routes with route seems to indicate that eth0 is being used:

x.x.x.x.no 10.0.2.2        255.255.255.255 UGH   0      0        0 eth0

2 Answers 2

1

The PPTP client will use the Linux kernel's routing to select which interface is used to source traffic from. If you want to make sure a specific interface is used, the best route towards the VPN endpoint needs to be via that interface.

1

Teun Vink's answer is correct, but it is also very restrictive: in order to convey the VPN traffic through eth1, his solution directs all traffic through eth1.

It is instead possible to leave one's options open, by adding to the routing table specific options which allow only some kind of traffic to be routed through eth1.

First of all, you may use the --localbind option for pptp to specify which interface to use. For instance, if your eth1 card has the IP 192.168.1.15, by calling pptp as follows:

 pptp --localbind 192.168.1.15 ...

(or modifying your myvpn file), you will have connected through to the VPN by using the interface eth1.

Now you specify that you only want traffic to the remote LAN to pass through the VPN, nothing else. You achieve this by saying:

sudo route add -net 192.168.50.0/24 dev ppp0

where I assumed the LAN behind the VPN server is 192.168.50.0/24

If you want traffic to a specific site with IP address xx.yy.ww.zz to go through the VPN, you may say:

sudo route add -host xx.yy.ww.zz dev ppp0

With these commands, the traffic you have explicitly selected for routing through the VPN will use it, all of the remaining traffic will be routed outside the VPN. And you can use both eth0 and eth1 to route other traffic, outside the VPN.

2
  • I don't think you're answering what he's asking. The way I read the question he's asking how to route traffic to the VPN server via a specific interface on his machine, not how to route specific traffic via the VPN interface.
    – Teun Vink
    Nov 10, 2013 at 16:18
  • I disagree. He is asking "how to specify which interface to use". That's what the first part of my answer does, the --localbind thing. The rest of the answer shows there are alternatives to routing everything through the VPN. Nov 10, 2013 at 16:25

You must log in to answer this question.

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