0

I am dealing with post systemd crapstorm where devices get renamed to eno1,2,3 or sometimes rename1,2,3. I don't run systemd as init system but unfortunately udevd is that systemd infected garbage what is broken now so it won't do much good adding /etc/systemd/network/*.link files.

I need a simple way to extract the device name eg eno1 for a mac address.

This would be possible with:

ip a

ifconfig -a

but is there a more convenient way from getting this info right out of the proc file system? So whatever the interface gets renamed I can always rename it back to eth0 and eth1. I also want to run this distro on a great variety of servers so this check list must be extensible by device mac ids.

msuser
  • 9
  • 3
  • What distribution are you using? A quick search turned up several ways of dealing with this but there were distribution-specific packages involved... – ivanivan Jul 10 '17 at 16:07
  • I would usually prefer `ip link` over `ip address` (which is of course what `ip a` abbreviates) for this particular purpose. Less extraneous output, for a start. Also I *think* a device can be in a state where in shows up in `link` but not `address`. – Darael Jul 10 '17 at 17:38

1 Answers1

2

You can easily get the MAC address of an interface using:

cat /sys/class/net/eth0/address
Khaled
  • 36,533
  • 8
  • 72
  • 99