Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have two systems and each have a NIC with two ethernet ports. One system has a verified NIC card, but the other has a NIC which has to be verified.

I use ping to verify whether the interfaces on the NIC card is functioning correctly.

Why does each interface have to be on a different subnet for ping to work?

For example:

System 1:  eth0 (10.0.0.1), eth1 (10.0.1.1) -->This NIC is tested good
                  ^                ^
                  |                |
                  V                V
System 2:  eth0 (10.0.0.2), eth1 (10.0.1.2) -->This NIC is being tested

In this setup, eth0 on System 1 is connected to eth0 on System 2. And eth1 on System 1 is connected to eth1 on System 2. I am using submet mask of 255.255.255.0.

So on System 2, I would do the following:

$ ping -I eth0 -c 100 -qA 10.0.0.1
$ ping -I eth1 -c 100 -qA 10.0.1.1

Why couldn't I have this setup though?

System 1:  eth0 (10.0.0.1), eth1 (10.0.0.2) -->This NIC is tested good
                  ^                ^
                  |                |
                  V                V
System 2:  eth0 (10.0.0.3), eth1 (10.0.0.4) -->This NIC is being tested

And then do:

$ ping -I eth0 -c 100 -qA 10.0.0.1
$ ping -I eth1 -c 100 -qA 10.0.0.2

What is it about having a host with multiple interfaces?

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth1
10.0.1.0        0.0.0.0         255.255.255.0   U         0 0          0 eth2
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
192.168.0.0     0.0.0.0         255.255.252.0   U         0 0          0 eth0
share|improve this question
    
what do you want to ask? ping still works even if your interfaces in the same subnet. –  Gnouc Jul 3 at 7:07
    
netstat -rn | grep default –  Warwick Jul 3 at 7:08
    
@Gnouc : You will not be able to ping in the second setup of using ip address (10.0.0.1-4). ping will only work in the first case. –  user1527227 Jul 3 at 7:12
    
@Warwick what is that supposed to do? –  user1527227 Jul 3 at 7:12
    
@user1527227: Is your two host in the same network or not? –  Gnouc Jul 3 at 7:15

1 Answer 1

If you have a different network configured for eth1 on systems 1 and 2, then by default, any packets for that network will use those interfaces, rather than eth0. When they are all on the same network though, they will get sent via the default route unless there is a specific route specified on system 2 that says send packets to 10.0.0.2 via 10.0.0.4.

To view the routing table on system 2, run

netstat -rn

If no specific route is set up for this network, then the default route will be used.

To change that behaviour, you would run on system 2 a command similar to:

route add -host 10.0.0.2 10.0.0.4

(Sorry, I don't use Ubuntu so the syntax may be different. Perhaps someone can verify and edit this answer if required.)

share|improve this answer

Your Answer

 
discard

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.