Changing Ethernet Device Names in EL7 and Fedora 15+: Difference between revisions

From Alteeve Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{howto_header}}
{{howto_header}}
{{warning|1=The topic includes [[RHEL]] v7, which has not be released. It may well prove that the methods described here will not work with the final release of Red Hat Enterprise Linux version 7. Best guesses on how things will work inform this tutorial and may prove wrong.}}


Traditionally in [[Linux]], network devices were given the name <span class="code">ethX</span>, where <span class="code">X</span> was a digit starting at <span class="code">0</span> and incremented up. The drawback to this was that there was no consistent or deterministic way to know which physical network ports would get which <span class="code">ethX</span> name. To address this, Fedora 15 (and other distributions) began using a new tool called <span class="code">[[biosdevname]]</span> which names each network device based on where it is found in the system. The result is that, ''usually'', you can predict the name of a given physical interface.
Traditionally in [[Linux]], network devices were given the name <span class="code">ethX</span>, where <span class="code">X</span> was a digit starting at <span class="code">0</span> and incremented up. The drawback to this was that there was no consistent or deterministic way to know which physical network ports would get which <span class="code">ethX</span> name. To address this, Fedora 15 (and other distributions) began using a new tool called <span class="code">[[biosdevname]]</span> which names each network device based on where it is found in the system. The result is that, ''usually'', you can predict the name of a given physical interface.
Line 12: Line 10:


This tutorial assumes you have six network cards;
This tutorial assumes you have six network cards;
* <span class="code">p1p1</span>
* <span class="code">eth0</span>
* <span class="code">p1p2</span>
* <span class="code">eth1</span>
* <span class="code">p2p1</span>
* <span class="code">eth2</span>
* <span class="code">p2p2</span>
* <span class="code">eth3</span>
* <span class="code">p4p1</span>
* <span class="code">eth4</span>
* <span class="code">p4p2</span>
* <span class="code">eth5</span>


We will rename these to;
We will rename these to;


* <span class="code">bcn1</span>
* <span class="code">bcn_link1</span>
* <span class="code">bcn2</span>
* <span class="code">bcn_link2</span>
* <span class="code">sn1</span>
* <span class="code">sn_link1</span>
* <span class="code">sn2</span>
* <span class="code">sn_link2</span>
* <span class="code">ifn1</span>
* <span class="code">ifn_link1</span>
* <span class="code">ifn2</span>
* <span class="code">ifn_link2</span>


The reason for these names is that, in my case, I wish to give names to interfaces that reflect their purpose in my servers. Specifically, I need three bonded networks; [[BCN]], [[SN]] and [[IFN]] in my [[AN!Cluster Tutorial 3|clusters]]. You can just as easily use <span class="code">eth0</span> to <span class="code">eth5</span> or any other name that suits your purposes.
The reason for these names is that, in my case, I wish to give names to interfaces that reflect their purpose in my servers. Specifically, I need three bonded networks; [[BCN]], [[SN]] and [[IFN]] in my [[AN!Cluster Tutorial 3|clusters]]. You can just as easily use <span class="code">eth0</span> to <span class="code">eth5</span> or any other name that suits your purposes.
Line 45: Line 43:
= Identify Interfaces =
= Identify Interfaces =


To start, you want to see what the names your system has already given to the network interfaces. This can be done with <span class="code">iptables -a</span>, which reports all network cards, regardless if they are started or not.
To start, you want to see what the names your system has already given to the network interfaces. This can be done with <span class="code">ip addr</span>, which reports all network cards, regardless if they are started or not.
 
