Rename the NIC name in centos7.x/RedHat7.x
On CentOS7.x or RedHat7.x, the NIC naming rule is changed to default, which is automatically determined based on the firmware, topology, and location information. In this way, although there are benefits, it will also affect the operation, because the new naming rules are more difficult to read than the previous ones. If you want to modify it, follow these steps:
1. After the system is installed, the NIC information may be as follows:
1: lo: <LOOPBACK, UP, LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
Link/loopback 00: 00: 00: 00: 00: 00 brd00: 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: eno16777736: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_faststate UP qlen 1000
Link/ether 00: 0c: 29: 8b: e3: 0f brdff: ff
Inet 10.0.0.20/24 brd 10.0.0.255 scopeglobal eno16777736
Valid_lft forever preferred_lft forever
Inet6 fe80: 20c: 29ff: fe8b: e30f/64 scopelink
Valid_lft forever preferred_lft forever
2. Modify the NIC configuration file, Set NAME To eth0, and delete the DEVICE line.
[Root @ test ~] # Cd/etc/sysconfig/network-scripts/
Root @ test ~] # Vim ifcfg-eno16777736.
3. modify the configuration file name
[Root @ testnetwork-scripts] # Music ifcfg-eno16777736 ifcfg-eth0
[Root @ testnetwork-scripts] # cd
4. Modify/etc/sysconfig/grub and add net. ifnames = 0 biosdevname = 0.
[Root @ test ~] # Vim/etc/sysconfig/grub
Before modification:
GRUB_TIMEOUT = 5
GRUB_DEFAULT = saved
GRUB_DISABLE_SUBMENU = true
GRUB_TERMINAL_OUTPUT = "console"
GRUB_CMDLINE_LINUX = "crashkernel = auto rhgb quiet"
GRUB_DISABLE_RECOVERY = "true"
Modified content:
GRUB_TIMEOUT = 5
GRUB_DEFAULT = saved
GRUB_DISABLE_SUBMENU = true
GRUB_TERMINAL_OUTPUT = "console"
GRUB_CMDLINE_LINUX = "crashkernel = auto net. ifnames = 0 biosdevname = 0 rhgb quiet"
GRUB_DISABLE_RECOVERY = "true"
5. regenerate grub configuration and update Kernel Parameters
[Root @ test ~] # Grub2-mkconfig-o/boot/grub2/grub. cfg
Restart and view the changes.
6. Create a rule
If you have multiple NICs and want the controller device name, instead of naming the kernel as your own, you need to modify the rules.
[Root @ test ~] # Vim/etc/udev/rules. d/70-persistent-ipoib.rules
SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR (address) =" 00: 0c: 29: 8b: e3: 0f ", ATTR (type) =" 1 ",
KERNEL = "eth *", NAME = "eth0"
Restart the system.