Debian,Operating Systems 05/01/2013 at 21:12

Assign interfaces names to MAC address in Debian 6


Sometimes your network interface fails, or simply you replace it for a new one. In this case, when you restart the Debian machine, it detects that the MAC address of the new interface is different of the MAC address of the old interface,so it assumes that it is a new interface and assigns it a new name.

So, if before the name of our network interface was eth0, the new network interface becomes eth0.This behavior has the advantage of allowing you to add multiple network interfaces easily, but in the case of replacing a network interface, it breaks the network configuration, because the directives defined in the file / etc / networt / interfaces
no longer apply.

To solve this problem, we must edit the file finished persistent-net.rules under the directory /etc/udev/rules.d/


Inside it, each MAC address is asociated to a device name (such ethx), so you have to remove the line that made ??reference to eth0, and edit the line that refers to eth1, to reference eth0.
So, if our rules file looks 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, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:65:9a:9f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:37:bd:91", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

we must remove lines 7, and 8, and modify line 10, to leave file as follows:

# 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:37:bd:91", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Finally reboot the machine with the typical command:

# restart

This way, your network settings should be restored.

References

Debian: MAC address changes: interface changes


This post is also available in Español.

Tags:

Leave a reply

required

required

optional


%d bloggers like this: