Thursday, November 10, 2011

Howto get network card vendor, device or kernel module from the /proc and/or /sys filesystem

Work in progress - place to keep notes to myself - may help someone else - cheat sheet kinda page ;)

1. How to get NIC/network card vendor information (scripted example)

for i in `ls -d /sys/class/net/eth*` do   ETH="`basename $i`"   echo -n "$ETH "   NICID="`cat /sys/class/net/$ETH/device/vendor|cut -c3-`"   grep "^$NICID" /usr/share/hwdata/pci.ids done
2. How to get the NIC/network card MAC address (simple example)
cat /sys/class/net/eth0/address
3. How to get the NIC/network kernel module and PCI device info (DETAILS). This can also derive the vendor and device info like above (simple example)
VENDOR="`cat /sys/class/net/eth0/device/modalias |cut -c6-13`" DEVICE="`cat /sys/class/net/eth0/device/modalias |cut -c15-22`" grep -i $VENDOR /lib/modules/`uname -r`/modules.alias | grep -i $DEVICE
OR generally
grep `cat /sys/class/net/eth0/device/modalias |cut -c-22` /lib/modules/`uname -r`/modules.alias
External important links for PCI or kernel module information for Linux:
http://www.pcidatabase.com/

4. How to find the WWN for a SAS end device (the arrary for example) card on RHEL 6, CentOS 6 or similar (simple example)
cat /sys/class/sas_device/*/sas_address
5. How to find the WWN for a SAS card on RHEL 6, CentOS 6 or similar (simple example)
cat /sys/class/sas_phy/*/sas_address

2 comments:

  1. Thanks for this valuable info.
    Is there a way of quickly mapping interfaces to their corresponding adapter slot in the system?
    for exmaple: eth0 is on slot 1 and so on.

    ReplyDelete
    Replies
    1. Many recent Linux OS's will not use the generic EthX designations, they will use the more specific "Consistent Network Device Naming" or "biosdevname". For example, LAN-on-motherboard will be an emp

      Delete