List availible NICs on Linux

4

I want to list all availible physical (or virtual on DomU) NICs connected to motherboard and see it's MAC addresses.
I guess that related information should be somewhere in /proc or may be in output of some command.
The option to list ifcfg-ethX files clearly not suitable here.

Thank you for ahead.

Rodnower

Posted 2010-08-21T21:24:17.720

Reputation: 1 739

Answers

5

/sys/class/net/*/address

Ignacio Vazquez-Abrams

Posted 2010-08-21T21:24:17.720

Reputation: 100 516

Thank you very much. And here is oneliner for match interface with MAC address. You are welcome to make it shorter: ls -d /sys/class/net/* | while read line; do echo -en "echo $line | cut -d'/' -f 5\t:"; echo -e "\tcat $line/address"; done – Rodnower – 2010-08-23T10:47:10.730

for i in /sys/class/net/* ; do echo -en "${i##*/}:\t" ; cat "$i"/address ; done – Ignacio Vazquez-Abrams – 2010-08-23T15:41:50.507