Change Linux CentOS Ethernet Interface Name to Default eth0
Check Network Interface information:

Before reboot :
[roo[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Change ethernet name from ens3 to eth0.
But still in next reboot it might change to earlier one, for this we have to make them persistent through editing it system file named /usr/lib/udev/rules.d/60-net.rules
- ip a
- ip l
- nmcli d
- nmtui
Disable Consistent Interface Device Naming
To regain the ethX back, edit the grub file.
vi /etc/default/grub
Look for GRUB_CMDLINE_LINUX and add or change to the following net.ifnames=0.

FROM:
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
TO:
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet"
[[email protected] ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:00:17:00:b1:dc brd ff:ff:ff:ff:ff:ff
inet 10.0.0.2/24 brd 10.0.0.255 scope global dynamic ens3
valid_lft 86202sec preferred_lft 86202sec
inet6 fe80::17ff:fe00:b1dc/64 scope link
valid_lft forever preferred_lft forever
[[email protected] ~]# vi /etc/default/grub
[[email protected] ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1062.12.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.12.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-229.1.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.1.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-64cb9cb13e6a425f9bca6c461e593eb3
Found initrd image: /boot/initramfs-0-rescue-64cb9cb13e6a425f9bca6c461e593eb3.img
Found linux image: /boot/vmlinuz-0-rescue-5eef1a77fa764e12a0a38a6c52d9818b
Found initrd image: /boot/initramfs-0-rescue-5eef1a77fa764e12a0a38a6c52d9818b.img
done
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens3
# Generated by dracut initrd
NAME="ens3"
DEVICE="ens3"
ONBOOT=yes
NETBOOT=yes
UUID="673dfd0f-eece-41f6-b538-6233106248df"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
NM_CONTROLLED=no
[[email protected] ~]# mv /etc/sysconfig/network-scripts/ifcfg-ens3 /etc/sysconfig/network-scripts/ifcfg-eth0
[[email protected] ~]# systemctl disable NetworkManager
[[email protected] ~]#
[[email protected] ~]#
Before reboot :
[roo[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
...... NAME=eth0 DEVICE=eth0 ......
Change ethernet name from ens3 to eth0.
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service' rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service' rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'
But still in next reboot it might change to earlier one, for this we have to make them persistent through editing it system file named /usr/lib/udev/rules.d/60-net.rules
[[email protected] ~]# cat /usr/lib/udev/rules.d/60-net.rules ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="52:54:00:5f:d0:28", NAME="eth0"
Now we permanent rename Network Ethernet cards name to required one.
[[email protected] rules.d]# pwd
/etc/udev/rules.d
[[email protected] rules.d]# cat 70-persistent-net.rules |grep -v \#
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:4e:40:9a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
[[email protected] rules.d]#
[[email protected] ~]#reboot
Unmask NetworkManager Service
nmtui is the command to launch NetworkManager. In previous section, we have disabled and masked this serviec. Here is the step to unmask and enable it.[[email protected] ~]# systemctl list-unit-files | grep Network NetworkManager-dispatcher.service disabled NetworkManager-wait-online.service masked NetworkManager.service masked [[email protected] ~]# systemctl unmask NetworkManager Removed symlink /etc/systemd/system/NetworkManager.service. [[email protected] ~]# systemctl start NetworkManager [[email protected] ~]# nmtui [[email protected] ~]# systemctl status NetworkManager
[[email protected] ~]# systemctl unmask NetworkManager.service
Removed symlink /etc/systemd/system/NetworkManager.service.
[[email protected] ~]# systemctl unmask NetworkManager-wait-online.service
Removed symlink /etc/systemd/system/NetworkManager-wait-online.service.
No comments