Automatic detect a new network card in CentOS 6.x

Step 1 : Delete the persistent rules file

[root@ns1 ~]# cd /etc/udev/rules.d/

[root@ns1 rules.d]# ls -l
total 16
-rw-r–r– 1 root root 316 Nov 5 17:19 60-raw.rules
-rw-r–r–. 1 root root 789 Mar 1 21:05 70-persistent-cd.rules
-rw-r–r– 1 root root 422 Mar 8 22:24 70-persistent-net.rules
-rw-r–r–. 1 root root 53 Dec 8 2011 91-drm-modeset.rules

[root@ns1 rules.d]# rm -f 70-persistent-net.rules

[root@ns1 rules.d] ls -l

-rw-r–r– 1 root root 316 Nov 5 17:19 60-raw.rules
-rw-r–r– 1 root root 422 Mar 8 22:24 70-persistent-net.rules
-rw-r–r–. 1 root root 53 Dec 8 2011 91-drm-modeset.rules

Step 2 : Edit ifcfg-eth0:

[root@ns1 rules.d]# cd /etc/sysconfig/network-scripts/
[root@ns1 network-scripts]# ls -l
total 196
-rw-r–r– 1 root root 52 Mar 8 22:33 ifcfg-eth0
-rw-r–r– 1 root root 254 Apr 27 2012 ifcfg-lo
lrwxrwxrwx 1 root root 20 Mar 1 22:31 ifdown -> ../../../sbin/ifdown
-rwxr-xr-x 1 root root 627 Apr 27 2012 ifdown-bnep
-rwxr-xr-x 1 root root 5384 Sep 17 16:54 ifdown-eth
-rwxr-xr-x 1 root root 781 Apr 27 2012 ifdown-ippp
-rwxr-xr-x 1 root root 4168 Apr 27 2012 ifdown-ipv6
lrwxrwxrwx 1 root root 11 Mar 1 22:31 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x 1 root root 1481 Apr 27 2012 ifdown-post
-rwxr-xr-x 1 root root 1064 Apr 27 2012 ifdown-ppp
-rwxr-xr-x 1 root root 835 Apr 27 2012 ifdown-routes
-rwxr-xr-x 1 root root 1370 Apr 27 2012 ifdown-sit
-rwxr-xr-x 1 root root 1434 Apr 27 2012 ifdown-tunnel
lrwxrwxrwx 1 root root 18 Mar 1 22:31 ifup -> ../../../sbin/ifup
-rwxr-xr-x 1 root root 11919 Apr 27 2012 ifup-aliases
-rwxr-xr-x 1 root root 859 Apr 27 2012 ifup-bnep
-rwxr-xr-x 1 root root 10488 Apr 27 2012 ifup-eth
-rwxr-xr-x 1 root root 11971 Apr 27 2012 ifup-ippp
-rwxr-xr-x 1 root root 10401 Apr 27 2012 ifup-ipv6
lrwxrwxrwx 1 root root 9 Mar 1 22:31 ifup-isdn -> ifup-ippp
-rwxr-xr-x 1 root root 727 Apr 27 2012 ifup-plip
-rwxr-xr-x 1 root root 954 Apr 27 2012 ifup-plusb
-rwxr-xr-x 1 root root 2364 Apr 27 2012 ifup-post
-rwxr-xr-x 1 root root 4154 Apr 27 2012 ifup-ppp
-rwxr-xr-x 1 root root 1925 Apr 27 2012 ifup-routes
-rwxr-xr-x 1 root root 3499 Apr 27 2012 ifup-sit
-rwxr-xr-x 1 root root 2488 Apr 27 2012 ifup-tunnel
-rwxr-xr-x 1 root root 3770 Apr 27 2012 ifup-wireless
-rwxr-xr-x 1 root root 4623 Apr 27 2012 init.ipv6-global
-rwxr-xr-x 1 root root 1125 Apr 27 2012 net.hotplug
-rw-r–r– 1 root root 11736 Apr 27 2012 network-functions
-rw-r–r– 1 root root 29853 Apr 27 2012 network-functions-ipv6
[root@ns1 network-scripts]# vi ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
HWADDR=00:06:29:FB:XX:XX
IPADDR=9.12.20.136
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet

REMOVE the HWADDR=00:06:29:FB:XX:XX line altogether (or change it to match your new NIC’s MAC address).

Step 3 : Reboot System

[root@ns1 network-scripts]# reboot

If you change the NIC again, just repeat step #1 and # 3.