eth0 changed to eth1 or eth2 and the solution to fix it

If you move your hard drive(s) around to other computers/servers, you'll find that your eth0 keeps getting higher, the first time it will become eth1 and then eth2 etc and even higher if your server has dual or quad NICs.  The reason is that udevd basically assigns eth0 tot he first NIC it finds and remembers it, if it encounters a NIC with a different MAC, it assigns it one higher (eg. eth1).

See the example below, I have eth2 now so how do I fix it?

ifconfig
eth2      Link encap:Ethernet  HWaddr 90:e6:ba:30:fb:0c 
          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::92e6:baff:fe30:fb0c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:62000457 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25890816 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3247729393 (3.2 GB)  TX bytes:1775390659 (1.7 GB)
          Interrupt:253 Base address:0xa000




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


# This file maintains persistent names for network interfaces.
# See udev(7) for syntax.
#
# Entries are automatically added by the 75-persistent-net-generator.rules
# file; however you are also free to add your own entries.

# PCI device 0x10de:0x03ef (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:66:51:42:83", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="20:cf:30:79:a4:95", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="90:e6:ba:30:fb:0c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

 

Remove the two entries at the top and then change the last entry where it says "eth2" to "eth0" and reboot your computer. 

I thought restarting udevd and network/networking would enable it on the fly but it doesn't, I believe this is because Linux assigns a static device name at boot time only.

 


Tags:

eth, itif, servers, ll, etc, server, dual, quad, nics, udevd, assigns, tot, nic, encounters, eg, ifconfig, encap, ethernet, hwaddr, fb, inet, addr, bcast, fe, baff, scope, broadcast, multicast, mtu, metric, rx, packets, errors, overruns, tx, carrier, collisions, txqueuelen, bytes, gb, xa, vi, udev, persistent, maintains, interfaces, syntax, entries, automatically, generator, pci, ef, forcedeth, subsystem, quot, drivers, attr, kernel, ec, cf, entry, reboot, restarting, networking, enable, doesn, linux, static,

Latest Articles

  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist