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 192.168.10.1 and VPN server IP 172.29.148.1, route to subnet 192.168.9.0/24 out 172.29.148.1 via 172.29.148.2 with src (source) IP 192.168.10.1:


sudo ip route add to 192.168.9.0/24 src 192.168.10.1 via 172.29.148.2

3 Comments

  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 192.168.1.103
    Local router is at 192.168.1.1

    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 10.1.10.2XX 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)

    ..ping 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