How to change the NIC name in CentOS 6.X

  
                

Usually the network card name is automatically recognized by the system and exists in the registry. However, some users want to modify the network card name of the CentOS6.x system for some reason. How do the network card name change? Let's take a look at it with Xiaobian.

CentOS 6.X modify the network card under the name of three ways:

Method 1:

UDEV modify the file, delete the contents inside; command, redefined Name, both names must be changed;

Method 2:

In centos6, you can use setup directly, set up a new network card, fill in eth1, ip and so on.

In CentOS 6, the default kudzu service for identifying hardware does not exist. Basically all hardware management is managed by Udev.

If you add a new hardware to Centos 6, for example, the network card only needs to restart udev.

start_udev

It will rescan the newly added hardware and do related processing.

If the new network card is added, the identification is incorrect and sometimes you want to update the name of the network card, you do not need to edit the contents of /etc/sysconfig/network-scripts/, after running to the above, it is not normal, directly modify Udev can be configured for the network.

The configuration file for the specific NIC serial number of the udev of the network is /etc/udev/rules.d/70-persistent-net.rules.

Probably as follows:

SUBSYSTEM==“net”, ACTION==“add”, DRIVERS==“? *”, ATTR{address}==“54:52:00:78:e8:2e”, ATTR{type}==“1”, KERNEL==“eth*”, NAME=“ Eth1” # PCI device

0x1af4:0x1000 (virtio-pci) SUBSYSTEM==“net”, ACTION==“add”, DRIVERS==“? *”, ATTR{address}==“54:52:00:04:19:6c”, ATTR{type}==“1”, KERNEL==“eth*”,

NAME=“eth0”

Refer to the above to modify the MAC address and NAME at most.

After the modification is completed, use the udev command to test:

udevadm test /sys/class/net/eth0/

This command can display the identification of udev in great detail. And the process of processing.

Note:

Newly added hardware, if a network card is added in setup and system-config-network-tui, but /etc/sysconfig/network-scripts/cannot find the configuration file Time.

Because these commands will put the generated configuration file into /etc/sysconfig/networking/devices/by default, just put the following two configuration files in /etc/sysconfig/network-scripts/, and then Use

system-config-network-tui to configure it.

Code Example: cp /etc/sysconfig/networking/devices/* /etc/sysconfig/network-scripts/

Then it will take effect after rebooting.

Method 3:

1. Increase the startup parameter of biosdevname=0 in grub, such as

kernel /vmlinuz-2.6.32-131.21.1.el6. I686 ro root=/dev/mapper/vg_test-lv_root rd_LVM_LV=vg_test/lv_root rd_LVM_LV=vg_test/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latar

cyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us Crashkernel=auto rhgb quiet biosdevname=0

2, delete the udev configuration file rm -f /etc/udev/rules.d/70-persistent-net.rules

3, put the network card Rename the configuration file

mv ifcfg-em1 ifcfg-eth0

4. Correct the contents of the NIC configuration file and change all em1 to eth0

You can use perl -p - i -e ‘s/em1/eth0/g’ ifcfg-eth0 or sed -i ‘s/em1/eth0/g’ ifcfg-eth0 is replaced.

5, restart the system can be

The above is the method of changing the name of the network card CentOS6.x introduced, this article introduced a total of three ways to modify the name of the network card, you can modify the UDEV file, or Then use the setup and other methods to achieve.

Copyright © Windows knowledge All Rights Reserved