I have default gateway added in a specific routing table for eth0 interface in /etc/iproute2/rt_tables ,the table name being eth0-rt. However the outbound traffic is not working from the box. The moment the default gateway entry is added to the main routing table..the traffic seems to be working fine and it stops working when gateway is removed from the main table .Is it mandatory to add the default gateway entry in main routing table in addition to the same being added in custom made routing table for outbound traffic .
Detailed Explanation
I am working on busy box v31.1. where there are two interfaces namely eth0 and eth1.I have implemented a different routing table for each namely eth0-rt and eth1-rt after adding these entries in /etc/iproute2/rt_tables These are the ip route and rule commands I have added
ifconfig eth0 10.184.194.108 netmask 255.255.255.0 broadcast 10.184.194.255 mtu 1500 up ifconfig eth0 hw ether aa:bb:cc:dd:11:aa ip route add 10.184.194.0/24 dev eth0 src 10.184.194.108 table eth0-rt ip route add default via 10.184.194.1 dev eth0 table eth0-rt ip rule add from 10.184.194.108/32 table eth0-rt ip rule add to 10.184.194.108/32 table eth0-rt
ifconfig eth1 10.184.194.109 netmask 255.255.255.0 broadcast 10.184.194.255 mtu 400 up ifconfig eth1 hw ether aa:bb:cc:dd:11:bb ip route add 10.184.194.0/24 dev eth1 src 10.184.194.108 table eth1-rt ip route add default via 10.184.194.1 dev eth1 table eth1-rt ip rule add from 10.184.194.109/32 table eth1-rt ip rule add to 10.184.194.109/32 table eth1-rt
On adding these there is no default gateway entry in the "main' routing table, but the default entries are there in eth0-rt and eth1-rt routing tables. Inbound traffic via these IP addresses are working fine. But outbound traffic to internet is not working. Is it because I don't have the default gateway entry in main routing table. Is it necessary to have any of these default entries in main routing table too?
Hi Rob
I have the following ip rules added:
ip rule add from 10.184.194.108/32 table eth0-rt
ip rule add to 10.184.194.108/32 table eth0-rt
However outbound traffic did not work. But when I add the below rule
ip rule add from all table eth0-rt
It works. However I cannot proceed with this rule as I have another interface eth1, which can also be connected to establish internet connectivity when connected to a different network. Is a preference always required when two interfaces are used to establish internet connectivity ? I want the interfaces to be flexible, so I have created two different routing tables and two default gateways in each table separately and both these interfaces attempt to reach internet from two networks. Can that be possible without a preference ?Please assist