Posted in Networking, Oracle, Virtualbox

How to change the network device name from eth5 to eth0

As I’m using a lot Virtualbox, I have often encountered the situation where I had to adapt the network adapters to follow some naming standards (to match my scripts 🙂 of course).

I’ve created some time ago a BASE VM where I deployed all the packages that I would possibly need for any ORACLE installation. On this BASE VM I have created 3 network adapters (1 bridged one and 2 host-only ones). Each time I need to create a VM, I’m just cloning the BASE VM – it saves A LOT of time. However, I still need to apply some changes, such as the hostname and network adapters.

So, here is what I did:

After the new VM is up&running, grab the MAC addresses first:

[root@base rules.d]# ifconfig | grep HWadd
eth3      Link encap:Ethernet  HWaddr 08:00:27:50:9C:9D
eth4      Link encap:Ethernet  HWaddr 08:00:27:B6:B4:99
eth5      Link encap:Ethernet  HWaddr 08:00:27:B1:8F:0A
[root@base rules.d]#

Go to /etc/udev/rules.d/ and edit 70-persistent-net.rules

This is what I have:

[root@base rules.d]# cat 70-persistent-net.rules
# 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 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:22:74:f9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b1:b2:5c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:89:47:fd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:50:9c:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b6:b4:99", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b1:8f:0a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
[root@base rules.d]#

As you can see, the new names are eth3 – eth4 – eth5. I’m going to delete the previous ones and rename the new ones as eth0 – eth1 – eth2. My file is going to look like this:

[root@base rules.d]# cat 70-persistent-net.rules
# 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 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:50:9c:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b6:b4:99", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b1:8f:0a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
[root@base rules.d]#

The second step is to go here “/etc/sysconfig/network-scripts” and adapt the ifcfg-eth* files accordingly.

[root@base network-scripts]# ll ifcfg-eth*
-rw-r--r--. 1 root root 231 Jun 18  2014 ifcfg-eth0
-rw-r--r--. 1 root root 231 Jun 18  2014 ifcfg-eth1
-rw-r--r--. 1 root root 231 Jun 18  2014 ifcfg-eth2
[root@base network-scripts]#

Delete in each file the UUID line, replace the MAC address with the one u get with “ifconfig | grep HW” and adapt the Name with a proper one.

The last step is to REBOOT the server and check the network adapters.

Advertisements

Author:

I am an Oracle DBA with experience in Maximum Availability technology such as RAC, Data Guard, Grid Control and ASM. I worked with version 9i through 12c on a number of operating systems. Next to that I have an extensive experience with PL/SQL, Oracle eBusiness Suite and shell scripting. Specialties: Oracle RAC & ASM (Configuration/Monitoring/Tuning) Oracle Data Guard (Configuration/Monitoring/Tuning) EM12c (Installation / troubleshooting) SQL & PLSQL *nix Shell scripting

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.