Feb
08

ifconfig ubuntu outputI have seen this problem a lot on hyper-visors that use dynamic MAC addresses over the past few weeks, such as hyper-v.

Your interface names such as eth0 are assigned to a physical interface, specifically the MAC address of that interface. So when your MAC address changes the system thinks it’s a new network card and assigns the next free name, lets say eth1.

However your network configuration file is still referring to the old name eth0. So basically you end up trying to apply configuration to a NIC that doesn’t exist, while there is a new NIC with no configuration. The ultimate result is you lose all network connectivity…

So how do you fix it? well there is a few ways depending on how much of a mess your in. However remember which ever method you use, ensure that once complete your no longer using dynamic MAC addresses and the below fix should be permanent.

1. Ok so you remember the original MAC address?

Hyper-V sometimes logs this in the job’s trail, so if you can find it that’s great, otherwise it’s going to get a bit more technical in option 2.
Power down the virtual machine and just apply a static MAC address to the interface using the original MAC, boot it back up and you should be on-line.

2. Don’t know what the old MAC was?

This one actually isn’t too hard, so I normally do this anyway.

Power on the virtual machine if its not already, make a backup of the following file.

sudo cp /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.backup

Now you have a backup, delete the file.

sudo rm /etc/udev/rules.d/70-persistent-net.rules

reboot the machine

reboot

So basically that just deleted all of the old MAC address to name (eht0) mappings, so when the system boots these should be correctly created again.

Don’t forget to do a final power off and set the NIC to static MAC’s, so you don’t end up with this problem again.

If you have no console access to the virtual machine or server, this can be risky!

3. Manually edit.
I am not going into it here, however you can try to manually update the above file you removed. However I find it easier just to let the OS do the work for you…

Bookmark this on Digg
Share on reddit
Share on StumbleUpon
Bookmark this on Delicious
Share on LinkedIn

You can leave a response, or trackback from your own site.

4 Responses to “Ubuntu eth0 missing after reboot.”

 
  1. Bryan Deshner says:

    Thanks for provided this article,Thank you for sharing the report.I admire it very much.it is very useful for me.

  2. charles wan says:

    Tom, thanks a lot. This helped me solve the problem of rebooting from a USB drive on a different machine (so the MAC address are different from last time). Appreciate your contribution.

  3. Sandeep says:

    Thanks, helped me :)

  4. Al says:

    Thank you for your insight. I was wondering why my eth0 interface would not appear after creating a linked clone in VirtualBox. (I had chosen to reinitialize the MAC addresses when creating the clone, and that explains why it “disappeared”.)

 

Leave a Reply

Our Sponsors