Source routing for a VPN node in Linux

Occansion in Linux when running a VPN you want to generate traffic from the VPN server node. By default Linux uses the IP of the interface used to route a package. The might often complicated the routing tables required at client networks.

A solution to fix this issue is to use Linux source/policy routing. For example, for node with IP and VPN server IP, route to subnet out via with src (source) IP

sudo ip route add to src via


  1. travis Said,

    January 2, 2009 @ 12:33 pm

    I’m having a problem trying to route traffic over a VPN that I set up, maybe you can clarify things for me..

    My local computer has an IP of
    Local router is at

    The network I’m connecting to has LAN IPs in the 10.1.10.XXX range.

    my vpn is created as adapter ppp0 with an IP in the range

    For this scenario, how do I direct traffic over the VPN?

  2. travis Said,

    January 2, 2009 @ 12:40 pm

    ..just to clarify; when VPN (ppp0) is up I am not able to get any response from a ping to any computer on the remote network (10.1.10.XXX) works fine if I connect from windows!

  3. Nicholas Lee Said,

    January 7, 2009 @ 9:42 am

    ppp0 on the router or your local computer?

    Note this important point: “By default Linux uses the IP of the interface used to route a package.”

RSS feed for comments on this post