I'm using OpenVPN on Ubuntu Server to connect to my VPN. That network interface is tun0. All traffic currently goes through the VPN. I'd like to exclude traffic that goes over a specific port, and have that traffic go through eth0, and not through the VPN. I know it's possible, but I don't have much networking experience, so I'm at a loss here. Any help is much appreciated.

  • Do you want general tips or specific steps? I can do the former. – Otheus May 12 '15 at 22:27
  • Thanks Otheus, I'm mostly looking for specific tips, but general tips might point me in the right direction in where to search. Thanks! – Randy May 12 '15 at 22:34

You can use iptables + ip-route together to achieve this. The idea is, iptables "mangles" a specified packet by "marking it", and then later, the ip route rules can direct such marked packets to a different gateway, ie, interface. I found a concise and simple example for you: http://lartc.org/howto/lartc.netfilter.html The example is that you have two connections to the internet -- one fast, one slow, and they route mail (port 25) to the slow one.

  • Interesting. I found a very similar guide here, and I set it up, but traffic for that port is still going over the VPN. I wonder if something else is taking precedence? I'm not sure how to troubleshoot. – Randy May 12 '15 at 23:59
  • Honestly, me neither. You could check to see if iptables rules are getting hit with iptables -n -v -x -c -- shows you packet counts on each rule. As far as iptables rules, not really sure. – Otheus May 13 '15 at 0:04

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.