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'm having some problems with routing with the following:

I have a server with 2 interfaces. It has 1-1 alias contains the same subnet. the 2 interface is connected to 2 switch, which are separated from each other. Infrastructure:


I have a PC which has the IP address:

The problem is the next:

  • If PC is on subnet 1, I can ping it.
  • If PC is on subnet 2, I can't ping it.

traceroute shows the route is across

ping -I is not working on subnet 2.

arp entries show the MAC address belonging to the correct interface (eth1 on subnet 2)

How can I force the server to look on both interface same ranged subnet for specific IP?

It searches only in the first subnet.

The routing table has these 2 entries: dev eth0 proto kernel scope link src dev eth1 proto kernel scope link src


So no way to linux kernel determine which interface has ip. We solved the problem with connect the separated subnet switch with each other, but traffic goes now out on ETH0.

The final way will be reconfig pc ip adresses during test to fit to the subnet ip range.

Thanks to the answers.

share|improve this question
Having two interfaces in the same subnet mean that unless you have separate routing tables, all traffic on that subnet will take the first matching entry. That would be dev eth0 proto kernel scope link src Search around here for "policy based routing", you will need to create multiple routing tables, each one with its own source address. A google search for the same terms(maybe include linux) will get you all the info you need. – NickW Nov 4 '13 at 12:13
Can u show an example for that situation? I checked rt_talbel, policy based routing, but not get exactly what i need. – Coolpet Nov 4 '13 at 13:03
Have a look at this response I typed up earlier:… then make slight changes, table 1 for eth0, table 2 for eth1, and specify the source address in each one. – NickW Nov 4 '13 at 13:07

We had the exact same configuration with different IP addresses. One host had an IP address configured on multiple interfaces, like: dev eth1  proto kernel  scope link  src dev eth2  proto kernel  scope link  src dev eth3  proto kernel  scope link  src

I just had to add ip routes like:

> ip route add dev eth3

So I had entries like:

> ip route show
... dev eth3  scope link dev eth2  scope link dev eth1  scope link

After those, it should work. @nickw suggesting the policy based rules might also be right, but I find this approach a bit easier.

Note: IMHO this is a really bad practice, we ended up having a lot of trouble with it. Also AFAIK you will not be able to access the host on the other interface without changing ip route or rule entries, so you have to reconfigure the tables if you move the machine to the different (physical) network.

share|improve this answer

The problem is the next:

If PC is on subnet 1, I can ping it. If PC is on subnet 2, I can't ping it.

How can I force the server to look on both interface same ranged subnet for specific IP?

This is not possible. Not at the kernel level.

You cannot have two routes on a routing table and expect that the kernel will try both when you do not specify anything else, like which interface or source IP address to use.

The basic rule of thumb is this: If an host is not reachable through an interface, DO NOT add a route for this host on that interface. Hosts are not supposed to be "smart" or magically guess which interface to use. If there is a route, the kernel always selects that route, even if it does not work.

You can have multiple routing tables depending on the source IP address, an application-specified output interface or a mark, or a tos, or many other parameters, and even multiple network namespaces, but at the end, if you only do a simple "ping", the kernel will only pick a single route in one of your routing table and it will use it.

Even if Linux has the technical possibility to round-robin which route to use, it will do so for every packet. If you use that, you will have a 50% packet loss to reach your host.

If you need this somewhat broken setup to work, either:

  • Bridge the two network, on your servers or on your switchs, even if it is only on the point of view of your server.
  • Ensure that your host can be seen from both networks
  • at layer 2, join your two interfaces and duplicate everything that get sent to eth0 to eth1. This is horrible, yes.
  • Stop moving from your two subnets.
  • Run a routing protocol on your server and on, so that routing tables are automatically adjusted depending on where is.
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.