Linux – Ethernet Loopback plug – running a ping

ethernetlinuxpingtcpiptesting

For a project at work, I need to be able to test various Ethernet NICs by connecting them to a "loopback adapter plug", like this one on various embedded Linux boxen that come off a production assembly line. I'd like to be able to setup two different IP addresses (AddressA and AddressB) on one Ethernet interface, and then run a ping from AddressA to AddressB.

Ex:  ping -I AddressA AddressB

Is this even possible?

Also, is there a test available that would test the Ethernet interface solely on a L2 / MAC address level using the loopback plug? If I recall, RealTek had a diagnostics tool for their 8139 ethernet adapters that did a L2-only loopback test of sorts, and I was wondering if there was a linux tool that did the same.

UPDATE: Added comments about why I'm testing the boxes in the above comments. I'll have to try out some of these ideas this weekend to see what happens. Maybe make my own "loopback adapter plug" using a keystone jack + some wires from a hardware store, and try to see if I can peek at the signals using an oscilloscope or logic analyser to ensure that signals are actually hitting the wire. Since this seems to be harder than expected, our team at work made the decision to test the Linux boxen ethernet ports by picking up a small home NAT router and then pinging the router, and putting that in the hardware test fixtures. Still, I'm intrigued by the technical aspects of this and want to experiment on this subject on my own.

Best Answer

For sure :)

# ip address list dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:1e:4f:9b:4a:ab brd ff:ff:ff:ff:ff:ff
    inet 10.10.141.83/24 brd 10.10.141.255 scope global eth0
    inet6 fe80::21e:4fff:fe9b:4aab/64 scope link 
       valid_lft forever preferred_lft forever
# ip address add 10.10.141.253/24 dev eth0
# ip address list dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:1e:4f:9b:4a:ab brd ff:ff:ff:ff:ff:ff
    inet 10.10.141.83/24 brd 10.10.141.255 scope global eth0
    inet 10.10.141.253/24 scope global eth0
    inet6 fe80::21e:4fff:fe9b:4aab/64 scope link 
       valid_lft forever preferred_lft forever
# ping -I 10.10.141.83 10.10.141.253
PING 10.10.141.253 (10.10.141.253) from 10.10.141.83 : 56(84) bytes of data.
64 bytes from 10.10.141.253: icmp_seq=1 ttl=64 time=0.050 ms
64 bytes from 10.10.141.253: icmp_seq=2 ttl=64 time=0.034 ms
64 bytes from 10.10.141.253: icmp_seq=3 ttl=64 time=0.038 ms
^C
--- 10.10.141.253 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.034/0.040/0.050/0.010 ms
# ip address delete 10.10.141.253/24 dev eth0
# ping -I 10.10.141.83 10.10.141.253
PING 10.10.141.253 (10.10.141.253) from 10.10.141.83 : 56(84) bytes of data.
From 10.10.141.83 icmp_seq=1 Destination Host Unreachable
From 10.10.141.83 icmp_seq=2 Destination Host Unreachable
From 10.10.141.83 icmp_seq=3 Destination Host Unreachable
^C
--- 10.10.141.253 ping statistics ---
4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3016ms

Actually dead simple. :) (Just kidding, it's always simple if you already know it)

I'm not sure L2 would really work but with ip neigh you can should be able to modify the arp cache also (so much for dead simple)

Related Topic