/etc/udev/rules.d/70-persistent-net.rules

I had to make a post about this one file, because I often need to find it, yet never seem to remember the name or location of it. At times I will p2v a box, change the VMNIC or just in general mess with the NIC of an Ubuntu box. When you do this though, Ubuntu may detect it is a new/different NIC and map it to eth1 instead of eth0. In theory, not a big deal, but inconsistency can lead to problems later on. To change the MAC associated with an eth name, edit /etc/udev/rules.d/70-persistent-net.rules
Mine looks like this for example

user@ubuntu:~$ cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x14e4:0x167a (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:aa:a0:42:c3:24", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x14e4:0x168b (tg4)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:aa:a0:42:c3:26", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Now you can change the mac of the eth device, or what I do is just comment out the eth0 line, and change eth1 to eth0 on the second line. Commenting out changes is favorable in my opinion.  Hope this helps!

Comments are closed