Problem is, say you're not really set on the MAC you've got (it's a VM and you cloned it, clones get a new MAC. It's a physical box and that card died, replace it and it's got a new MAC). How do you get that coveted eth0 label back so you don't have to change a lot of things**? Well, to quote Dr. Seuss "We can do it, we know how".
Pull yourself a quick ifconfig listing. Note the MAC address of the NIC you want to be, say, eth0 in this case.
[root@mysystem ~] # ifconfig |grep HWaddr
eth1 Link encap:Ethernet HWaddr 00:50:56:88:00:74
eth2 Link encap:Ethernet HWaddr 00:50:56:88:00:75
eth3 Link encap:Ethernet HWaddr 00:50:56:88:00:7b
eth1 Link encap:Ethernet HWaddr 00:50:56:88:00:74
eth2 Link encap:Ethernet HWaddr 00:50:56:88:00:75
eth3 Link encap:Ethernet HWaddr 00:50:56:88:00:7b
In this case, there used to be an eth0 and when I cloned this box, I got eth3. Let's change that.
[root@mysystem ~] # cat /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:88:00:74", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:88:00:75", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:88:00:7b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:88:00:74", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:88:00:75", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:88:00:7b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
What we need to do is edit this file and change that last 'NAME="eth3"' to 'NAME="eth0"'.
Now, I'd say reboot, but you need to do one more check first... Make sure you have something in /etc/sysconfig/network-scripts/ifcfg-eth0 and make sure of two things, if you have a Device= line that it says eth0 (In case you thought you'd be clever by copying ifcfg-eth3 to ifcfg-eth0 and rolling with it). Also, make sure if it has a HWADDR= line that it equals the new MAC and not the old one. Truthfully, since udev does the association from MAC->device name, this line isn't necessary and I almost always comment it out (# at the front of the line works in this file), but CentOS's "system-config-network" script adds it in there, so watch out. Okay, now reboot!
** I know, this doesn't seem like that big of a deal, but if you have a complex setup of many NICs and/or are using a monitoring program to watch traffic on a specific NIC, you now have more to change. Especially if there's a group of servers that match and now this one doesn't, etc.
No comments:
Post a Comment