Turn
A Problem description
A small problem occurs in the test environment because the virtual machines are frequently duplicated to replicate, resulting in inconsistent behavior of the NIC configuration.
Configuration file Information:
[Email protected] network-scripts]# Catifcfg-eth0
Device= "Eth0"
Nm_controlled= "Yes"
Onboot=yes
Type=ethernet
Bootproto=none
ipaddr=192.168.1.12
Prefix=24
gateway=192.168.1.1
Defroute=yes
Ipv4_failure_fatal=no
Ipv6init=no
Name= "System eth0"
Uuid=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
Hwaddr=08:00:27:bd:a6:ed
[Email protected] network-scripts]# catifcfg-eth1
Device= "Eth1"
Nm_controlled= "Yes"
Onboot=yes
Type=ethernet
Bootproto=none
ipaddr=192.168.1.13
Prefix=24
gateway=192.168.1.1
dns1=8.8.8.8
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth1"
Uuid=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
Hwaddr=08:00:27:6e:86:10
This corresponds to the NIC name is eth0 and eth1.
But if we use the Ifconfig command to view:
[Email protected] network-scripts]# ifconfig-a
Eth2 Link encap:ethernet hwaddr08:00:27:bd:a6:ed
inet addr:192.168.1.12 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::A00:27FF:FEBD:A6ED/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:187 errors:0 dropped:0 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16356 (15.9 KiB) txbytes:6116 (5.9 KiB)
Eth3 Link encap:ethernet Hwaddr08:00:27:6e:86:10
inet addr:192.168.1.13 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::A00:27FF:FE6E:8610/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:1357 errors:0 dropped:0 overruns:0 frame:0
TX packets:1099 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:120604 (117.7 KiB) txbytes:115937 (113.2 KiB)
Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up LOOPBACK RUNNING mtu:16436 metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) txbytes:480 (480.0 b)
The NIC names here are eth2 and eth3.
Two Workaround
Modify the mapping relationship in the/etc/udev/rules.d/70-persistent-net.rules file.
--Before modification:
[Email protected] network-scripts]# Cat/etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated Bythe/lib/udev/write_net_rules
# program, run by thepersistent-net-generator.rules rules file.
#
# can modify it, as long as you keepeach rule on a single
# line, and change is only the value of Thename= key.
# PCI Device 0x8086:0x100e (e1000)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "08:00:27:d4:ab:67", attr{type}== "1", kernel== "eth*" , name= "Eth1"
# PCI Device 0x8086:0x100e (e1000)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "08:00:27:af:2b:37", attr{type}== "1", kernel== "eth*" , name= "Eth0"
# PCI Device 0x8086:0x100e (e1000)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "08:00:27:bd:a6:ed", attr{dev_id}== "0x0", Attr{type} = = "1", kernel== "eth*", name= "eth2"
# PCI Device 0x8086:0x100e (e1000)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "08:00:27:6e:86:10", attr{dev_id}== "0x0", Attr{type} = = "1", kernel== "eth*", name= "Eth3"
--After modification:
[Email protected] network-scripts]# Cat/etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated Bythe/lib/udev/write_net_rules
# program, run by thepersistent-net-generator.rules rules file.
#
# can modify it, as long as you keepeach rule on a single
# line, and change is only the value of Thename= key.
# PCI Device 0x8086:0x100e (e1000)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "08:00:27:6e:86:10", attr{type}== "1", kernel== "eth*" , name= "Eth1"
# PCI Device 0x8086:0x100e (e1000)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "08:00:27:bd:a6:ed", attr{type}== "1", kernel== "eth*" , name= "Eth0"
Note that the MAC address here should be consistent with the ifcfg-eth0.
Then reboot the NIC and Udev:
--ifdown Network card:
Ifdown eth0
Ifdown eth1
--Restart Udev
/etc/init.d/udev-post stop;
/etc/init.d/udev-post start
or use:
Service Udev-post Stop
Service Udev-post Start
NOTE: For Oracle Linux is udev-post, while Redhat is Udev
--ifup:
Ifup eth0
Ifup eth1
But in my test, none of the 2 have worked, and I restarted the entire OS before it came into effect. A little knowledge, a note of essays.
CentOS Modify NIC Name