Udev makes sure that your devices always get assigned the same device identifier. For network devices, this means that a particular network interface will always be eth0, and the second one always eth1.
This makes perfect sense, except in my scenario : I use VMWare workstation with 1 virtual machine that functions as my “template”. I keep this up to date with regards to CentOS version and VMWare tools, and also my ssh keys etc. Creating a new Virtual Machine is as simple as copying this “template” (actually the name is “cloning”).
Really annoying with udev, is that since the virtual machine receives new virtual hardware, eth0 is no longer found and I need to reconfigure the network interfaces every time.
In addition, I need to edit the file
/etc/udev/rules.d/70-persistent-net.rules , to remove the previous “eth0” interface and renaming “eth1” to “eth0”.
I have not found a good way to disable these rules for networking, because if you remove the file
/etc/udev/rules.d/70-persistent-net.rules, it’s recreated automatically on reboot. There’s no setting to disable persistent net rules afaik without disabling udev altogether (which is not what I want either).
But this does seem to work :
as root , remove also the file that is used by udev to recreate the
/etc/udev/rules.d/70-persistent-net.rules file :
rm /lib/udev/write_net_rules rm /etc/udev/rules.d/70-persistent-net.rules
If udev is updated , the file
/lib/udev/write_net_rules will likely be recreated, so it’s a workaround at best.
After cloning the virtual machine, I now just need to change the hostname and potentially change the ip address (if the vmware dhcp is not nice to me and gives an ip address that’s already in use …)
system-config-network to do this, this modifies the
/etc/sysconfig/network-scripts/ifcfg-eth0 file for me :
(update : for Redhat 7 , there is no system-config-network anymore, but you can use nmtui . Same difference)
This shows the eth0 device …
No need to change anything in the device (unless you want to set it to a fixed ip address)
The DNS configuration is actually where it’s at.
Now edit it , the hostname will always need to be edited in my case. The dns server points to my host machine, as described here Setup dnsmasq
Save and quit, and restart the network (or better, reboot the virtual machine).