Alright, this is actually a pretty simple problem, but only once you know which configuration files to look at.
I recently replaced the machine that powers this very web site with a better one. This was my first migration since switching to Ubuntu Server last winter. I essentially took the hard drive out of the old machine and plopped it in the new one, booted it up, and hoped for the best. Since Linux is not as picky as Windows about being moved to a new set of hardware, I figured it would work out fine.
Sure enough, Ubuntu booted right up on the new machine without so much as a complaint. However, network connectivity was gone. The old machine was using a PCI Ethernet card, while the new machine had an on-board controller that I hoped to use. Anyway, I took the PCI card from the old machine and put it in the new machine, and then the network connectivity was back.
Why wouldn’t Ubuntu just start using the on-board controller, though?
Well, it turns out Ubuntu Server, in its default configuration, remembers which MAC address goes with which Ethernet device. (This as opposed to the default configuration on the desktop version, where NetworkManager handles this dynamically.) This information is stored in /etc/udev/rules.d/70-persistent-net.rules, and looks something like this:
# 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.# PCI device 0x8086:0x1229 (e100)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"# PCI device 0x14e4:0x4401 (b44)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
Here, my old Ethernet card (e100) and my new card (b44) are listed as eth0 and eth1. In /etc/network/interfaces, I only had a configuration for eth0. Thus, no network connectivity when that card was not present.
The solution is simply to modify /etc/udev/rules.d/70-persistent-net.rules so that the card you want is eth0, or to add an appropriate configuration for eth1 in /etc/network/interfaces. Of course, the entry in the rules file for the adapter that is no longer present should be commented out or erased. Anyway, after making these changes and bouncing the Ethernet kernel modules (or just rebooting the machine), things should work how you like.
Tags: Linux, Ubuntu, Ubuntu Server
I actually had the same problem, thanks.
Isn’t there any command for udev to detect new devices and kill everything related to a missing one?
very good tutorial this work to my box
This fix worked for me too!