Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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've got two subnets and a RedHat 5.3 with 2 NIC, each with an IP on a single subnet:


On each subnet I've got a Gateway / Firewall and I'd like to forward each NIC on its own GW. This is the current routing table:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface      *        U     0      0        0 eth1     *        U     0      0        0 eth0
default         UG    0      0        0 eth1

If I first try to delete the already existing rule on net and next use the following command

route add -net netmask gw dev eth0

It returns

SIOCADDRT: Network is unreachable

Could anyone explain me in simple words the reason for that message and possibly how I can accomplish the goal.

Thanks in advance Regards

Alessandro Ilardo

share|improve this question
up vote 2 down vote accepted

First off, the route you're adding is on the same network segment as the interface itself. This means there's no need to use a router/gateway when sending those packets. The interface is able to address the host directly. The local switch will get it there without using a router as an intermediary.

You are getting an error when adding your rule because it's a rule that defines how to send packets to a whole network, by giving directions to send to a specific host on that network. It's a catch-22. In order to send a packet to that gateway, you need to know how to get to its IP address. In order to send to its IP address, you have to go through that gateway. It's like telling someone In order to get to Main Street, go to 1512 Main Street, and ask the guy who lives there.

Now, as far as a proper gateway is concerned, that's what the last line in your routing table does. It routes all traffic to that hasn't been matched by the rules above it. THIS is your default gateway. You don't need a GW for your second NIC, because ALL non-local traffic goes through this gateway.

If you wanted to split half your traffic through the other NIC/GW, you'd need to define which networks to do so. eg: route add -net netmask gw dev eth1 will get JUST the 10.x.x.x network routed through your second NIC.

share|improve this answer
He's right. If your interface is already on that subnet, it doesn't need an explicit route to other addresses on that subnet. In terms of his "Main Street" example, you don't need to ask anyone how to get to a house on main street when you already live on main street. – Satanicpuppy Feb 5 '10 at 15:28
very clear. Thanks – AleIla Feb 5 '10 at 15:30

i think you have to swap the devices. try this:

route add -net netmask gw dev eth1

this should be the corresponding rule to your setup:

share|improve this answer
Sorry, that's my mistake, they're actually swapped. – AleIla Feb 5 '10 at 14:08

You can also make some policy based routing

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.