Changing the ethX to Ethernet Device Mapping in EL6 and Fedora 12 to 14: Difference between revisions
(Created page with '{{howto_header}} When you have two or more ethernet devices in one machine, the Fedora install may not install them in the order you want. This document will show you how to cha…') |
No edit summary |
||
Line 28: | Line 28: | ||
* <span class="code">eth0</span> | * <span class="code">eth0</span> | ||
** MAC: <span class="code"> | ** MAC: <span class="code">90:E6:BA:71:82:D8</span> | ||
* <span class="code">eth1</span> | * <span class="code">eth1</span> | ||
** MAC: <span class="code">00: | ** MAC: <span class="code">00:21:91:19:96:5A</span> | ||
* <span class="code">eth2</span> | * <span class="code">eth2</span> | ||
** MAC: <span class="code">00: | ** MAC: <span class="code">00:0E:0C:59:45:78</span> | ||
== Initial Mapping == | == Initial Mapping == | ||
Line 39: | Line 39: | ||
* <span class="code">eth0</span> | * <span class="code">eth0</span> | ||
** MAC: <span class="code">00: | ** MAC: <span class="code">00:21:91:19:96:5A</span> | ||
* <span class="code">eth1</span> | * <span class="code">eth1</span> | ||
** MAC: <span class="code"> | ** MAC: <span class="code">90:E6:BA:71:82:D8</span> | ||
* <span class="code">eth2</span> | * <span class="code">eth2</span> | ||
** MAC: <span class="code">00: | ** MAC: <span class="code">00:0E:0C:59:45:78</span> | ||
== The Problem == | == The Problem == | ||
In the above example, <span class="code"> | In the above example, <span class="code">eth2</span> is where we want it, so we leave it alone. The problem is that <span class="code">eth0</span> and <span class="code">eth2</span> are reversed. | ||
== The Fix == | == The Fix == | ||
First, stop | First, stop <span class="code">network</span>. This is important because if you change the MAC address to <span class="code">ethX</span> mapping while the network is still up, the <span class="code">initd</span> script will fail to bring down the network devices and you will need to reboot for the changes to take effect. | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 57: | Line 57: | ||
</source> | </source> | ||
We'll need to work in two directories; | |||
* <span class="code">/etc/sysconfig/network-scripts/</span> | |||
** Where the interface configuration files exist. | |||
* <span class="code">/etc/udev/rules.d/</span> | |||
** Where the <span class="code">udev</span> configuration files exist. | |||
=== Interface Configuration === | |||
Go to <span class="code">/etc/sysconfig/network-scripts/</span> and then use <span class="code">cat</span> to see the contents of the <span class="code">ifcfg-eth*</span> network configuration files: | |||
<source lang="bash"> | <source lang="bash"> | ||
Line 68: | Line 76: | ||
This will produce output something like this: | This will produce output something like this: | ||
<source lang="bash"> | |||
cd /etc/sysconfig/network-scripts | |||
cat ifcfg-eth* | |||
</source> | |||
<source lang="text"> | <source lang="text"> | ||
# D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter | |||
HWADDR=00:21:91:19:96:5A | |||
DEVICE=eth0 | DEVICE=eth0 | ||
BOOTPROTO= | BOOTPROTO=static | ||
ONBOOT=yes | ONBOOT=yes | ||
TYPE=Ethernet | |||
IPADDR=192.168.1.71 | |||
NETMASK=255.255.255.0 | |||
GATEWAY=192.168.1.1 | |||
DNS1=192.139.81.117 | |||
DNS2=192.139.81.1 | |||
DEFROUTE=yes | |||
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller | # Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller | ||
HWADDR=90:E6:BA:71:82:D8 | |||
DEVICE=eth1 | DEVICE=eth1 | ||
BOOTPROTO= | BOOTPROTO=static | ||
ONBOOT=yes | ONBOOT=yes | ||
TYPE=Ethernet | |||
IPADDR=10.0.0.71 | |||
NETMASK=255.255.255.0 | |||
# Intel Corporation 82540EM Gigabit Ethernet Controller | |||
HWADDR=00:0E:0C:59:45:78 | |||
DEVICE=eth2 | DEVICE=eth2 | ||
BOOTPROTO= | BOOTPROTO=static | ||
ONBOOT=yes | ONBOOT=yes | ||
TYPE=Ethernet | |||
IPADDR=10.0.1.71 | |||
NETMASK=255.255.255.0 | |||
</source> | </source> | ||
The important lines are the <span class="code">HWADDR=...</span> lines. | The important lines are the <span class="code">DEVICE=...</span> and <span class="code">HWADDR=...</span> lines. The rest of the lines will very likely differ from the output above, and most will likely be set to <span class="code">BOOTPROTO=static</span>. One or more may also be set to <span class="code">ONBOOT=yes</span>. It is outside the scope of this tutorial to cover the various settings | ||
With networking stopped, all we need to do is change the <span class="code">HWADDR=...</span> lines in <span class="code">ifcfg-eth0</span> to have the MAC address from <span class="code">ifcfg-eth2</span> and vice-versa. | With networking stopped, all we need to do is change the <span class="code">HWADDR=...</span> lines in <span class="code">ifcfg-eth0</span> to have the MAC address from <span class="code">ifcfg-eth2</span> and vice-versa. For an exhaustive list of available options, please [http://docs.fedoraproject.org/en-US/Fedora/12/html/Deployment_Guide/s1-networkscripts-interfaces.html see the Fedora documentation]. | ||
To rearrange the mappings, simply change around the <span class="code">HWADDR=...</span> values in the <span class="code">ifcfg-eth*</span> files so that the desired MAC address and <span class="code">DEVICE=...</span> are in the same file. Personally, I like to move around the comment at the top that names the NICs, also. Here is the updated files: | |||
<source lang="bash"> | <source lang="bash"> | ||
cat ifcfg-eth* | |||
</source> | </source> | ||
<source lang="text"> | <source lang="text"> | ||
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller | |||
HWADDR=90:E6:BA:71:82:D8 | |||
DEVICE=eth0 | |||
BOOTPROTO=static | |||
ONBOOT=yes | |||
TYPE=Ethernet | |||
IPADDR=192.168.1.71 | |||
NETMASK=255.255.255.0 | |||
GATEWAY=192.168.1.1 | |||
DNS1=192.139.81.117 | |||
DNS2=192.139.81.1 | |||
DEFROUTE=yes | |||
# D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter | # D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter | ||
DEVICE= | HWADDR=00:21:91:19:96:5A | ||
BOOTPROTO= | DEVICE=eth1 | ||
BOOTPROTO=static | |||
ONBOOT=yes | |||
TYPE=Ethernet | |||
IPADDR=10.0.0.71 | |||
NETMASK=255.255.255.0 | |||
# Intel Corporation 82540EM Gigabit Ethernet Controller | |||
HWADDR=00:0E:0C:59:45:78 | |||
DEVICE=eth2 | |||
BOOTPROTO=static | |||
ONBOOT=yes | ONBOOT=yes | ||
TYPE=Ethernet | |||
IPADDR=10.0.1.71 | |||
NETMASK=255.255.255.0 | |||
</source> | </source> | ||
=== 'udev' Configuration === | |||
The user-space device manager, [http://en.wikipedia.org/wiki/Udev udev], maintains a list of configuration files that help ensure that hardware to <span class="code">/dev</span> (software) mappings stay consistent, even when hardware is hot swapped or moved between physical connections. For networking hardware, this mapping is recorded in the <span class="code">70-persistent-net.rules</span>. | |||
Here, all that needs to be done is for the <span class="code">NAME="..."</span> entry to be changed to reflect what you want. Note that the entries do not need to be in any particular order. | |||
<source lang="bash"> | <source lang="bash"> | ||
cd /etc/udev/rules.d/ | |||
cat ifcfg-eth* | |||
</source> | </source> | ||
<source lang="text"> | <source lang="text"> | ||
# | # This file was automatically generated by the /lib/udev/write_net_rules | ||
# program, run by the persistent-net-generator.rules rules file. | |||
# | |||
# You can modify it, as long as you keep each rule on a single | |||
# line, and change only the value of the NAME= key. | |||
# PCI device 0x10ec:0x8168 (r8169) (custom name provided by external tool) | |||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="90:e6:ba:71:82:d8", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" | |||
# PCI device 0x1186:0x4b00 (sky2) (custom name provided by external tool) | |||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:21:91:19:96:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" | |||
# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool) | |||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:0c:59:45:78", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" | |||
</source> | |||
Make the changes and save the file. Continuing with this example, the file should now look like this: | |||
<source lang="bash"> | |||
cd /etc/udev/rules.d/ | |||
cat ifcfg-eth* | |||
</source> | </source> | ||
<source lang="text"> | |||
# This file was automatically generated by the /lib/udev/write_net_rules | |||
# program, run by the persistent-net-generator.rules rules file. | |||
# | |||
# You can modify it, as long as you keep each rule on a single | |||
# line, and change only the value of the NAME= key. | |||
# PCI device 0x10ec:0x8168 (r8169) (custom name provided by external tool) | |||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="90:e6:ba:71:82:d8", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" | |||
# PCI device 0x1186:0x4b00 (sky2) (custom name provided by external tool) | |||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:21:91:19:96:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" | |||
# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool) | |||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:0c:59:45:78", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" | |||
</source> | </source> | ||
=== Making the Changes Take Effect === | |||
First, you need to reload <span class="code">udev</span> so that it updates the mapping in memory. This is done using the <span class="code">start_udev</span> program: | |||
<source lang="bash"> | <source lang="bash"> | ||
start_udev | |||
</source> | </source> | ||
<source lang="text"> | <source lang="text"> | ||
Starting udev: [ OK ] | |||
</source> | |||
With <span class="code">udev</span> updated, the last step is to restart the <span class="code">network</span> daemon: | |||
<source lang="bash"> | |||
/etc/init.d/network start | |||
</source> | |||
<source lang="text"> | |||
Bringing up loopback interface: [ OK ] | |||
Bringing up interface eth0: [ OK ] | |||
Bringing up interface eth1: [ OK ] | |||
Bringing up interface eth2: [ OK ] | |||
</source> | </source> | ||
Done! use <span class="code">ifconfig</span> to verify that the network cards are properly assigned to the specified <span class="code">ethX</span> names. | |||
== Caveat! == | == Caveat! == |
Revision as of 03:51, 2 July 2010
AN!Wiki :: How To :: Changing the ethX to Ethernet Device Mapping in EL6 and Fedora 12 to 14 |
When you have two or more ethernet devices in one machine, the Fedora install may not install them in the order you want. This document will show you how to change the ethX to ethernet device mapping.
For the Impatient
Assuming that NetworkManager is already removed.
/etc/init.d/network stop
vim /etc/sysconfig/network-scripts/ifcfg-eth*
# Make changes as needed
vim /etc/udev/rules.d/70-persistent-net.rules
# Make changes as needed
start_udev
/etc/init.d/network start
Thanks for fenris02 and mutk
Example
I find it easier to follow instructions when I have an example to follow, so let me provide one here:
Desired Mapping
Let's assume that you want this:
- eth0
- MAC: 90:E6:BA:71:82:D8
- eth1
- MAC: 00:21:91:19:96:5A
- eth2
- MAC: 00:0E:0C:59:45:78
Initial Mapping
Now lets assume you got this:
- eth0
- MAC: 00:21:91:19:96:5A
- eth1
- MAC: 90:E6:BA:71:82:D8
- eth2
- MAC: 00:0E:0C:59:45:78
The Problem
In the above example, eth2 is where we want it, so we leave it alone. The problem is that eth0 and eth2 are reversed.
The Fix
First, stop network. This is important because if you change the MAC address to ethX mapping while the network is still up, the initd script will fail to bring down the network devices and you will need to reboot for the changes to take effect.
/etc/init.d/network stop
We'll need to work in two directories;
- /etc/sysconfig/network-scripts/
- Where the interface configuration files exist.
- /etc/udev/rules.d/
- Where the udev configuration files exist.
Interface Configuration
Go to /etc/sysconfig/network-scripts/ and then use cat to see the contents of the ifcfg-eth* network configuration files:
cd /etc/sysconfig/network-scripts/
cat ifcfg-eth0
cat ifcfg-eth1
cat ifcfg-eth2
This will produce output something like this:
cd /etc/sysconfig/network-scripts
cat ifcfg-eth*
# D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter
HWADDR=00:21:91:19:96:5A
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=192.168.1.71
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.139.81.117
DNS2=192.139.81.1
DEFROUTE=yes
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
HWADDR=90:E6:BA:71:82:D8
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.0.0.71
NETMASK=255.255.255.0
# Intel Corporation 82540EM Gigabit Ethernet Controller
HWADDR=00:0E:0C:59:45:78
DEVICE=eth2
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.0.1.71
NETMASK=255.255.255.0
The important lines are the DEVICE=... and HWADDR=... lines. The rest of the lines will very likely differ from the output above, and most will likely be set to BOOTPROTO=static. One or more may also be set to ONBOOT=yes. It is outside the scope of this tutorial to cover the various settings
With networking stopped, all we need to do is change the HWADDR=... lines in ifcfg-eth0 to have the MAC address from ifcfg-eth2 and vice-versa. For an exhaustive list of available options, please see the Fedora documentation.
To rearrange the mappings, simply change around the HWADDR=... values in the ifcfg-eth* files so that the desired MAC address and DEVICE=... are in the same file. Personally, I like to move around the comment at the top that names the NICs, also. Here is the updated files:
cat ifcfg-eth*
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
HWADDR=90:E6:BA:71:82:D8
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=192.168.1.71
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.139.81.117
DNS2=192.139.81.1
DEFROUTE=yes
# D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter
HWADDR=00:21:91:19:96:5A
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.0.0.71
NETMASK=255.255.255.0
# Intel Corporation 82540EM Gigabit Ethernet Controller
HWADDR=00:0E:0C:59:45:78
DEVICE=eth2
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.0.1.71
NETMASK=255.255.255.0
'udev' Configuration
The user-space device manager, udev, maintains a list of configuration files that help ensure that hardware to /dev (software) mappings stay consistent, even when hardware is hot swapped or moved between physical connections. For networking hardware, this mapping is recorded in the 70-persistent-net.rules.
Here, all that needs to be done is for the NAME="..." entry to be changed to reflect what you want. Note that the entries do not need to be in any particular order.
cd /etc/udev/rules.d/
cat ifcfg-eth*
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x10ec:0x8168 (r8169) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="90:e6:ba:71:82:d8", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x1186:0x4b00 (sky2) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:21:91:19:96:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:0c:59:45:78", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
Make the changes and save the file. Continuing with this example, the file should now look like this:
cd /etc/udev/rules.d/
cat ifcfg-eth*
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x10ec:0x8168 (r8169) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="90:e6:ba:71:82:d8", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1186:0x4b00 (sky2) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:21:91:19:96:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:0c:59:45:78", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
Making the Changes Take Effect
First, you need to reload udev so that it updates the mapping in memory. This is done using the start_udev program:
start_udev
Starting udev: [ OK ]
With udev updated, the last step is to restart the network daemon:
/etc/init.d/network start
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]
Bringing up interface eth2: [ OK ]
Done! use ifconfig to verify that the network cards are properly assigned to the specified ethX names.
Caveat!
NOTE: If you are using a vlan, the device facing the vlan can not have the HWADDR=... value set! Set the others and leave this commented out. Otherwise, because of how the vlan loads, the OS will not see the physical device and will fail to bring up the interface at all.
Any questions, feedback, advice, complaints or meanderings are welcome. | |||
Alteeve's Niche! | Enterprise Support: Alteeve Support |
Community Support | |
© Alteeve's Niche! Inc. 1997-2024 | Anvil! "Intelligent Availability®" Platform | ||
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions. |