Link State Detection

Matthew Carpenter matt
Mon Nov 22 07:02:13 PST 2004


James McDonald wrote:

> I have a linux server with three nics in it.
>  
> 2 are using ne2k-pci cards and one is a 8139too card
>  
> I can use ethtool to find out the Link state on the 8139too
>  
> simply by running
>  
> ethtool eth0
> <snippage>
> Link detected: no
>  
> Which gives me th Link State of yes or no.
>  
> However running it on the  ne2k-pci doesn't give me squat
>  ethtool eth1
> Settings for eth1:
> No data available
> What is a universally useful command to detect the link state of a NIC?
>
> This would be handy because I sometimes don't know which interface I'm 
> plugged in to.
>  

I'm not sure if *anything* is universally going to tell you link-state, 
since some hardware and drivers do strange things.
I've found that one crude way is to look for the "RUNNING" state on 
/sbin/ifconfig.  Play with it, I think you'll like it.

/sbin/ifconfig -a | grep -B3 RUNNING | grep Link.encap | cut -c0-9

should give you a list of connected NIC's.
Hope this helps.



More information about the Linux-users mailing list