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

  • How to install Windows or other OS and then bring to another computer by using a physical drive and Virtual Machine with QEMU
  • PXE-E23 Error BOOTx64.EFI GRUB booting is 0 bytes tftp pxe dhcp solution NBP filesize is 0 Bytes
  • vagrant install on Debian Mint Ubuntu Linux RHEL Quick Setup Guide Tutorial
  • RHEL 8 CentOS 8, Alma Linux 8, Rocky Linux 8 System Not Booting with RAID or on other servers/computers Solution for dracut and initramfs missing kernel modules
  • How to Upgrade to Debian 11 from Version 8,9,10
  • Ubuntu Linux Mint Debian Redhat Cannot View Files on Android iPhone USB File Transfer Not Working Solution
  • Virtualbox Best Networking Mode In Lab/Work Environment without using NAT Network or Bridged
  • debootstrap how to install Ubuntu, Mint, Debian install
  • Linux grub not using UUID for the root device instead it uses /dev/sda1 or other device name solution
  • How To Restore Partition Table on Running Linux Mint Ubuntu Debian Machine
  • Debian Ubuntu apt install stop daemon questions/accept the default action without prompting
  • iptables NAT how to enable PPTP in newer Debian/Ubuntu/Mint Kernels Linux
  • Grandstream Phone Vulnerability Security Issue Remote Backdoor Connection to 207.246.119.209:3478
  • Linux How to Check Which NIC is Onboard eth0 or eth1 Ubuntu Centos Debian Mint
  • VboxManage VirtualBox NAT Network Issues Managment Troubleshooting
  • Dell PowerEdge Server iDRAC Remote KVM/IP Default Username, Password Reset and Login Information Solution
  • Nvidia Tesla GPUs K40/K80/M40/P40/P100/V100 at home/desktop hacking, cooling, powering, cable solutions Tutorial AIO Solutions
  • Stop ls in Linux Debian Mint CentOS Ubuntu from applying quotes around filenames and directory names
  • Thunderbird Attachment Download Error Corrupt Wrong filesize of 29 or 27 bytes Solution
  • Generic IP Camera LAN Default IP Settings DVR