How to set up source based routing with Linux

This document (7008874) is provided subject to the disclaimer at the end of this document.


SUSE Linux Enterprise Server 12 Service Pack 3
SUSE Linux Enterprise Server 12 Service Pack 2
SUSE Linux Enterprise Server 11 Service Pack 4
SUSE Linux Enterprise Server 10 Service Pack 4


Separate routes must be used when sending data from two interfaces configured on the same subnet.


On standard Internet systems, when an IP packet needs to be routed, the decision of where to route the packet is made based on the destination address in the IP packet header. 
This default behavior works great when a host uses only a single interface connected to a LAN segment, however, it may cause unintended issues on systems where two interfaces are configured on the same subnet.
For this example, eth0 and eth1.
All the traffic not in the local subnet will be routed to the default gateway of x.x.x.x. But what if the packets originating from eth1 should be routed to y.y.y.y. The following steps will help in achieving this
  1. Edit /etc/iproute2/rt_tables.
  2. At the bottom, please type 100 SECONDPOA.
    Replace SECONDPOA with any other string.
  3. Save the file.
  4. Please type ip rule add from s.s.s.s table SECONDPOA where s.s.s.s is the IP Address of the eth1.
  5. Please type ip route add default via y.y.y.y dev eth1 table SECONDPOA and press Enter where y.y.y.y is the IP Address of the next hop for packets originating from eth1.
  6. To test it, please type
    traceroute -S p.p.p.p where p.p.p.p is the IP Address of eth0 and notice the next hop. This should be x.x.x.x

    traceroute -S s.s.s.s where s.s.s.s is the IP Address of eth1 and notice the next hop. This should be y.y.y.y
  7. Once the above test is successful, please follow the sub steps below to make ip rule statement persistent across reboot.
    • Create a file /etc/rc.d/rclocal .
    • Paste the following in the file. Modify the ip rule statement accordingly.
      # Provides: rclocal
      # Required-Start: $local_fs $remote_fs $network
      # X-UnitedLinux-Should-Start: $ALL
      # Required-Stop:
      # X-UnitedLinux-Should-Stop:
      # Default-Start: 3 5
      # Default-Stop: 0 1 2 6
      # Short-Description: Simulates rc.local
      # Description: Simulates redhat's rc.local: contains
      # commands to execute after system has booted (all services are already
      # available)
      ### END INIT INFO
      case "$1" in
      ip rule add from s.s.s.s table SECONDPOA
      exit 0
    • Save the file 
    • Type "chmod +x rclocal" without quotes and press Enter.
    • Type "chkconfig rclocal on" without quotes and press Enter.
  8. Once the above test is successful, please make the ip route statement persistent. Please edit /etc/sysconfig/network/routes and type
    default y.y.y.y - eth1 table SECONDPOA
    where y.y.y.y is the next hop that packets originating from eth1 needs to take.


This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7008874
  • Creation Date: 21-Jun-2011
  • Modified Date:23-Mar-2021
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center