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

  • systemd-journald high memory usage solution
  • How to Install FreePBX 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
  • How to Install Any OS on a Physical Drive from Windows Using VMware Workstation (Linux, Windows, BSD)
  • CDN Cloudflare how to set and preserve the real IP of the client without modifying application code on Apache
  • CentOS 7 fix Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was 14: curl#6 -
  • Ubuntu Debian How To Install Recommended Packages Automatically
  • How to set Linux Ubuntu Redhat Debian Command Line http https socks proxy for yum apt
  • How to resize a pdf without losing much quality in Linux Mint Ubuntu Debian Redhat Solution
  • qemu: could not load PC BIOS 'bios-256k.bin' solution