Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Ubuntu Server 12.04

I have 3 gateways on my lan

Ubuntu has 3 NICs

eth0 gw
eth1 gw
eth2 gw

If a request comes in from gw it work fine. the other gateways don't

I have tried to fix this with routes but I can't seem to get it right.

My ISP can only give 10Mbps up per modem the server streams a live video feed. I need all 3 modems for load balancing

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    100    0        0 eth0   U     0      0        0 eth1   U     0      0        0 eth2   U     0      0        0 eth0

If this could be done with one NIC I am fine with that I just need to be able to balance this traffic.

I tried this (but all networking stopped after):

#echo "60 out60" >> /etc/iproute2/rt_tables
#echo "61 out61" >> /etc/iproute2/rt_tables
#echo "62 out62" >> /etc/iproute2/rt_tables

#ip route add default via table out60
#ip route add default via table out61
#ip route add default via table out62

#ip rule add from table out60
#ip rule add from table out61
#ip rule add from table out62

This Diagram doesn't have the server in question its just so you can see the network layout.

Network Diagram
share|improve this question
Why do you have three gateways for a web server? – Joel E Salas Aug 9 '13 at 2:46
Wut... where is all the traffic going? Why three gateways? – ewwhite Aug 9 '13 at 2:47
My ISP can only give 10Mbps up per modem the server streams a live video feed. I need all 3 modems for load balancing. – Eric Fluharty Aug 9 '13 at 2:50
What does you routing table look like? You might have to configure each one to be on a separate subnet. – Ryan Gibbons Aug 9 '13 at 4:14
This network is in a production environment. I can't change the design of the network, only the server its self. – Eric Fluharty Aug 9 '13 at 6:05

I will strongly recommend to change subnet. It's very bad idea to use the same subnet for all interfaces and their gateways, imho

I would suggest to use something like the following

eth0 gw
eth1 gw
eth2 gw

You could try to setup PBR, but I don't know, if it would work in your environment





/sbin/ip route add $P1_NET dev $IF1 src $IP1 table ISP1
/sbin/ip route add default via $GW1 table ISP1

/sbin/ip route add $P2_NET dev $IF2 src $IP2 table ISP2
/sbin/ip route add default via $GW2 table ISP2

/sbin/ip route add $P3_NET dev $IF3 src $IP3 table ISP3
/sbin/ip route add default via $GW3 table ISP3

/sbin/ip rule add from $IP1 table ISP1
/sbin/ip rule add from $IP2 table ISP2
/sbin/ip rule add from $IP3 table ISP3

/sbin/ip route add default via $P1
/sbin/ip route flush cache

Don't forget to enable ip forwarding and disable Reverse Path Filtering

# echo 1 > /proc/sys/net/ipv4/ip_forward
# echo 0 > /proc/sys/net/ipv4/conf/default/rp_filter
share|improve this answer
I can not modify the network. I have many other production systems running on this network. – Eric Fluharty Aug 9 '13 at 23:40
I will try this again, but last I tried it broke networking. – Eric Fluharty Aug 9 '13 at 23:54
$ sudo ip route add dev eth0 src table ISP1 RTNETLINK answers: Invalid argument – Eric Fluharty Aug 10 '13 at 1:03
I removed the scr field from this command, it ran successfully but didn't work in the end # ip route add dev eth2 table ISP3 – Eric Fluharty Aug 10 '13 at 1:23
Did you add ISP1/ISP2/ISP3 to the /etc/iproute2/rt_tables ? – ALex_hha Aug 10 '13 at 6:36

The confusion expressed in the comments stems from this Private Class A LAN networking scheme being not very conventional or common in practice. Usually each net block is (a /28,/16 etc.) is broken up and the gateway set to the first usable IP. In this case it looks like each modem is a /31.

Paste output of route -n or netstat -nra (should work on most *nix variants) if you're interested as to what gateway each interface believes it has, for further diagnosis.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.