Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my Linux server (Ubuntu), how can I configure traffic originating from one of my network interfaces (my VPN device - ppp0) to route through its own gateway address?

Caveats:

  • I can't set it up as a default route on the server because it is expensive to route all traffic through it
  • There isn't a specific subnet linked to the VPN - it could be traffic to any public IP or port (the VPN behaves as a proxy)

The end goal is to be able to configure a single local application to bind to the VPN IP and communicate only over the VPN, but no other server traffic should be routed through it. I've set it up like this, but I seem to need some sort of additional routing rules to get it working.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If the VPN is actually acting as a proxy, then the source addresses should be re-written to the far end of the ppp session (unless it's an unnumbered interface, but I haven't seen that on a vpn). If it's actually routing normally, and the destination could be anywhere, then it becomes a more interesting problem.

The base solution is outlined in the LARTC-- you'd want to create a second routing table specifying the VPN tunnel as the default route, and then add filters to direct some traffic to look at the secondary routing table instead of the default one. If you only need one app to take the tunnel, and the app can bind to the tunnel interface's IP, then policy-based routing from the source IP should do the trick -- see the example here: http://lartc.org/howto/lartc.rpdb.html

share|improve this answer
    
Exactly what I was looking to do - thanks. Also found this useful example once I knew what to look for: kindlund.wordpress.com/2007/11/19/… –  Jer Nov 7 '10 at 16:38
add comment

you can use the dev parameter to bin a route to a specified device.

route add -net 0.0.0.0 gw ENTER-GATEWAY-HERE dev ppp0

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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