Debian: swap hardware name eth0 to eth1 and vice versa

On one of my computer I have two network cards, one for internet connection and the other one for local network. After a new Debian installation, the hardware names changed. Here is what I have done to swap them back:

1. Edit file “/etc/udev/rules.d/70-persistent-net.rules” using your favorite editor:

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

2. Change entry NAME=”eth0″ to NAME=”eth1″ and NAME=”eth1″ to NAME=”eth0″. My file then 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 0x14e4:0x1677 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:30:05:c5:73:e0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10ec:0x8169 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:52:ae:b2:95", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

3. Edit file “/etc/network/interfaces” and change all “eth1” to “eth0”. My file then looks like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

4. Reboot your computer.

5. That’s it!