Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show Ethernet drivers on Linux
% what_eth_drivers.sh
br0 [ac:22:0b:c3:cd:2a]: (up)
docker0 [02:42:6b:bb:b4:67]: (down)
enp3s0 [ac:22:0b:c3:cd:2a]: r8169 (up)
enp5s0 [00:01:02:d8:91:07]: 3c59x (unknown)
enx00e04c6800e5 [00:e0:4c:68:00:e5]: r8152 (down)
lo [00:00:00:00:00:00]: (unknown)
vmnet1 [00:50:56:c0:00:01]: (unknown)
vmnet8 [00:50:56:c0:00:08]: (unknown)
#!/bin/bash
#
# See: https://unix.stackexchange.com/a/225496/50007
# See: https://gist.github.com/JonathonReinhart/573694d541dc2108f7629aaa615cef3b
#
for f in /sys/class/net/*; do
dev=$(basename "$f")
driver=$(readlink "$f/device/driver/module")
if [ "$driver" ]; then
driver=$(basename "$driver")
fi
addr=$(cat "$f/address")
operstate=$(cat "$f/operstate")
printf "%16s [%s]: %10s (%s)\n" "$dev" "$addr" "$driver" "$operstate"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment