Why NIC renames in CentOS ? (e.g. eth0 renamed to eth3)

HI
I installed new CentOS 6.4 on my system . and when i tried to set a static IP address. I noticed the NIC name has changed to something else. for example i was looking out for eth0 but there wasn’t.
Also when I add new NIC to my virtual machine on ESXi Also i have same problem .

Why this happen ? And how can be fixed???

Thanks

First open /etc/udev/rules.d/70-persistent-net.rules file and change the mac address and interface name to eth0.

Next, rename the current network interface name from eth3 to eth0 as shown.

# cd etc/sysconfig/network-scripts/
# mv ifcfg-eth3 ifcfg-eth0

Now open and edit the file ‘ifcfg-eth0’ and change change the mac address and interface name to eth0.

# vi ifcfg-eth0

After making network changes, don’t forget to restart the network to take new configuration into effect and check the ip address again with ifconfig command.

# service network restart
# ifconfig -a
1 Like

Hi

First of all find out the mac address of your interface cards

[root@devmillennium-web ~]# ifconfig -a | grep -i --color hwaddr

eth0 Link encap:Ethernet HWaddr **xx:xx:xx:xx:xx:xx**

To rename eth3 as eth0, edit a file called 70-persistent-net.rules in /etc/udev/rules.d/ directory.

# vi /etc/udev/rules.d/70-persistent-net.rules

The names of the Ethernet devices are listed in this file as follows:

# PCI device 0x14e4:0x1680 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="**n6:cd:6f:45:32:e6**", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="**eth0**"

Here change the mac address to your networkinterface mac address xx:xx:xx:xx:xx:xx and change name of the interface from eth3 to eth0.

and now reboot the server or kindly follow the steps which are said by ravi

Hi dears,
thanks for your quick answer.
can you explain more about this file , i mean 70-persistent-net.rules ?
and when this rule execute ?
Also i’ve add new NIC to my virtual machine. but there weren’t any ifcfg-ethx in /etc/sysconfig/network-script. shall i add same line as below in this (70-persistent-net.rule) file ?

@millad90s

I think this file holds the system network related configuration and it executes when system boots up…First check your new NIC is detected by using following command.

# lspci | egrep -i --color 'network|ethernet'

After detecting you can add the below rule to the file and don’t forget to change MAC and name of the Ethernet…

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?", ATTR{address}=="**n6:cd:6f:45:32:e6**", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth", NAME="**eth0**"
After making changes, **reboot** the system and edit **ifcfg-eth0** and update MAC of your new NIC card.

Hi

you can also use the below command to find out the info about your nic card

#/usr/sbin/lshw -class network

@millad90s

if u find any difficulties with this file U need to run below command after changes to ifcfg-eth* file.
#start_udev

it will create automatically with info ifcfg-eth* file after running this command

hi thanks for your answer .
but lshw is not installed by default .
in which package i can find it??

Just do a yum or apt to get the lshw package. For example do as shown below.

# yum install lshw        [on CentOS alike systems]
# apt-get install lshw    [on Debian alike systems]
1 Like