Sie sind auf Seite 1von 9

Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

Main menu
BASH Shell
Linux
CentOS
Debian / Ubuntu
Ubuntu Linux
Suse
RedHat and Friends
Slackware Linux
UNIX
AIX
Mac os x
FreeBSD
FreeBSD Jails (VPS)
Openbsd
Solaris
Troubleshooting
Nginx
Networking
MySQL
See all tutorial topics
Blog
About
Contact us
Forum
RSS/FEED

Linux FAQ / Howtos

Red Hat / CentOS: Swap / Change


Ethernet Aliases
by nixCraft on January 14, 2009 12 comments last updated at January 14, 2009

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 rewall congurations.
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


conguration les. This will ensure that eth0,eth1 are assigned the way you want it.

1 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

Open each interfaces conguration le:

1. /etc/syscong/network-scripts/ifcfg-eth0 - eth0 conguration le


2. /etc/syscong/network-scripts/ifcfg-eth1 - eth1 conguration le

Open le 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 cong le:


# 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 le. Update /etc/syscong/network-scripts/ifcfg-eth1 le with correct


HWADDR entry. Once done restart networking or just reboot the server:
# reboot

Tweet 4

You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X


Top 30 Nmap Command Examples For Sys/Network Admins
25 PHP Security Best Practices For Sys Admins
20 Linux System Monitoring Tools Every SysAdmin Should Know
20 Linux Server Hardening Security Tips
Linux: 20 Iptables Examples For New SysAdmins
Top 20 OpenSSH Server Best Security Practices
Top 20 Nginx WebServer Best Security Practices
20 Examples: Make Sure Unix / Linux Conguration Files Are Free From Syntax
Errors

2 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

15 Greatest Open Source Terminal Applications Of 2012


My 10 UNIX Command Line Mistakes
Top 10 Open Source Web-Based Project Management Software
Top 5 Email Client For Linux, Mac OS X, and Windows Users
The Novice Guide To Buying A Linux Laptop

{ 12 comments read them below or add one }

1 James January 15, 2009 at 12:14 am

Althought the HW address does address the problem in RHEL4/CentOS4 it doesnt


work right in RHEL5/CentOS5 if the box has mixed onboard and PCI Nics or 3 or
more Nics. Ive had a devil of a time with these two and the kernel on
RHEL/CentOS getting around this.

In the end my solution (that worked) was to build my own kernel from a newer
version of source than RH provides (one from Fedora to be exact). Once I did, I
stopped losing NICs and having them switch names on me.

What happens in the above scenario is if you do already have the HWADDR line it
will refuse to initialize the NIC since the HWADDR (mac) doesnt match.

Reply

2 Je Schroeder January 15, 2009 at 1:50 pm

For those who dont know, the Redhat/Fedora ifup/ifdown scripts that read the
HWADDR variable are using the ip(8) command to set the names.

You can rename eth5 to eth0 like this:


ip link set down eth5
ip link set eth5 name eth0

Afterwards youll need to add an ip and up the interface with the ip(8) or ifcong(8)
commands.

Je Schroeder
http://www.digitalprognosis.com

Reply

3 Srinivas.Y May 29, 2009 at 9:54 am

Very good tip.

Reply

4 Nicholas Redgrave June 15, 2009 at 4:18 pm

I followed the original tip with my Fedora 11 installation but it didnt work due to a
conict with udev.
I found that I also had to edit /etc/udev/rules.d/70-persistent-net.rules and swap

3 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

the NAME=eth0 and NAME=eth1 entries over in that le before it worked.

Reply

5 Ploink December 10, 2009 at 12:49 pm

In Fedora, aliases are assigned by udev.


As Nicholas did, you can simply change the order by editing /etc/udev/rules.d
/70-persistent-net.rules and reboot. You do not need to edit/change anything else.

I gured this out when I replaced a network card. I started with eth0 and eth1,
then replaced eth1 with a dierent card and ended up with eth0 and eth2. I deleted
the old card from the rules le and changed the new from eth2 to eth1.

I do not recommend to specify the HW address in the ifcfg* les.

Reply

