Signal9Signal9 — home
online
back to labs

udev: Pin a Network Interface to a Stable Name by MAC

MediumKernel Security & Rootkits15-25 min
The brief

An interface should always come up under a fixed name, but it uses the kernel's default (which can change when NICs are re-enumerated). Write a udev rule under /etc/udev/rules.d/ that renames it — matching by the property that stays constant with the card: its MAC address, not the PCI slot path (KERNELS), which changes if the card is moved.

The device's attributes are in /root/case/udevadm-info.txt (a udevadm info -a walk); the target name is in /root/case/brief.txt. Grading reads the rule file — it does not run udevadm.

Rule shape (one line): SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="<mac>", NAME="<name>" (match keys use ==; NAME assigns with a single =, since NAME== would only compare and never rename).

What you'll do
  • Write a udev rule to persistently name a device
  • Match a device by a stable attribute (MAC) rather than a volatile one (PCI slot)
  • Read device attributes from a udevadm info walk

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.