Sunday, May 20, 2012

Red Hat / CentOS: Swap / Change Ethernet Aliases

Q. My Ethernet aliases are randomly switched and they are bound to the wrong interface. My eth0 became eth1 and eth1 become eth0. This is causing all sort of trouble for services and firewall configurations. How do I swap back and make sure Ethernet aliases works correctly under CentOS Linux server?

A. It is possible to bind the MAC address to the network interfaces in configuration files. This will ensure that eth0,eth1 are assigned the way you want it.
Open each interfaces configuration file:
  1. /etc/sysconfig/network-scripts/ifcfg-eth0 - eth0 configuration file
  2. /etc/sysconfig/network-scripts/ifcfg-eth1 - eth1 configuration file
Open file for eth0 using vi, type:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add the following line:
HWADDR=<MAC address of the network interface> 
Here is my sample config file:
# Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:19:B1:2A:BA:B8
IPADDR=10.10.11.24
NETMASK=255.255.255.192
ONBOOT=yes
Save and close the file. Update /etc/sysconfig/network-scripts/ifcfg-eth1 file with correct HWADDR entry. Once done restart networking or just reboot the server:
# reboot

No comments:

Post a Comment