I want to set a specific ethernet MAC address for an interface using UDEV rules. I have the following rule:
SUBSYSTEM=="net", ACTION=="add", ATTRS{serial}=="50B123", ATTR{address}="00:22:33:44:55:AA", NAME="yolo0"
The rule matches and the interface is renamed to "yolo0" however the hw ether address remains unchanged from the one pre-set by the manufacturer. I can change the mac address manually of course using:
ifconfig yolo0 hw ether ..00:22:33:44:55:AA
You can use udev
PROGRAM
rules for that, by making the appropriate call toip link set … address …
. Like this:/etc/udev/rules.d/10-network-persistent-custom-mac-address.rules
IMHO udev is the wrong place to do that, the rule is for setting the interface name.
There are two things to consider when you add a network card:
The name with which you'll refer to that interface
The network properties you'll give to an interface with a given name, the name you chosen in point 1.
This said, you can set your MAC address, IP, subnet, autoneg et cetera when you setup / bring up your network interface, for example, on RH /SuSE you can do this for (let's say) eth0 in:
For RedHat add in there:
For SuSE:
And you're good to go.