Assigning eth0 to a particular NIC
From: Ben (johndoe_at_lets-send-spam-to.verisign.com)
Date: 11/05/03
- Next message: Mike Shafer: "Linux Server, Windows XP Workstations, roaming profiles?"
- Previous message: outty: "VERY Strange IP info???"
- Next in thread: David Efflandt: "Re: Assigning eth0 to a particular NIC"
- Reply: David Efflandt: "Re: Assigning eth0 to a particular NIC"
- Maybe reply: Visvanath Ratnaweera: "Re: Assigning eth0 to a particular NIC"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 04 Nov 2003 23:34:54 -0500
More than once, I've found that RedHat assigned eth0 to the card I
intended (and wired) as eth0, and vice versa. I figured there had to be
some way to get Linux to do what I wanted, instead of what it wanted.
And there is.
However, I had so much trouble finding the answer to these questions, I
thought I'd better post the information I found. I've seen several
postings of some variation of this question, and most went unanswered.
What's below works for me . . . but that doesn't guarantee anything for you!
As best I can tell, there are two (2.5?) ways, and two references. My
apologies for any errors: corrections are welcomed.
In Redhat, it appears that you can modify the ifcfg-ethxx files using
the MACADDR and the HWADDR configuration variables. At present, this is
documented here (along with many of the other ifcfg variables):
http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/ref-guide/s1-networkscripts-interfaces.html
The MACADDR variable is apparently used to force a particular network
device, say eth0, to report the ASSIGNED MAC, rather than the burned in MAC.
The HWADDR variable is used to force the eth0 device handle to be
assigned to the network interface card (in a mult-NIC environment)
having a MAC = HWADDR.
At least, this is what I *think* happens: I haven't tested it. Some one
more skilled in reading Bash scripts than I may be able to confirm this,
by checking the relevant scripts. It appears that the following scripts
(under RH9) read the HWADDR value:
/etc/sysconfig/network-scripts/ifdown
/etc/sysconfig/network-scripts/ifup
/etc/ppp/plugins/rp-pppoe.so
/etc/pcmcia/wireless
and these read the MACADDR value:
/etc/sysconfig/network-scripts/ifdown
/etc/sysconfig/network-scripts/ifup
/etc/sysconfig/netdump
/etc/rc.d/init.d/netdump
/etc/rc.d/rc0.d/K50netdump
/etc/rc.d/rc1.d/K50netdump
/etc/rc.d/rc2.d/K50netdump
/etc/rc.d/rc3.d/K50netdump
/etc/rc.d/rc4.d/K50netdump
/etc/rc.d/rc5.d/K50netdump
/etc/rc.d/rc6.d/K50netdump
/etc/init.d/netdump
/etc/rc0.d/K50netdump
/etc/rc1.d/K50netdump
/etc/rc2.d/K50netdump
/etc/rc3.d/K50netdump
/etc/rc4.d/K50netdump
/etc/rc5.d/K50netdump
/etc/rc6.d/K50netdump
Only ONE of these variables should be used in a network device
configuration file. I assume that configuring the device handles this
way is persistent over a reboot, but also that it only works with RedHat
installations. Also in RedHat, the "neat" GUI tool can be used to set
these values, but the results some users reported were erratic and
unpredictable.
There's another way, that I HAVE tested. Assignments made this way will
NOT survive a reboot (unless you write a boot script) but the method
should work with most distros. The "ip" program can be used to either
assign a particular MAC to a particular NIC *or* to assign a particular
handle to a particular NIC.
Anyhow, to switch eth0 and eth1 name assignments (and assign eth0 to
the card of MY choice):
ip link set eth0 down
ip link set eth1 down
ip link set dev eth0 name eth9
ip link set dev eth1 name eth0
ip link set dev eth9 name eth1
ip link set eth0 up
ip link set eth1 up
As a script, this takes less than a second to run on my machine.
Documentation for the "ip" tool is found in Alex Kuznetsov's "IP Command
Reference". Here's one copy:
http://linux-ip.net/gl/ip-cref/
Ben
*******************************************************************
Additional Google keys:
How can you bind an network device handle to a particular NIC?
Binding a NIC to a MAC
How can you bind eth0 to a particular NIC?
- Next message: Mike Shafer: "Linux Server, Windows XP Workstations, roaming profiles?"
- Previous message: outty: "VERY Strange IP info???"
- Next in thread: David Efflandt: "Re: Assigning eth0 to a particular NIC"
- Reply: David Efflandt: "Re: Assigning eth0 to a particular NIC"
- Maybe reply: Visvanath Ratnaweera: "Re: Assigning eth0 to a particular NIC"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|