6 gndudeus October 9, 2010 at 4:09 pm

I encountered this problem today and was able to resolve it using the following
steps;

OS: CentOS release 5.2

1) First check hwaddress of your eth0 and eth1 (and any others you may have)-do
this by simply using ifcong command and note down the hwaddress.
2) Next enter into your interface cong and insert the hwaddr like this vi
/etc/syscong/network-scripts/ifcfg-eth0. HWADD=mac_address
3) Repeat step 2 for your other network cards.
4) goto /etc/syscong/hwconf and under NETWORK, note your driver, e.g device:
eth1 driver: r8169. Check this for all your network cards.
5) Now nally goto /etc/modprobe.conf
6) Match your ethernet cards with their correct drivers, e.g. alias eth0 skge
7) Save and reboot.

The above worked perfectly for me. I hope it does help you too.

Reply

7 Darshak Thakore November 10, 2010 at 4:35 pm

Thanks for the tip gndudeus.

Your tip worked for me with CentOS 5.5

With systems that have switched to udev (Fedora, Ubuntu), editing the
70-persistent-net.rules work but for older systems like CentOS 5, this tip is the only
way to safely swap eth devices.

Reply

4 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

8 Luis Talora January 5, 2011 at 1:32 pm

Excelent tip! Just what I was looking for. Thanks!

Reply

9 anas alaayah June 30, 2011 at 1:00 pm

ive followed the steps but when i reboot the system the original mac address back
is there any other solution
thanks all

Reply

10 Eric Zhu October 22, 2011 at 3:36 pm

CentOS 6.0 implement a new system called NetworkManger to manage network . I


have to stop this service rst to rename network interface with this resolution.

Reply

11 John McLean February 21, 2012 at 11:36 am

On a cloned (VM) Centos 6.2 machine you will need to delete the below le:
/etc/udev/rules.d/70-persistent-net.rules

also remove mac info from:

/etc/sysconfig/network-scripts/ifcfg-eth0

Sourced from here.

Edited by admin. Reason formatting.

Reply

12 mrbyte May 24, 2012 at 2:47 pm

the step described by gndudeus worked perfectly for me with Centos 5.2 and 3
network interface, great.

Reply

Leave a Comment

Name *

E-mail *

Website

5 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

You can use these HTML tags and attributes for your code and commands: <strong>
<em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Notify me of followup comments via e-mail

Submit

Tagged as: /etc/syscong/network-scripts/ifcfg-eth0, /etc/syscong/network-scripts/ifcfg-eth1, aliases,


rewall congurations, gigabit ethernet controller, intel, interface, Linux, linux server, mac address, network
interfaces, network scripts, Networking, reboot command

Previous Faq: Red Hat / CentOS: Check / List Running Services

Next Faq: FreeBSD: Restart Apache Server

GET FREE TIPS


Make the most of Linux Sysadmin work!

Enter your email Sign Up

Youtube | Twitter | Google +

6 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

ERROR
The requested
URL could not
be retrieved

The following error was encountered while


trying to retrieve the URL:
http://www.facebook.com/plugins
/likebox.php?

Related Faqs

Linux command to remove virtual interfaces or network


aliases

Linux Display Ethernet Bridge Name and Information

7 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

Linux Static IP Address Conguration

SUSE Linux Restart / Stop / Start Network Service

Setting Up a CentOS / Red Hat Linux DHCP Client

Ubuntu Static IP

CentOS / Redhat: KVM Bridged Network Conguration

Red Hat / CentOS Setup Routing Metric For Network


Device

8 of 9 03/07/2013 12:55 PM
Red Hat / CentOS: Swap / Change Ethernet Aliases http://www.cyberciti.biz/faq/rhel-fedora-centos-howto-sw...

Linux MTU Change Size

Ubuntu Linux Congure Gateway / Default Routing IP


Address

2006-2013 nixCraft. All rights reserved. Cannot be reproduced without written


permission.
Privacy Policy | Terms of Service | Questions or Comments | Sitemap

9 of 9 03/07/2013 12:55 PM

Das könnte Ihnen auch gefallen