I want to be able to make request through a specific network interface, like this:

ping -I eth0.1 google.be
ping -I eth0.2 google.be

This example works on my multihomed OpenWRT router.
I now want to do something similar on my computer.

The catch is: it's not a real interface, but a VPN interface.

Right now I have set up OpenVPN, which has created a TUN device. I currently chose that because it's the default. I don't mind switching to TAP or PPTP if that makes this easier.

So what I want to do is do something similar as the first command, but then:

ping -I tun0 google.be

Right now, this just does not work and times out. I've also tried it with a TAP interface, and that gives me network unreachable errors.

I guess I need to add some iproute entries, or something alike.

Important: I do not know which servers/IPs I need to contact through the vpn device, that's a variable, so I can't just set a route for that.

  • Additionally to your missing local route, a problem is that you need to route it on the other side of the VPN, even if you have a route for it on your local site. Is the other site of the VPN configured as router? – Martin C. Dec 18 '14 at 20:16
  • You'd need to use tcpdump or similar tool to see whether the packet is actually sent through that device. Please note that the returned packets are typically not bound by the path of the original packets, so you should also use tcpdump to see which way you're getting the answer. If you're lucky, you can run it also on the other end and/or on some intermediate host. That should give you enough information for amending the question accordingly. – Pavel Šimerda Dec 18 '14 at 21:45

Several conditions have to be met in order for that to work:

  1. Your system must route packets to the target through the VPN.
  2. The VPN end point must forward the packets to the target.
  3. The target's routing must return the packets to the VPN endpoint. This is very improbable. The only real option to reach this is to use SNAT. The target has to believe the packet was sent from the WAN interface of the VPN endpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.