Syed Jahanzaib – Personal Blog to Share Knowledge !

August 26, 2013

Mystry of ethernet not appearing in Ubuntu under VM after mac change

Filed under: Linux Related, VMware Related — Tags: — Syed Jahanzaib / Pinochio~:) @ 8:41 AM

Ubuntu

Recently I was doing an remote installation of Ubuntu Server as a guest VM in ESXI 5.1 in INDIA/PUNE. It was OS requirement to change the default dynamic mac created by VM to some other fixed mac address because of an application requirement which was bind with the specific mac address. After changing mac address to required mac address e.g: 00:0h:c1:96:1c:98 via esxi client in guest vm networking properties , when I rebooted Ubuntu, the Ethernet adapter didn’t not appeared in the networking interfaces list.If i manualy try to bring up the interface by ifconfig eth0 up or ifconfig eth1 up , I receive following error.

SIOCSIFADDR: no such device
eth0: ERROR while getting interface flags: No such device
Bind socket to interface: no such device
Failed to bring up eth0

When I revert it to default (dynamic) it works ok.

After investigating deeply, it revealed that it occurred because if we clone a virtual machine , it creates a new MAC address for each network adapter. The guest operating system detects this is a new network adapter that has been inserted, but retains configuration for the previous network adapter (name and mac).

So here is how I fixed it.

Login to your Ubuntu server (which is installed under vm) with root access ,

Open the file /etc/udev/rules.d/70-persistent-net.rules in nano.

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


You will see something like below . . . (After cloning of mac)

# 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 0x1022:0x2000 (pcnet32)  # Entry Ethernet adapter before cloning
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:11:3b:6a:8c", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (pcnet32)  # Entry Ethernet adapter after cloning
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0h:c1:96:1c:98", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

.

Now simply remove the first entry which is old interface entry with mac 00:0c:11:3b:6a:8c,

and in second entry which is eth1, change it to eth0

so after editing the file will look like following.

# 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.
# Syed Jahanzaib . aacable@hotmai.com . https://aacable.wordpress.com

# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0h:c1:96:1c:98", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Save the file and and exit.

Now simply reboot the Ubuntu server, and then check your interface by

ifconfig

Hopefully it will appear in the list.

.

TIP: To avoid such issues, always change the mac address before OS installation :)~  / Zaib

.

Regard’s
Syed Jahanzaib