<source lang="bash">
ifconfig -a
</source>
<source lang="text">
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
p1p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::21b:21ff:fe72:99ab  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:72:99:ab  txqueuelen 1000  (Ethernet)
        RX packets 2103  bytes 198150 (193.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf7ec0000-f7ee0000 
 
p1p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2e0:81ff:fecb:80  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:81:cb:00:80  txqueuelen 1000  (Ethernet)
        RX packets 2102  bytes 197804 (193.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  memory 0xf7b00000-f7b20000 
 
p2p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.255.0.151  netmask 255.255.0.0  broadcast 10.255.255.255
        inet6 fe80::21b:21ff:febf:6c87  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:bf:6c:87  txqueuelen 1000  (Ethernet)
        RX packets 2179  bytes 208690 (203.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 76  bytes 14361 (14.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  memory 0xf7dc0000-f7de0000 
 
p2p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2e0:81ff:fecb:81  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:81:cb:00:81  txqueuelen 1000  (Ethernet)
        RX packets 2102  bytes 197804 (193.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18  memory 0xf7a00000-f7a20000 
 
p4p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::21b:21ff:febf:7002  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:bf:70:02  txqueuelen 1000  (Ethernet)
        RX packets 2103  bytes 198150 (193.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xf7cc0000-f7ce0000 


p4p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
<syntaxhighlight lang="bash">
        inet6 fe80::21b:21ff:fe72:9692  prefixlen 64 scopeid 0x20<link>
ip addr
        ether 00:1b:21:72:96:92  txqueuelen 1000 (Ethernet)
</syntaxhighlight>
        RX packets 2101  bytes 197740 (193.1 KiB)
<syntaxhighlight lang="text">
        RX errors 0  dropped 0  overruns 0  frame 0
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        TX packets 3  bytes 270 (270.0 B)
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    inet 127.0.0.1/8 scope host lo
        device interrupt 16  memory 0xf79c0000-f79e0000 
      valid_lft forever preferred_lft forever
</source>
    inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.254/24 brd 192.168.122.255 scope global dynamic eth0
      valid_lft 3445sec preferred_lft 3445sec
    inet6 fe80::5054:ff:febd:1307/64 scope link
      valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:39:18:09 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:c9:83:aa brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:fe:eb:0f brd ff:ff:ff:ff:ff:ff
</syntaxhighlight>


So I see the six network cards named <span class="code">pXpY</span>. You might have <span class="code">emX</span>, <span class="code">ethX</span> or similar. The current names themselves doesn't matter too much, so long as you see all of your cards.  
So I see the six network cards named <span class="code">ethX</span>. You might have <span class="code">emX</span>, <span class="code">pXpY</span> or so on. The current names themselves doesn't matter too much, so long as you see all of your interfaces.  


== Mapping Current Names to Desired Names ==
== Mapping Current Names to Desired Names ==
Line 123: Line 80:
* Sorting out the [http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming Consistent Network Device Names] to physical interfaces. I find this to be an imperfect art.
* Sorting out the [http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming Consistent Network Device Names] to physical interfaces. I find this to be an imperfect art.
* Use <span class="code">ethtool -p <dev></span> and watch to see which port's light blinks. This requires driver support and a clear view of the network cards.
* Use <span class="code">ethtool -p <dev></span> and watch to see which port's light blinks. This requires driver support and a clear view of the network cards.
* Watch the system log and unplug each cable to see what device is reported as having disconnected. This isn't the most elegant, but it is the method I prefer and which we will use here.
* Unplug a network cable and then run <span class="code">ip addr</span> and see which interface changed from <span class="code"><BROADCAST,MULTICAST,UP,LOWER_UP></span> to <span class="code"><NO-CARRIER,BROADCAST,MULTICAST,UP></span> and note the device name.
* Watch the system log and unplug each cable to see what device is reported as having disconnected. This is the method we'll use.


Before we proceed, let me give some background on what is happening behind the scenes.
Before we proceed, let me give some background on what is happening behind the scenes.


In my case, I have three networks, each bonded across two interfaces, each link going to a separate switch (<span class="code">switch 1</span> and <span class="code">switch 2</span>). I want to name these devices after their purpose;
In my case, I have three networks, each bonded across two interfaces, each link going to a separate switch (<span class="code">switch 1</span> and <span class="code">switch 2</span>). I want to name these devices after their purpose;
* [[BCN|Back-Channel Network]]; <span class="code">bcn1</span> and <span class="code">bcn2</span>
* [[BCN|Back-Channel Network]]; <span class="code">bcn_link1</span> and <span class="code">bcn_link2</span>
* [[SN|Storage Network]]; <span class="code">sn1</span> and <span class="code">sn2</span>
* [[SN|Storage Network]]; <span class="code">sn_link1</span> and <span class="code">sn_link2</span>
* [[IFN|Internet-Facing Network]]; <span class="code">ifn1</span> and <span class="code">ifn2</span>
* [[IFN|Internet-Facing Network]]; <span class="code">ifn_link1</span> and <span class="code">ifn_link2</span>


Before I started, I figured out which physical port I wanted to use for a given network and link. You will obviously have your own plan and it will likely differ from the one shown here. This is no problem at all. So long as you know what name you want to give each physical interface, you are ready to go.
Before I started, I figured out which physical port I wanted to use for a given network and link. You will obviously have your own plan and it will likely differ from the one shown here. This is no problem at all. So long as you know what name you want to give each physical interface, you are ready to go.


I start by creating a list of interfaces names I want. Then, as I pull each cable, I mark the current name beside the desired name.
== Initial List ==


== Initial List ==
Start by creating a list of interfaces names you want. Then, as you pull each cable, mark the current name of the connection that went down beside the desired name.


So here is the list of desired names that I start with;
So here is the list of desired names that I start with;
Line 143: Line 101:
!Current Name!!Desired Name
!Current Name!!Desired Name
|-
|-
| ||bcn1
|
|bcn_link1
|-
|-
| ||bcn2
|
|bcn_link2
|-
|-
| ||sn1
|
|sn_link1
|-
|-
| ||sn2
|
|sn_link2
|-
|-
| ||ifn1
|
|ifn_link1
|-
|-
| ||ifn2
|
|ifn_link2
|}
|}


Now I will start watching the system log. In a terminal, run;
Before we begin, we'll want to watch messages being printed to the system log. We can do this using <span class="code">journalctl</span>'s 'follow' switch, <span class="code">-f</span> switch, like so;
 
<syntaxhighlight lang="bash">
journalctl -f -n 0
</syntaxhighlight>
<syntaxhighlight lang="text">
-- Logs begin at Wed 2015-07-22 02:03:47 GMT. --
</syntaxhighlight>


<source lang="bash">
The '<span class="code">-n 0</span>' tells it to show no previous lines in the log.
tail -f -n 0 /var/log/messages
</source>


This will watch for changes in the system log and print them to the screen. Let's start by pulling the first cable. In my case, I am pulling the network cable which I want to be named <span class="code">bcn1</span> (the "back-channel network link to switch number 1).
Now, start by pulling the first cable and you should see a message indicating the current name of the interface having gone down. In my case, I am pulling the network cable which I want to be named <span class="code">bcn_link1</span> (the "back-channel network link to switch number 1).


A moment or so after unplugging the cable, you will see something like this;
Unplug the first cable and you should see log entries like this:


<source lang="text">
<syntaxhighlight lang="text">
Oct  7 17:30:51 an-c04n02 kernel: [ 9368.605187] e1000e: p2p2 NIC Link is Down
Jul 22 03:38:24 an-a03n01.alteeve.ca nm-dispatcher[14204]: Dispatching action 'dhcp4-change' for eth0
Oct  7 17:30:51 an-c04n02 NetworkManager[547]: <info> (p2p2): carrier now OFF (device state 30)
Jul 22 03:46:12 an-a03n01.alteeve.ca NetworkManager[816]: <info>  (eth4): link disconnected
Oct  7 17:30:51 an-c04n02 NetworkManager[547]: <info> (p2p2): device state change: disconnected -> unavailable (reason 'carrier-changed') [30 20 40]
</syntaxhighlight>
Oct  7 17:30:51 an-c04n02 NetworkManager[547]: <info> (p2p2): deactivating device (reason 'carrier-changed') [40]
Oct 7 17:30:51 an-c04n02 NetworkManager[547]: <info> Policy set 'Boot Disk' (p2p1) as default for IPv4 routing and DNS.
Oct  7 17:30:51 an-c04n02 NetworkManager[547]: <info> Policy set 'Boot Disk' (p2p1) as default for IPv4 routing and DNS.
</source>


The line <span class="code"><info> (p2p2): carrier now OFF</span> tells me that the device with the current name <span class="code">p2p2</span> was just unplugged. Now I know that the I want to change the device <span class="code">p2p1</span> to be <span class="code">bcn1</span>. So I plug it back in and then I update my list;
Plug the cable back in and you should see an entry like this;
 
<syntaxhighlight lang="text">
Jul 22 03:46:17 an-a03n01.alteeve.ca NetworkManager[816]: <info> (eth4): link connected
</syntaxhighlight>
 
So in my case, I see that the current name is <span class="code">eth4</span>. So I will record this next to '<span class="code">bcn_link1</span>' in my table;


{|class="wikitable sortable"
{|class="wikitable sortable"
!Current Name!!Desired Name
!Current Name!!Desired Name
|-
|-
|p2p2||bcn1
|eth4
|bcn_link1
|-
|-
| ||bcn2
|
|bcn_link2
|-
|-
| ||sn1
|
|sn_link1
|-
|-
| ||sn2
|
|sn_link2
|-
|-
| ||ifn1
|
|ifn_link1
|-
|-
| ||ifn2
|
|ifn_link2
|}
|}


Now I unplug the device I want to be called <span class="code">bcn2</span>;
Now I unplug the device I want to be called <span class="code">bcn_link2</span>;
 
<syntaxhighlight lang="text">
Jul 22 04:00:53 an-a03n01.alteeve.ca NetworkManager[816]: <info>  (eth5): link disconnected
</syntaxhighlight>
 
Plug it back in;


<source lang="text">
<syntaxhighlight lang="text">
Oct  7 17:43:14 an-c04n02 kernel: [10111.686371] e1000e: p2p1 NIC Link is Down
Jul 22 04:01:01 an-a03n01.alteeve.ca NetworkManager[816]: <info> (eth5): link connected
Oct  7 17:43:14 an-c04n02 NetworkManager[547]: <info> (p2p1): carrier now OFF (device state 100, deferring action for 4 seconds)
</syntaxhighlight>
</source>


Here I see that the device I want to rename is <span class="code">p2p1</span>, so I plug the cable back in and again update my list;
So here I see that the interface currently named <span class="code">eth5</span> is the one I want to rename to '<span class="code">bcn_link2</span>', so I add it to the table.


{|class="wikitable sortable"
{|class="wikitable sortable"
!Current Name!!Desired Name
!Current Name!!Desired Name
|-
|-
|p2p2||bcn1
|eth4
|bcn_link1
|-
|-
|p2p1||bcn2
|eth5
|bcn_link2
|-
|-
| ||sn1
|
|sn_link1
|-
|-
| ||sn2
|
|sn_link2
|-
|-
| ||ifn1
|
|ifn_link1
|-
|-
| ||ifn2
|
|ifn_link2
|}
|}


I repeat this for the next four cables. Once done, I have;
Repeat this for the next four interfaces. Once done, you should have something like;
 


{|class="wikitable sortable"
{|class="wikitable sortable"
!Current Name!!Desired Name
!Current Name!!Desired Name
|-
|-
|p2p2||bcn1
|eth4
|bcn_link1
|-
|-
|p2p1||bcn2
|eth5
|bcn_link2
|-
|-
|p1p2||sn1
|eth2
|sn_link1
|-
|-
|p4p1||sn2
|eth3
|sn_link2
|-
|-
|p1p1||ifn1
|eth0
|ifn_link1
|-
|-
|p4p2||ifn2
|eth1
|ifn_link2
|}
|}


Line 242: Line 237:
The way we're going to create the actual [[MAC]] address to device name mapping will be via <span class="code">[[udev]]</span> rules. Specifically, we're going to edit or create the <span class="code">/etc/udev/rules.d/70-persistent-net.rules</span>. As of Fedora 17, this file is no longer created, so you will need to create it yourself. I've written a little script to do this;
The way we're going to create the actual [[MAC]] address to device name mapping will be via <span class="code">[[udev]]</span> rules. Specifically, we're going to edit or create the <span class="code">/etc/udev/rules.d/70-persistent-net.rules</span>. As of Fedora 17, this file is no longer created, so you will need to create it yourself. I've written a little script to do this;


{{note|1=If this script produces no output, run <span class="code">ifconfig -a</span>. If the output looks like: [<span class="code">p1p1     Link encap:Ethernet  HWaddr 00:1b:21:72:99:ab</span>], then your system is using the old-style output and this script won't work.}}
{{note|1=If this script produces no output, run <span class="code">ip addr</span>. If the output looks like: [<span class="code">eth0     Link encap:Ethernet  HWaddr 00:1b:21:72:99:ab</span>], then your system is using the old-style output and this script won't work.}}


<source lang="perl">
<syntaxhighlight lang="perl">
#!/usr/bin/perl
#!/usr/bin/perl


Line 252: Line 247:
my $conf = {};
my $conf = {};


# Read the 'ifconfig -a'
# Read the 'ip addr'
my $dev = "";
my $device      = "";
my $mac = "";
my $mac_address = "";
my $fh  = IO::Handle->new();
my $file_handle = IO::Handle->new();
my $sc = "ifconfig -a";
my $shell_call = "ip addr";
open ($fh, "$sc 2>&1 |") or die "Failed to call: [$sc], error: $!\n";
open ($file_handle, "$shell_call 2>&1 |") or die "Failed to call: [$shell_call], error: $!\n";
while (<$fh>)
while (<$file_handle>)
{
{
chomp;
chomp;
my $line = $_;
my $line = $_;
if ($line =~ /^(\S+):/)
if ($line =~ /^\d+: (\S+):/)
{
{
$dev = $1;
$device = $1;
next if $dev eq "lo";
next if $device eq "lo";
$mac = "";
$mac_address = "";
next;
next;
}
}
if ($line =~ /ether (.*?) /)
if ($line =~ /ether (.*?) /)
{
{
$mac = $1;
$mac_address = $1;
next if not $dev;
next if not $device;
$conf->{$dev} = $mac;
$conf->{$device} = $mac_address;
}
}
}
}


foreach my $dev (sort {$a cmp $b} keys %{$conf})
foreach my $device (sort {$a cmp $b} keys %{$conf})
{
{
my $say_dev = lc($dev);
my $say_dev = lc($device);
my $say_mac = lc($conf->{$dev});
my $say_mac = lc($conf->{$device});
print "\n# Added by 'write_udev' for detected device '$dev'.\n";
print "\n# Added by 'generate-udev-net' for detected device '$device'.\n";
print "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$say_mac\", NAME=\"$say_dev\"\n";
print "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$say_mac\", NAME=\"$say_dev\"\n";
}
}
</source>
 
exit(0);
 
</syntaxhighlight>


You can download and run this and it will print a skeleton udev file. If the output looks good, re-run it again and pipe the output to the <span class="code">70-persistent-net.rules</span> file.
You can download and run this and it will print a skeleton udev file. If the output looks good, re-run it again and pipe the output to the <span class="code">70-persistent-net.rules</span> file.
Line 290: Line 288:
Download it;
Download it;


<source lang="bash">
<syntaxhighlight lang="bash">
cd ~
cd ~
wget -c https://alteeve.ca/files/write_udev
wget -c https://alteeve.ca/files/generate-udev-net
</source>
</syntaxhighlight>
<source lang="text">
<syntaxhighlight lang="text">
--2012-10-07 21:25:19--  https://alteeve.ca/files/write_udev
--2015-07-22 04:18:01--  https://alteeve.ca/files/generate-udev-net
Resolving alteeve.ca... 64.34.141.3
Resolving alteeve.ca (alteeve.ca)... 65.39.153.64
Connecting to alteeve.ca|64.34.141.3|:443... connected.
Connecting to alteeve.ca (alteeve.ca)|65.39.153.64|:443... connected.
HTTP request sent, awaiting response... 200 OK
HTTP request sent, awaiting response... 200 OK
Length: 768 [text/plain]
Length: 897 [text/plain]
Saving to: `write_udev'
Saving to: ‘generate-udev-net’


100%[====================================================>] 768    --.-K/s  in 0s       
100%[====================================================================>] 897        --.-K/s  in 0s       


2012-10-07 21:25:19 (11.5 MB/s) - `write_udev' saved [768/768]
2015-07-22 04:18:02 (89.2 MB/s) - ‘generate-udev-net’ saved [897/897]
</source>
</syntaxhighlight>


Then you can run it;
Then you can run it;


<source lang="bash">
<syntaxhighlight lang="bash">
chmod 755 write_udev
chmod 755 generate-udev-net
./write_udev
./generate-udev-net
</source>
</syntaxhighlight>
<source lang="bash">
<syntaxhighlight lang="bash">
# Added by 'write_udev' for detected device 'p1p1'.
# Added by 'generate-udev-net' for detected device 'eth0'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:99:ab", NAME="p1p1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="eth0"


# Added by 'write_udev' for detected device 'p1p2'.
# Added by 'generate-udev-net' for detected device 'eth1'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:80", NAME="p1p2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="eth1"


# Added by 'write_udev' for detected device 'p2p1'.
# Added by 'generate-udev-net' for detected device 'eth2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:6c:87", NAME="p2p1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="eth2"


# Added by 'write_udev' for detected device 'p2p2'.
# Added by 'generate-udev-net' for detected device 'eth3'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:81", NAME="p2p2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="eth3"


# Added by 'write_udev' for detected device 'p4p1'.
# Added by 'generate-udev-net' for detected device 'eth4'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:70:02", NAME="p4p1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="eth4"


# Added by 'write_udev' for detected device 'p4p2'.
# Added by 'generate-udev-net' for detected device 'eth5'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:96:92", NAME="p4p2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="eth5"
</source>
</syntaxhighlight>


What we see above are the rules telling the system that the network device with the specified MAC address is to be given the given name. We are '''not''' changing the names yet. That will come in the next step.
What we see above are the rules telling the system that the network device with the specified MAC address is to be given the given name. We are '''not''' changing the names yet. That will come in the next step.
Line 337: Line 335:
If the output looks good to you, re-run the program, but this time we will redirect the output to the <span class="code">70-persistent-net.rules</span> file.
If the output looks good to you, re-run the program, but this time we will redirect the output to the <span class="code">70-persistent-net.rules</span> file.


<source lang="bash">
<syntaxhighlight lang="bash">
./write_udev > /etc/udev/rules.d/70-persistent-net.rules
./generate-udev-net > /etc/udev/rules.d/70-persistent-net.rules
cat /etc/udev/rules.d/70-persistent-net.rules  
cat /etc/udev/rules.d/70-persistent-net.rules  
</source>
</syntaxhighlight>
<source lang="bash">
<syntaxhighlight lang="bash">
# Added by 'write_udev' for detected device 'p1p1'.
# Added by 'generate-udev-net' for detected device 'eth0'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:99:ab", NAME="p1p1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="eth0"


# Added by 'write_udev' for detected device 'p1p2'.
# Added by 'generate-udev-net' for detected device 'eth1'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:80", NAME="p1p2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="eth1"


# Added by 'write_udev' for detected device 'p2p1'.
# Added by 'generate-udev-net' for detected device 'eth2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:6c:87", NAME="p2p1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="eth2"


# Added by 'write_udev' for detected device 'p2p2'.
# Added by 'generate-udev-net' for detected device 'eth3'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:81", NAME="p2p2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="eth3"


# Added by 'write_udev' for detected device 'p4p1'.
# Added by 'generate-udev-net' for detected device 'eth4'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:70:02", NAME="p4p1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="eth4"


# Added by 'write_udev' for detected device 'p4p2'.
# Added by 'generate-udev-net' for detected device 'eth5'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:96:92", NAME="p4p2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="eth5"
</source>
</syntaxhighlight>


If you are more comfortable writing this file yourself, instead of downloading some stranger's program, you can copy the output above, replace the <span class="code">ATTR{address}=="xx:xx:xx:xx:xx:xx"</span> value with the MAC addresses shown in the output from the earlier <span class="code">ifconfig -a</span> and setting the device names you wish.
If you are more comfortable writing this file yourself, instead of downloading some stranger's program, you can copy the output above, replace the <span class="code">ATTR{address}=="xx:xx:xx:xx:xx:xx"</span> value with the MAC addresses shown in the output from the earlier <span class="code">ip addr</span> and setting the device names you wish.


{{note|1=The MAC address values '''must''' be in lower-case.}}
{{note|1=The MAC address values '''must''' be in lower-case.}}
Line 371: Line 369:
I like to always make a backup of any file before I edit it;
I like to always make a backup of any file before I edit it;


<source lang="bash">
<syntaxhighlight lang="bash">
cp /etc/udev/rules.d/70-persistent-net.rules ~/
cp /etc/udev/rules.d/70-persistent-net.rules ~/
</source>
</syntaxhighlight>


Now we will edit our newly created <span class="code">/etc/udev/rules.d/70-persistent-net.rules</span> file and change the <span class="code">NAME="..."</span> values according to our table. In my case, the new file will look like this;
Now we will edit our newly created <span class="code">/etc/udev/rules.d/70-persistent-net.rules</span> file and change the <span class="code">NAME="..."</span> values according to our table. In my case, the new file will look like this;


<source lang="bash">
<syntaxhighlight lang="bash">
vim /etc/udev/rules.d/70-persistent-net.rules
vim /etc/udev/rules.d/70-persistent-net.rules
</source>
</syntaxhighlight>
<source lang="bash">
<syntaxhighlight lang="bash">
# Added by 'write_udev' for detected device 'p1p1'.
</syntaxhighlight>
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:99:ab", NAME="ifn1"
 
# Added by 'write_udev' for detected device 'p1p2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:80", NAME="sn1"
 
# Added by 'write_udev' for detected device 'p2p1'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:6c:87", NAME="bcn2"
 
# Added by 'write_udev' for detected device 'p2p2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:81", NAME="bcn1"
 
# Added by 'write_udev' for detected device 'p4p1'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:70:02", NAME="sn2"
 
# Added by 'write_udev' for detected device 'p4p2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:96:92", NAME="ifn2"
</source>


The changes are easier to see in a <span class="code">diff</span>;
The changes are easier to see in a <span class="code">diff</span>;


<source lang="bash">
<syntaxhighlight lang="bash">
diff -u /etc/udev/rules.d/70-persistent-net.rules /root/70-persistent-net.rules  
diff -u /etc/udev/rules.d/70-persistent-net.rules /root/70-persistent-net.rules  
</source>
</syntaxhighlight>
<source lang="diff">
<syntaxhighlight lang="diff">
--- /etc/udev/rules.d/70-persistent-net.rules 2012-10-07 21:40:38.041922729 -0400
--- /root/70-persistent-net.rules 2015-07-22 04:22:14.355000000 +0000
+++ /root/70-persistent-net.rules 2012-10-07 21:35:36.085919304 -0400
+++ /etc/udev/rules.d/70-persistent-net.rules 2015-07-22 04:22:44.472000000 +0000
@@ -1,18 +1,18 @@
@@ -1,18 +1,18 @@
   
   
  # Added by 'write_udev' for detected device 'p1p1'.
  # Added by 'generate-udev-net' for detected device 'eth0'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:99:ab", NAME="ifn1"
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="eth0"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:99:ab", NAME="p1p1"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="ifn_link1"
   
   
  # Added by 'write_udev' for detected device 'p1p2'.
  # Added by 'generate-udev-net' for detected device 'eth1'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:80", NAME="sn1"
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="eth1"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:80", NAME="p1p2"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="ifn_link2"
   
   
  # Added by 'write_udev' for detected device 'p2p1'.
  # Added by 'generate-udev-net' for detected device 'eth2'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:6c:87", NAME="bcn2"
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="eth2"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:6c:87", NAME="p2p1"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="sn_link1"
   
   
  # Added by 'write_udev' for detected device 'p2p2'.
  # Added by 'generate-udev-net' for detected device 'eth3'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:81", NAME="bcn1"
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="eth3"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:81:cb:00:81", NAME="p2p2"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="sn_link2"
   
   
  # Added by 'write_udev' for detected device 'p4p1'.
  # Added by 'generate-udev-net' for detected device 'eth4'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:70:02", NAME="sn2"
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="eth4"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:bf:70:02", NAME="p4p1"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="bcn_link1"
   
   
  # Added by 'write_udev' for detected device 'p4p2'.
  # Added by 'generate-udev-net' for detected device 'eth5'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:96:92", NAME="ifn2"
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="eth5"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:72:96:92", NAME="p4p2"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="bcn_link2"
</source>
</syntaxhighlight>


Now, next time we reboot, the system will use the given names for the specified MAC addresses!
Now, next time we reboot, the system will use the given names for the specified MAC addresses!


We're not quite done yet, though.
== Reboot and Test ==
 
== Writing The Configuration Files ==
 
{{warning|1=From this point on, losing your network access is quite likely. Be sure to have physical access to your system before proceeding.}}
 
Up until now, we've focused on the names of the devices. Now we need to tell the operating system how to configure each device. To do this, we need to edit or create a <span class="code">/etc/sysconfig/network-scripts/ifcfg-<dev></span> file for each network card, where <span class="code"><dev></span> matches the device's new name we just gave it.
 
In theory, there should be a corresponding <span class="code">/etc/sysconfig/network-scripts/ifcfg-<dev></span> file for each of the existing network devices. However, I find that often that this is not the case. This doesn't really matter though, because we're going to write fresh configuration files. If you already have a given configuration file, you can rename it if you want. How the file comes into existence is less important. What matters is that there is a configuration file for each device.
 
First, I prune out old configs;
 
<source lang="bash">
cd /etc/sysconfig/network-scripts/
rm -f ifcfg-{e*,p*}
</source>
 
Now I create six configuration files, one for each network. How you configure these will largely depend on what your goal is. For the sake of this tutorial, I will set <span class="code">ifn1</span> to <span class="code">[[dhcp]]</span> and the rest of the interfaces to <span class="code">none</span>. The [http://docs.fedoraproject.org/en-US/Fedora/17/html/System_Administrators_Guide/s1-networkscripts-interfaces.html Fedora 17] documentation covers the various arguments and they values well.
 
First up, my two [[BCN]] interfaces;
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-bcn1
</source>
<source lang="bash">
# Back-Channel Network - Link 1
DEVICE="bcn1"
NM_CONTROLLED="no"
BOOTPROTO="none"
ONBOOT="yes"
</source>
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-bcn2
</source>
<source lang="bash">
# Back-Channel Network - Link 2
DEVICE="bcn2"
NM_CONTROLLED="no"
BOOTPROTO="none"
ONBOOT="yes"
</source>
 
Next, my two [[SN]] interfaces;
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-sn1
</source>
<source lang="bash">
# Storage Network - Link 1
DEVICE="sn1"
NM_CONTROLLED="no"
BOOTPROTO="none"
ONBOOT="yes"
</source>
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-bcn2
</source>
<source lang="bash">
# Storage Network - Link 2
DEVICE="sn2"
NM_CONTROLLED="no"
BOOTPROTO="none"
ONBOOT="yes"
</source>
 
Finally, the two [[IFN]] links. As mentioned above, the first one is set to <span class="code">BOOTPROTO="dhcp"</span>.
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-ifn1
</source>
<source lang="bash">
# Internet-Facing Network - Link 1
DEVICE="ifn1"
NM_CONTROLLED="no"
BOOTPROTO="dhcp"
ONBOOT="yes"
</source>
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-bcn2
</source>
<source lang="bash">
# Internet-Facing Network - Link 1
DEVICE="ifn1"
NM_CONTROLLED="no"
BOOTPROTO="none"
ONBOOT="yes"
</source>
 
Done. One step to go!
 
= Switching to Static network =
 
Traditionally, the <span class="code">network</span> [[daemon]] was used. However, this daemon is not very flexible, so moving a computer between networks is difficult. To address this, recent Fedora and Red Hat distributions switched to the more user friendly <span class="code">NetworkManager</span> daemon. This tool is much more flexible, allowing for the automatic detection of new wired and wireless networks and re-configuring the computer's networking to suite.
 
In servers though, this is not usually a good thing. Servers rarely move around and consistency is preferred. So the first thing we will do is to remove <span class="code">NetworkManager</span> and switch back to using the older, more static <span class="code">network</span> daemon.
 
== Switching NetworkManager For The network Daemon ==
 
First, tell the machine to start the <span class="code">network</span> daemon on boot.
 
<source lang="bash">
chkconfig network on
chkconfig --list network
</source>
<source lang="text">
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
 
network        0:off 1:off 2:on 3:on 4:on 5:on 6:off
</source>
 
Now, we will disable and then uninstall <span class="code">NetworkManager</span>.
 
<source lang="bash">
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
</source>
<source lang="text">
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
</source>
 
<source lang="bash">
yum remove NetworkManager
</source>
<source lang="text">
Loaded plugins: langpacks, presto, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:0.9.4.0-9.git20120521.fc17 will be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
Package          Arch      Version                          Repository  Size
================================================================================
Removing:
NetworkManager    x86_64    1:0.9.4.0-9.git20120521.fc17    @updates    6.8 M
 
Transaction Summary
================================================================================
Remove  1 Package
 
Installed size: 6.8 M
</source>
<source lang="text">
Is this ok [y/N]: y
</source>
<source lang="text">
Downloading Packages:
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : 1:NetworkManager-0.9.4.0-9.git20120521.fc17.x86_64          1/1
  Verifying  : 1:NetworkManager-0.9.4.0-9.git20120521.fc17.x86_64          1/1
 
Removed:
  NetworkManager.x86_64 1:0.9.4.0-9.git20120521.fc17                           
 
Complete!
</source>
 
= Applying The Changes =


We've changed how the kernel views the hardware, so we need to now reboot the system to make the changes take effect.
{{note|1=In the output below, you will see several additional interfaces, three bonds and a bridge, which were created as part of the [[Anvil!_Tutorial_3#Network|Anvil! Tutorial 3]] network setup. You can ignore those for now.}}


<source lang="bash">
So now, reboot and we'll verify it is remapped.
reboot
</source>


Once the system boots back up, we should see that all the network cards have been renamed.
First, call <span class="code">ip add</span> and make sure the '<span class="code">eth[05]</span>' interfaces are gone and the new '<span class="code">{bcn,sn,ifn}_link{1,2}</span>' interfaces are show.


<source lang="bash">
<syntaxhighlight lang="bash">
ifconfig -a
ip addr
</source>
</syntaxhighlight>
<source lang="text">
<syntaxhighlight lang="text">
bcn1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        inet6 fe80::2e0:81ff:fecb:81  prefixlen 64 scopeid 0x20<link>
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        ether 00:e0:81:cb:00:81  txqueuelen 1000  (Ethernet)
    inet 127.0.0.1/8 scope host lo
        RX packets 83  bytes 7958 (7.7 KiB)
      valid_lft forever preferred_lft forever
        RX errors 0  dropped 0  overruns 0  frame 0
    inet6 ::1/128 scope host
        TX packets 8  bytes 680 (680.0 B)
      valid_lft forever preferred_lft forever
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
2: ifn_link1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ifn_bond1 state UP qlen 1000
        device interrupt 18  memory 0xf7a00000-f7a20000 
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
3: ifn_link2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ifn_bond1 state UP qlen 1000
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
4: sn_link1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master sn_bond1 state UP qlen 1000
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
5: sn_link2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master sn_bond1 state UP qlen 1000
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
6: bcn_link1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bcn_bond1 state UP qlen 1000
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
7: bcn_link2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bcn_bond1 state UP qlen 1000
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
8: ifn_bridge1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.31/24 brd 192.168.122.255 scope global ifn_bridge1
      valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:febd:1307/64 scope link
      valid_lft forever preferred_lft forever
9: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
    link/ether fa:77:7c:ce:b9:f0 brd ff:ff:ff:ff:ff:ff
10: bcn_bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
    inet 10.20.30.1/16 brd 10.20.255.255 scope global bcn_bond1
      valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:feb3:633e/64 scope link  
      valid_lft forever preferred_lft forever
11: ifn_bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master ifn_bridge1 state UP
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5054:ff:febd:1307/64 scope link
      valid_lft forever preferred_lft forever
12: sn_bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
    inet 10.10.30.2/16 brd 10.10.255.255 scope global sn_bond1
      valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe01:3fc8/64 scope link
      valid_lft forever preferred_lft forever
</syntaxhighlight>


bcn2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
Interfaces 2 through 7 are the newly named interfaces. So now lets watch the system log again while we pull our cables.
        inet6 fe80::21b:21ff:febf:6c87  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:bf:6c:87  txqueuelen 1000  (Ethernet)
        RX packets 82  bytes 7862 (7.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 606 (606.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  memory 0xf7dc0000-f7de0000 


ifn1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
<syntaxhighlight lang="bash">
        inet 10.255.0.23  netmask 255.255.0.0  broadcast 10.255.255.255
journalctl -f -n 0
        inet6 fe80::21b:21ff:fe72:99ab  prefixlen 64  scopeid 0x20<link>
</syntaxhighlight>
        ether 00:1b:21:72:99:ab  txqueuelen 1000  (Ethernet)
<syntaxhighlight lang="text">
        RX packets 181  bytes 19221 (18.7 KiB)
-- Logs begin at Wed 2015-07-22 04:34:09 GMT. --
        RX errors 0  dropped 0  overruns 0  frame 0
</syntaxhighlight>
        TX packets 115  bytes 18154 (17.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf7ec0000-f7ee0000 


ifn2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
Pull the cable marked as '<span class="code">bcn_link1</span>';
        inet6 fe80::21b:21ff:fe72:9692  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:72:96:92  txqueuelen 1000  (Ethernet)
        RX packets 55  bytes 5248 (5.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 492 (492.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf79c0000-f79e0000 


lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
<syntaxhighlight lang="text">
        inet 127.0.0.1  netmask 255.0.0.0
Jul 22 04:46:00 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link1): link disconnected
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
</syntaxhighlight>
        loop  txqueuelen 0 (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


sn1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
Plug it back in;
        inet6 fe80::2e0:81ff:fecb:80  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:81:cb:00:80  txqueuelen 1000  (Ethernet)
        RX packets 55  bytes 5248 (5.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 492 (492.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  memory 0xf7b00000-f7b20000 


sn2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
<syntaxhighlight lang="text">
        inet6 fe80::21b:21ff:febf:7002  prefixlen 64  scopeid 0x20<link>
Jul 22 04:46:08 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link1): link connected
        ether 00:1b:21:bf:70:02  txqueuelen 1000 (Ethernet)
</syntaxhighlight>
        RX packets 55  bytes 5248 (5.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 492 (492.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xf7cc0000-f7ce0000 
</source>


To test, I will again <span class="code">tail</span> the system log and pull each cable. If everything worked, the proper interface should report going down.
Repeat for '<span class="code">bcn_link2</span>';


I'll start with <span class="code">bcn1</span>;
<syntaxhighlight lang="text">
Jul 22 04:47:24 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link2): link disconnected
Jul 22 04:47:27 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link2): link connected
</syntaxhighlight>


<source lang="bash">
Repeat for the other four interfaces;
tail -f -n 0 /var/log/messages
</source>


Unplug the cable;
<syntaxhighlight lang="text">
Jul 22 04:48:12 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link1): link disconnected
Jul 22 04:48:16 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link1): link connected
Jul 22 04:48:33 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link2): link disconnected
Jul 22 04:48:36 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link2): link connected
Jul 22 04:48:56 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link1): link disconnected
Jul 22 04:49:00 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link1): link connected
Jul 22 04:49:25 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link2): link disconnected
Jul 22 04:49:29 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link2): link connected
</syntaxhighlight>


<source lang="text">
That matches the order that we pulled the cables, so the remap worked perfectly.
Oct  7 23:18:24 an-c04n02 kernel: [  274.021561] e1000e: bcn1 NIC Link is Down
</source>


Excellent! All the others should show the proper named interface going down. If so, we're done!
We're done!


{{footer}}
{{footer}}

Latest revision as of 04:51, 22 July 2015

 AN!Wiki :: How To :: Changing Ethernet Device Names in EL7 and Fedora 15+

Traditionally in Linux, network devices were given the name ethX, where X was a digit starting at 0 and incremented up. The drawback to this was that there was no consistent or deterministic way to know which physical network ports would get which ethX name. To address this, Fedora 15 (and other distributions) began using a new tool called biosdevname which names each network device based on where it is found in the system. The result is that, usually, you can predict the name of a given physical interface.

This tutorial will show you how to change these device names to anything you would like. This tutorial is not meant to advocate against the new network naming. However, there are cases ranging from simple familiarity to application compatibility that might make you want to use different network device names. For those cases, this tutorial hopes to help you.

Assumptions

This tutorial makes a few assumption which may not apply to your system. Please adjust accordingly.

This tutorial assumes you have six network cards;

  • eth0
  • eth1
  • eth2
  • eth3
  • eth4
  • eth5

We will rename these to;

  • bcn_link1
  • bcn_link2
  • sn_link1
  • sn_link2
  • ifn_link1
  • ifn_link2

The reason for these names is that, in my case, I wish to give names to interfaces that reflect their purpose in my servers. Specifically, I need three bonded networks; BCN, SN and IFN in my clusters. You can just as easily use eth0 to eth5 or any other name that suits your purposes.

This tutorial also assumes that you have a minimal install and that the system is designed to be a server. As such, NetworkManager is removed and the network daemon will be used. No attempt was made to test if the method of renaming network devices shown here works with NetworkManager.

Overview

We will need to take the following steps;

  1. Identify the network device names assigned to each interface.
  2. Generate the /etc/udev/rules.d/70-persistent-net.rules file.
  3. Unplug and plug back in each network interface to create the map of current to desired names.
  4. Rename and edit the /etc/sysconfig/network-scripts/ifcfg-X files to reflect the desired names.
  5. Edit the /etc/udev/rules.d/70-persistent-net.rules file to create the MAC address to device name maps.
  6. Restart the machine to make the changes take effect.

Identify Interfaces

To start, you want to see what the names your system has already given to the network interfaces. This can be done with ip addr, which reports all network cards, regardless if they are started or not.

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.254/24 brd 192.168.122.255 scope global dynamic eth0
       valid_lft 3445sec preferred_lft 3445sec
    inet6 fe80::5054:ff:febd:1307/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:39:18:09 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:c9:83:aa brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:fe:eb:0f brd ff:ff:ff:ff:ff:ff

So I see the six network cards named ethX. You might have emX, pXpY or so on. The current names themselves doesn't matter too much, so long as you see all of your interfaces.

Mapping Current Names to Desired Names

So now that we know which cards you have, we need to sort out which name maps to which device. There are several ways you can do this;

  • Sorting out the Consistent Network Device Names to physical interfaces. I find this to be an imperfect art.
  • Use ethtool -p <dev> and watch to see which port's light blinks. This requires driver support and a clear view of the network cards.
  • Unplug a network cable and then run ip addr and see which interface changed from <BROADCAST,MULTICAST,UP,LOWER_UP> to <NO-CARRIER,BROADCAST,MULTICAST,UP> and note the device name.
  • Watch the system log and unplug each cable to see what device is reported as having disconnected. This is the method we'll use.

Before we proceed, let me give some background on what is happening behind the scenes.

In my case, I have three networks, each bonded across two interfaces, each link going to a separate switch (switch 1 and switch 2). I want to name these devices after their purpose;

Before I started, I figured out which physical port I wanted to use for a given network and link. You will obviously have your own plan and it will likely differ from the one shown here. This is no problem at all. So long as you know what name you want to give each physical interface, you are ready to go.

Initial List

Start by creating a list of interfaces names you want. Then, as you pull each cable, mark the current name of the connection that went down beside the desired name.

So here is the list of desired names that I start with;

Current Name Desired Name
bcn_link1
bcn_link2
sn_link1
sn_link2
ifn_link1
ifn_link2

Before we begin, we'll want to watch messages being printed to the system log. We can do this using journalctl's 'follow' switch, -f switch, like so;

journalctl -f -n 0
-- Logs begin at Wed 2015-07-22 02:03:47 GMT. --

The '-n 0' tells it to show no previous lines in the log.

Now, start by pulling the first cable and you should see a message indicating the current name of the interface having gone down. In my case, I am pulling the network cable which I want to be named bcn_link1 (the "back-channel network link to switch number 1).

Unplug the first cable and you should see log entries like this:

Jul 22 03:38:24 an-a03n01.alteeve.ca nm-dispatcher[14204]: Dispatching action 'dhcp4-change' for eth0
Jul 22 03:46:12 an-a03n01.alteeve.ca NetworkManager[816]: <info>  (eth4): link disconnected

Plug the cable back in and you should see an entry like this;

Jul 22 03:46:17 an-a03n01.alteeve.ca NetworkManager[816]: <info>  (eth4): link connected

So in my case, I see that the current name is eth4. So I will record this next to 'bcn_link1' in my table;

Current Name Desired Name
eth4 bcn_link1
bcn_link2
sn_link1
sn_link2
ifn_link1
ifn_link2

Now I unplug the device I want to be called bcn_link2;

Jul 22 04:00:53 an-a03n01.alteeve.ca NetworkManager[816]: <info>  (eth5): link disconnected

Plug it back in;

Jul 22 04:01:01 an-a03n01.alteeve.ca NetworkManager[816]: <info>  (eth5): link connected

So here I see that the interface currently named eth5 is the one I want to rename to 'bcn_link2', so I add it to the table.

Current Name Desired Name
eth4 bcn_link1
eth5 bcn_link2
sn_link1
sn_link2
ifn_link1
ifn_link2

Repeat this for the next four interfaces. Once done, you should have something like;


Current Name Desired Name
eth4 bcn_link1
eth5 bcn_link2
eth2 sn_link1
eth3 sn_link2
eth0 ifn_link1
eth1 ifn_link2

There, now I know the existing device name and the name I wish to give it.

Writing The udev Rules File

The way we're going to create the actual MAC address to device name mapping will be via udev rules. Specifically, we're going to edit or create the /etc/udev/rules.d/70-persistent-net.rules. As of Fedora 17, this file is no longer created, so you will need to create it yourself. I've written a little script to do this;

Note: If this script produces no output, run ip addr. If the output looks like: [eth0 Link encap:Ethernet HWaddr 00:1b:21:72:99:ab], then your system is using the old-style output and this script won't work.
#!/usr/bin/perl

use strict;
use warnings;
use IO::Handle;
my $conf = {};

# Read the 'ip addr'
my $device      = "";
my $mac_address = "";
my $file_handle = IO::Handle->new();
my $shell_call  = "ip addr";
open ($file_handle, "$shell_call 2>&1 |") or die "Failed to call: [$shell_call], error: $!\n";
while (<$file_handle>)
{
	chomp;
	my $line = $_;
	if ($line =~ /^\d+: (\S+):/)
	{
		$device = $1;
		next if $device eq "lo";
		$mac_address = "";
		next;
	}
	if ($line =~ /ether (.*?) /)
	{
		$mac_address = $1;
		next if not $device;
		$conf->{$device} = $mac_address;
	}
}

foreach my $device (sort {$a cmp $b} keys %{$conf})
{
	my $say_dev = lc($device);
	my $say_mac = lc($conf->{$device});
	print "\n# Added by 'generate-udev-net' for detected device '$device'.\n";
	print "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$say_mac\", NAME=\"$say_dev\"\n";
}

exit(0);

You can download and run this and it will print a skeleton udev file. If the output looks good, re-run it again and pipe the output to the 70-persistent-net.rules file.

Download it;

cd ~
wget -c https://alteeve.ca/files/generate-udev-net
--2015-07-22 04:18:01--  https://alteeve.ca/files/generate-udev-net
Resolving alteeve.ca (alteeve.ca)... 65.39.153.64
Connecting to alteeve.ca (alteeve.ca)|65.39.153.64|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 897 [text/plain]
Saving to: ‘generate-udev-net’

100%[====================================================================>] 897         --.-K/s   in 0s      

2015-07-22 04:18:02 (89.2 MB/s) - ‘generate-udev-net’ saved [897/897]

Then you can run it;

chmod 755 generate-udev-net
./generate-udev-net
# Added by 'generate-udev-net' for detected device 'eth0'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="eth0"

# Added by 'generate-udev-net' for detected device 'eth1'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="eth1"

# Added by 'generate-udev-net' for detected device 'eth2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="eth2"

# Added by 'generate-udev-net' for detected device 'eth3'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="eth3"

# Added by 'generate-udev-net' for detected device 'eth4'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="eth4"

# Added by 'generate-udev-net' for detected device 'eth5'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="eth5"

What we see above are the rules telling the system that the network device with the specified MAC address is to be given the given name. We are not changing the names yet. That will come in the next step.

If the output looks good to you, re-run the program, but this time we will redirect the output to the 70-persistent-net.rules file.

./generate-udev-net > /etc/udev/rules.d/70-persistent-net.rules
cat /etc/udev/rules.d/70-persistent-net.rules
# Added by 'generate-udev-net' for detected device 'eth0'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="eth0"

# Added by 'generate-udev-net' for detected device 'eth1'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="eth1"

# Added by 'generate-udev-net' for detected device 'eth2'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="eth2"

# Added by 'generate-udev-net' for detected device 'eth3'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="eth3"

# Added by 'generate-udev-net' for detected device 'eth4'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="eth4"

# Added by 'generate-udev-net' for detected device 'eth5'.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="eth5"

If you are more comfortable writing this file yourself, instead of downloading some stranger's program, you can copy the output above, replace the ATTR{address}=="xx:xx:xx:xx:xx:xx" value with the MAC addresses shown in the output from the earlier ip addr and setting the device names you wish.

Note: The MAC address values must be in lower-case.

Changing The Device Names

Now that we have our skeleton /etc/udev/rules.d/70-persistent-net.rules and our rename table, we can change the device names.

I like to always make a backup of any file before I edit it;

cp /etc/udev/rules.d/70-persistent-net.rules ~/

Now we will edit our newly created /etc/udev/rules.d/70-persistent-net.rules file and change the NAME="..." values according to our table. In my case, the new file will look like this;

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

The changes are easier to see in a diff;

diff -u /etc/udev/rules.d/70-persistent-net.rules /root/70-persistent-net.rules
--- /root/70-persistent-net.rules	2015-07-22 04:22:14.355000000 +0000
+++ /etc/udev/rules.d/70-persistent-net.rules	2015-07-22 04:22:44.472000000 +0000
@@ -1,18 +1,18 @@
 
 # Added by 'generate-udev-net' for detected device 'eth0'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="eth0"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:bd:13:07", NAME="ifn_link1"
 
 # Added by 'generate-udev-net' for detected device 'eth1'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="eth1"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:39:18:09", NAME="ifn_link2"
 
 # Added by 'generate-udev-net' for detected device 'eth2'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="eth2"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:01:3f:c8", NAME="sn_link1"
 
 # Added by 'generate-udev-net' for detected device 'eth3'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="eth3"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c9:83:aa", NAME="sn_link2"
 
 # Added by 'generate-udev-net' for detected device 'eth4'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="eth4"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b3:63:3e", NAME="bcn_link1"
 
 # Added by 'generate-udev-net' for detected device 'eth5'.
-SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="eth5"
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:eb:0f", NAME="bcn_link2"

Now, next time we reboot, the system will use the given names for the specified MAC addresses!

Reboot and Test

Note: In the output below, you will see several additional interfaces, three bonds and a bridge, which were created as part of the Anvil! Tutorial 3 network setup. You can ignore those for now.

So now, reboot and we'll verify it is remapped.

First, call ip add and make sure the 'eth[05]' interfaces are gone and the new '{bcn,sn,ifn}_link{1,2}' interfaces are show.

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ifn_link1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ifn_bond1 state UP qlen 1000
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
3: ifn_link2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ifn_bond1 state UP qlen 1000
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
4: sn_link1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master sn_bond1 state UP qlen 1000
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
5: sn_link2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master sn_bond1 state UP qlen 1000
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
6: bcn_link1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bcn_bond1 state UP qlen 1000
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
7: bcn_link2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bcn_bond1 state UP qlen 1000
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
8: ifn_bridge1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.31/24 brd 192.168.122.255 scope global ifn_bridge1
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:febd:1307/64 scope link 
       valid_lft forever preferred_lft forever
9: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN 
    link/ether fa:77:7c:ce:b9:f0 brd ff:ff:ff:ff:ff:ff
10: bcn_bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 52:54:00:b3:63:3e brd ff:ff:ff:ff:ff:ff
    inet 10.20.30.1/16 brd 10.20.255.255 scope global bcn_bond1
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:feb3:633e/64 scope link 
       valid_lft forever preferred_lft forever
11: ifn_bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master ifn_bridge1 state UP 
    link/ether 52:54:00:bd:13:07 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5054:ff:febd:1307/64 scope link 
       valid_lft forever preferred_lft forever
12: sn_bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 52:54:00:01:3f:c8 brd ff:ff:ff:ff:ff:ff
    inet 10.10.30.2/16 brd 10.10.255.255 scope global sn_bond1
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe01:3fc8/64 scope link 
       valid_lft forever preferred_lft forever

Interfaces 2 through 7 are the newly named interfaces. So now lets watch the system log again while we pull our cables.

journalctl -f -n 0
-- Logs begin at Wed 2015-07-22 04:34:09 GMT. --

Pull the cable marked as 'bcn_link1';

Jul 22 04:46:00 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link1): link disconnected

Plug it back in;

Jul 22 04:46:08 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link1): link connected

Repeat for 'bcn_link2';

Jul 22 04:47:24 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link2): link disconnected
Jul 22 04:47:27 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (bcn_link2): link connected

Repeat for the other four interfaces;

Jul 22 04:48:12 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link1): link disconnected
Jul 22 04:48:16 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link1): link connected
Jul 22 04:48:33 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link2): link disconnected
Jul 22 04:48:36 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (sn_link2): link connected
Jul 22 04:48:56 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link1): link disconnected
Jul 22 04:49:00 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link1): link connected
Jul 22 04:49:25 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link2): link disconnected
Jul 22 04:49:29 an-a03n01.alteeve.ca NetworkManager[703]: <info>  (ifn_link2): link connected

That matches the order that we pulled the cables, so the remap worked perfectly.

We're done!

 

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.