Add or Replace a Network Adapter (NIC) on CentOS 6

Problem


Getting CentOS to recognize a new external network card.

tl;dr


You can reset your network card configuration by deleting the /etc/udev/rules.d/70-persistent-net.rules file:

rm /etc/udev/rules.d/70-persistent-net.rules

Reboot and CentOS will re-acquire network adapters attached to the system. Setup the new NIC via the network configuration wizard:

system-config-network

Solution

CentOS stores its current network adapter configuration in 70-persistent-net.rules file. While it is possible to manually edit it, it is usually simpler to just delete it and reboot the system, so it rescans network adapters attached to the system and acquires their MAC addresses.

rm /etc/udev/rules.d/70-persistent-net.rules
reboot

Add a new NIC

If you are adding a new NIC, you can configure its network settings (such as IP address or gateway) with the network configuration wizard:

system-config-network

Replacing a NIC

If you are replacing a NIC that was already configured, you do not need to re-do the entire configuration. First, you need to note which interface it was originally assigned (such as eth1). Then, open up the network rules file from above:

nano /etc/udev/rules.d/70-persistent-net.rules

Make a quick note of MAC addresses (you do not need to write them down). Whichever MAC address changes in this file after the replacement will be the new network card. After that, replace the card and delete the persistent rules file as above.

After the reboot, you need to get the MAC address of the new NIC, so open up the rules file:

nano /etc/udev/rules.d/70-persistent-net.rules

And look for the MAC address of the new NIC:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="11:22:33:aa:bb:cc", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

In this case, the MAC address is aa:bb:cc:11:22:33. Copy it or write it down. In some cases, it may assign the network card a different name, such as eth2 instead of eth1. If this happens, change it back:

NAME="eth2"
To
NAME="eth1"

Ctrl-O and Ctrl-X to save and exit the file. Then, open up the network settings profile:

nano /etc/sysconfig/network-scripts/ifcfg-eth1

And edit HWADDR line with the new MAC address:

HWADDR=aa:bb:cc:11:22:33

Save the file. This will assign the eth1 profile to the new network card by identifying it via its MAC address.

Make sure to restart your network settings:

service network restart


Was this article helpful?

mood_bad Dislike 1
mood Like 11
visibility Views: 30578