How to change the name of the network card in CentOS 6.X

There are three ways to change the name of the network card under CentOS 6.X:

  Method 1:

  Modify the UDEV file and delete the contents; use the command to redefine the name, and both names must be changed;

  Method 2:

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

  In CentOS 6, the default kudzu service for identifying hardware no longer exists, and basically all hardware management is managed by Udev.

  If you add a new piece of hardware in Centos 6, such as a network card, just restart udev.

  start_udev

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

  If the newly added network card is not recognized correctly and sometimes you want to update the name of the network card, you don't need to edit the content under /etc/sysconfig/network-scripts/. After running the above, it is not normal, and directly modify the udev-related network configuration. Can.

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

  The content is roughly 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”

  Referring to the above content, 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 and processing process of udev in great detail.

  Notice:

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

  It is because these commands will put the generated configuration files in /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 can be configured.

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

  Then it will take effect after restarting.

  Method 3:

  1. Add the boot parameter of biosdevname=0 in grub, like

  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. Rename the network card configuration file

  mv ifcfg-em1 ifcfg-eth0

  4. Modify the content of the network card configuration file and change all em1 to eth0

  This can be replaced with perl -p -i -e 's/em1/eth0/g' ifcfg-eth0 or sed -i 's/em1/eth0/g' ifcfg-eth0.

  5. Restart the system

  The above is the introduction of the method of changing the name of the network card in CentOS6.x. This article introduces three methods of changing the name of the network card. You can modify the UDEV file, or use setup and other methods to achieve it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325346092&siteId=291194637