What command can you use to find the Gateway IP Address (ie. home router address) for eth0 in Linux?
I need to get the IP address from a command line app to use in a shell script.
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.