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.
For sure :)
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)You might find that arping is more likely to hit the wire, as this uses arp, and therefore avoids the IP stack completely.
In this scenario its doubtful the signal will ever actually 'hit the wire'. Since the device will see that it has both IP address assigned to one interface, all of the MAC look-up / routing (if the two interfaces are in different subnets) will happen in the system itself and never hit the physical interface.
The loopback connector can be used to trick the box into seeing the interface as 'up' so you can do this testing, but just using a normal cable and a spare switchport would accomplish the same thing.
If instead you mean you will be connecting eth0 to eth1 in the same box, then you can just use a cross-over cable, but the same thing may happen as above.
Ethernet loopback plug: http://www.tikkiweb.net/loopback
I did a bit of research and found this page on converting the ethernet signals to light, and testing that in a loopback configuration: http://ronja.twibright.com/testing/ploss_tetrapolis_ping.php.
Unfortunately, this isn't a true ping, as you simply only see the same ICMP packet twice in Wireshark/tcpdump. It does guarantee that the signal hits the wire though.