How do I write a generic udev rule to assign my network's interface name?

1

I am trying to write a "generic" udev rule to assign an interface name to my NIC card.

For a particular application i require the ability to boot a headless server where the NIC can be changed at any point. However the Make and model of the NIC will stay the same.

so i have attacked the problem by trying to write a generic udev rule which will assign the required name (to be later matched to specific static network settings) to any NIC matching the Vednor and Model ID. my output of udevadm:

micromass@ComExATE:/sbin> sudo ./udevadm info --attribute-walk --query=all --pat          h=/sys/class/net/eth4
P: /devices/pci0000:00/0000:00:1c.5/0000:05:00.0/net/eth4
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:1c.5/0000:05:00.0/net/eth4
E: INTERFACE=eth4
E: IFINDEX=2
E: SUBSYSTEM=net
E: ID_VENDOR_FROM_DATABASE=Broadcom Corporation
E: ID_MODEL_FROM_DATABASE=NetXtreme BCM5761 Gigabit Ethernet PCIe
E: ID_BUS=pci
E: ID_VENDOR_ID=0x14e4
E: ID_MODEL_ID=0x1681

so my rule looked like this:

SUBSYSTEM=="net", ACTION=="add", ATTR{IDVENDOR_ID}=="0x14e4", ATTR{ID_MODEL_ID}=="0x1681", NAME="my-device"

However no luck. so i tried something a bit simpler and decided to match the first 3 sets of the MAC address (which are assigned to a vendor)

SUBSYSTEM=="net", ACTION=="add", ADDRESS=="00:30:64??:??:??", NAME="my-device"

Still no luck. i cant ever seem to change these rules to add symlinks instead of renaming.

Not sure where to go from here so any help would be great.

Chris Matheson

Posted 2011-11-18T13:55:13.013

Reputation: 11

Answers

1

You misspelled the attribute name: It's ID_VENDOR_ID. Not IDVENDOR_ID

Zuluking

Posted 2011-11-18T13:55:13.013

Reputation: 11

0

Run udev debug and look at syslog, does it match your rules or not. What opensuse version do you use? Btw, I'm not sure you can add ? in MAC address field. First check if udev can rename interface at all in your setup (here is an example config).

Cougar

Posted 2011-11-18T13:55:13.013

Reputation: 533