Home   >>   Networking   >>   How To Route Reply Packets Out Over The Same Interface Where They Came In
How To Route Reply Packets Out Over The Same Interface Where They Came In PDF Print E-mail
( 8 Votes )
How To - Networking
Written by Christian Foronda   
Monday, 07 March 2011 11:46

Situation: Query packets are received over one network interface, but response/reply packets are sent out over a different interface (typically, eth0).

Solution: To route response/reply packets out over the same interface that the packets that they are a response to came in on, separate routing tables (based on the incoming interface) can be set up. For a detailed explanation, refer to the "Split Access" section of the "Rules - routing policy database" chapter in the Linux Advanced Routing & Traffic Control HOWTO (LARTC).

Requirements: iproute2

Add the following on the bottom of /etc/iproute2/rt_tables:

250 foo
251 bar

 

Set the routing rules:
Where:
eth0 - 192.168.0.10
eth1 - 192.168.0.11
gw - 192.168.0.1

ip route add 192.168.0.0/24 dev eth0 src 192.168.0.10 table foo
ip route add default via 192.168.0.1 dev eth0 src 192.168.0.10 table foo
ip rule add from 192.168.0.10 table foo

ip route add 192.168.0.0/24 dev eth1 src 192.168.0.11 table bar
ip route add default via 192.168.0.1 dev eth1 src 192.168.0.11 table bar
ip rule add from 192.168.0.11 table bar

 

Reference:
http://lartc.org/howto/

 




blog comments powered by Disqus
Last Updated on Thursday, 30 June 2011 22:27