Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


  • 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
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:

share|improve this answer
Exactly what I was looking to do - thanks. Also found this useful example once I knew what to look for:… – Jer Nov 7 '10 at 16:38

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

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

share|improve this answer

Your Answer


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.