Rename CentOS multi-nic Configuration
I have installed three NICs in CentOS7, but the name is in the enoxxxxx format, which makes my obsessive *** seat very uncomfortable, the following describes how to configure the NIC and rename it to ethx.
Prerequisites:
1. view the NIC UUID
# Nmcli con show
Name UUID Type Device
Eth1 dfc9199c-7b47-4209-a396-109bf44e683a 802-3-ethernet eth1
Eth2 020d86aa-548f-49c2-9cb0-f6cfffdb8219 802-3-ethernet eth2
Eth0 a5e6ae5c-dd71-48be-b374-ad64121bd785 802-3-ethernet eth0
2. View Nic Information
# Nmcli device show [device name] example:
# Nmcli device show eth0
GENERAL. device: eth0
GENERAL. Type: ethernet
GENERAL. Hard Disk: 00: 0C: 29: 94: C8: 08
GENERAL. MTU: 1500
GENERAL. Status: 100 (connected)
GENERAL. CONNECTION: eth0
GENERAL.CON-PATH:/org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES. Container: On
IP4. Address [1]: 192.168.66.4/24
IP4. Gateway: 192.168.66.1
IP4.DNS [1]: 202.106.46.151
IP6. Address [1]: fe80: 20c: 29ff: fe94: c808/64
IP6. Gateway:
Enter the subject
Go to the NIC configuration file directory
# Cd/etc/sysconfig/network-scripts
Rename the NIC
# Mv ifcfg-eno16777736 ifcfg-eth0
Modify the NIC information, not very familiar friends please refer to my another detailed explanation of http://baoer7758.blog.51cto.com/8187563/1638229
# Vim ifcfg-eth0.
HWADDR = 00: 0c: 29: 94: c8: 08
TYPE = Ethernet
BOOTPROTO = static
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
20174_failure_fatal = yes
NAME = eth0
UUID = a5e6ae5c-dd71-48be-b374-ad64121bd785
# DEVICE = eno16777736
ONBOOT = yes
IPADDR = 192.168.66.4
NETMASK = 255.255.255.0
GATEWAY = 192.168.66.1
DNS1 = 202.106.46.151
# DEVICE = eth0
Copy the configuration file two copies as the configuration file for the other two NICs
# Cp ifcfg-eth0 ifcfg-eth1
# Cp ifcfg-eth0 ifcfg-eth2
Edit and modify:
# Vim ifcfg-eth1.
HWADDR = 00: 0c: 29: 94: c8: 12
TYPE = Ethernet
BOOTPROTO = static
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
20174_failure_fatal = yes
NAME = eth1
UUID = dfc9199c-7b47-4209-a396-109bf44e683a
ONBOOT = yes
IPADDR = 192.168.67.4
NETMASK = 255.255.255.0
# DEVICE = eth0
Edit and modify
# Vim ifcfg-eth2.
HWADDR = 00: 0c: 29: 94: c8: 1c
TYPE = Ethernet
BOOTPROTO = static
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
20174_failure_fatal = yes
NAME = eth2
UUID = 020d86aa-548f-49c2-9cb0-f6cfffdb8219
# DEVICE = eno16777736
ONBOOT = yes
IPADDR = 192.168.68.4
NETMASK = 255.255.255.0
# DEVICE = eth0
Start to rename the configuration, not very knowledgeable friends please refer to my another detailed explanation http://baoer7758.blog.51cto.com/8187563/1638229
# Vi/etc/sysconfig/grub
GRUB_TIMEOUT = 5
GRUB_DEFAULT = saved
GRUB_DISABLE_SUBMENU = true
GRUB_TERMINAL_OUTPUT = "console"
GRUB_CMDLINE_LINUX = "rd. lvm. lv = centos/root rd. lvm. lv = centos/swap crashkernel = autoNet. ifnames = 0 biosdevname = 0 net. ifnames = 1 biosdevname = 1 net. ifnames = 2 biosdevname = 2 rhgb quiet "// bold to add content
GRUB_DISABLE_RECOVERY = "true"
Reload to startup
# Grub2-mkconfig-o/boot/grub2/grub. cfg
Generating grub configuration file...
Found linux image:/boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image:/boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image:/boot/vmlinuz-0-rescue-9bede79b46bd4e9696b92a4ec68a97b1
Found initrd image:/boot/initramfs-0-rescue-9bede79b46bd4e9696b92a4ec68a97b1.img
Done
Restart system reboot
View Nic Information
# Ifconfig
Eth0: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500
Inet 192.168.66.4 netmask 255.255.255.0 broadcast 192.168.66.255
Inet6 fe80: 20c: 29ff: fe94: c808 prefixlen 64 scopeid 0x20 <link>
Ether 00: 0c: 29: 94: c8: 08 txqueuelen 1000 (Ethernet)
RX packets 690 bytes 69262 (67.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 488 bytes 65725 (64.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Eth1: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500
Inet 192.168.67.4 netmask 255.255.255.0 broadcast 192.168.67.255
Inet6 fe80: 20c: 29ff: fe94: c812 prefixlen 64 scopeid 0x20 <link>
Ether 00: 0c: 29: 94: c8: 12 txqueuelen 1000 (Ethernet)
RX packets 129 bytes 15944 (15.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 26 bytes 3927 (3.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Eth2: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500
Inet 192.168.68.4 netmask 255.255.255.0 broadcast 192.168.68.255
Inet6 fe80: 20c: 29ff: fe94: c81c prefixlen 64 scopeid 0x20 <link>
Ether 00: 0c: 29: 94: c8: 1c txqueuelen 1000 (Ethernet)
RX packets 127 bytes 15613 (15.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 25 bytes 3609 (3.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Lo: flags = 73 <UP, LOOPBACK, RUNNING> mtu 65536
Inet 127.0.0.1 netmask 255.0.0.0
Inet6: 1 prefixlen 128 scopeid 0x10
Loop txqueuelen 0 (Local Loopback)
RX packets 4 bytes 420 (420.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 420 (420.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0