37

My new RPi 3 device (yay) recently booted up with a deactivated ethernet.

So i watched /etc/networks/interfaces and saw the line:

auto eth0
iface eth0 inet dhcp

Calling ifup eth0 unfortunately gave the following message:

eth0 No such device
No hardware found

So i checked my ifconfig -a and saw a strange device:

enx*MACADDRESS* Link encap:Ethernet HWaddr **:**:**:**:**:**

Trying to change /etc/networks/interfaces to the name resulted in a working network. How can i change that device name back to eth0?

PS: i don't have any 70-persistent-net.rules file fyi. OS is Ubuntu MATE 15.10

Thanks.

Tom Siwik
  • 473
  • 1
  • 4
  • 6

15 Answers15

29

raspi-config is easiest method.

If you are on Raspbian then it's installed by default. But if you are on Ubuntu, Mint or Mate then you can install it with command below:

sudo apt-get install raspi-config

Then you can do configure it with raspi-config.

sudo raspi-config
  1. Select "2. Network options"
  2. Select "N3 Network interface names"
  3. Select "No". It's now disabled predictable network interface names.
  4. Click "OK" and "Finish". Then it will reboot your raspberry pi.

Done.

Almas
  • 491
  • 5
  • 5
26

This solution only works if you're seeing an odd network interface device like env{hwdaddress} when running $ ifconfig -a instead of eth0. I tried all the common answers about adding rules but only this fix worked.

I'm running a Raspberry Pi 3 with Ubuntu 16.04 preinstalled server armhf. Long story short, running $ apt-get update added Predictable Network Interface Names

Edit the following file:

$ vim /lib/udev/rules.d/73-usb-net-by-mac.rules

You should see:

ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", NAME=="", \
ATTR{address}=="?[014589cd]:*", \
TEST!="/etc/udev/rules.d/80-net-setup-link.rules", \
IMPORT{builtin}="net_id", NAME="$env{ID_NET_NAME_MAC}"

Change the NAME at the end as follows:

ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", NAME=="", \
ATTR{address}=="?[014589cd]:*", \
TEST!="/etc/udev/rules.d/80-net-setup-link.rules", \
IMPORT{builtin}="net_id", NAME="eth0"

Save Changes

Reboot. Everything should be working now assuming everything is pointing to eth0.

Edit (10/26/2016) To prevent any future updates from overwriting this fix, do the following:

cp /lib/udev/rules.d/73-usb-net-by-mac.rules /etc/udev/rules.d/
Luis Godinez
  • 404
  • 1
  • 4
  • 4
18

I did have this issue when running Debian armhf on Raspberry Pi 2, you can change the interface name by create file /etc/udev/rules.d/70-persistent-net.rules and put this in

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b8:ac:6f:65:31:e5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

replace b8:ac:6f:65:31:e5 with your eth0 MAC address, reboot and it will become eth0, you may not have internet access after reboot because in /etc/network/interfaces is defining wrong interface, just change enx* to eth0

Edit: This is not an issue but a new interface naming scheme "Predictable Interface Names", you should adapt and using this instead of try to revert it to the old ones.

minhng99
  • 310
  • 1
  • 10
12

This is NOT a "bug" it is a "feature" "consistent network device naming". (I don't see anything consistent about it.)

There are probably many ways of "fixing" this, but they may not work if the hardware is changed.

To restore previous behaviour add net.ifnames=0 biosdevname=0 to the end of cmdline.txt.

Milliways
  • 62,573
  • 32
  • 113
  • 225
4

I haven't encountered it specifically with the mac address as part of the name, however what you're experiencing is called consistent network device naming.

This was a change made because it's possible, and maybe even probable on some systems that have multiple network cards that the cards would come up out of order and using the eth0, eth1, etc. naming scheme you would end up applying routing rules and whatnot to the wrong interface.

Many Linux distributions have moved to some sort of consistent network device naming, typically it will look something like enp0s1, identifying the PCI bus and the attachment point to the bus (0 and 1 respectively).

You can get more information from https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ch-Consistent_Network_Device_Naming.html, as well as how to change your system to the old way of doing things if you still want to do so.

Ficertyn
  • 171
  • 6
4

I had the same issue for Ubuntu Server 16.04 running in Raspberry Pi 2 and this (see link below) helped me solve the problem

https://bugs.launchpad.net/ubuntu-pi-flavour-maker/+bug/1585335

goutam
  • 41
  • 1
2

Simple:

sudo ln -s /dev/null /etc/systemd/network/99-default.link

and sudo reboot.

Source: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

1

For those now encountering this problem with the Raspberry Pi OS Bullseye, 73-usb-net-by-mac.rules no longer exists, at least for me, so I just edited /etc/udev/rules.d/80-net-setup-link.rules and much like the other comments, changed the final NAME listing from NAME="$env{ID_NET_NAME}" to NAME="eth0" and that did the trick.

Greenonline
  • 2,969
  • 5
  • 27
  • 38
1

With odroid creating this file fixed my problem

root@odroid:~# cat /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth0", NAME="eth0"
1

I had the same issue on Raspberry Pi 2 with Ubuntu 16.04 and what worked was following the link from #goutam and adding /etc/udev/rules.d/70-persistent-net.rules with the following:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth0", NAME="eth0"
Rodrigo
  • 11
  • 1
1

I found this suggestion here:

Change one line in the 70-persistent-net.rules to

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="98:90:96:e0:3c:e9", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME:="eth0"

which is dropping the KERNEL attribute and changing the NAME from = to :=

It seems to force whatever MAC address is found to eth0. Works on Raspberry Pi and uboot booting systems.

user855443
  • 119
  • 1
  • 5
1

Simply deactivate the udev rules responsible for the interface renaming process, i.e.

sudo ln -s /dev/null /etc/udev/rules.d/73-usb-net-by-mac.rules

or

sudo touch /etc/udev/rules.d/73-usb-net-by-mac.rules
Greenonline
  • 2,969
  • 5
  • 27
  • 38
1

I realize that this question is old but I have hit this problem and none of the proposed solutions thus far on this page solved my issue. For me the rules.d folder trick doesn't seem to do anything.

My solution was to simply write a script that goes in the init.d folder to assign DHCP to the wired ethernet port regardless of the name. This is important because I have several Raspberry Pi units and they all came down with this same issue. (very frustrating)

My issue is compounded because I have a network storage folder that needs to be mounted during the boot process. Because the interface didn't come up, this mount failed and things just went from bad to worse for me.

Here is my solution. I hope this will help anyone else that can't find join using the above answers.

Create the file /etc/init.d/raspi-init-network using your favorite text editor. I like to use vi.

cd /etc/init.d
sudo vi raspi-init-network

This is the code that belongs in the file

#!/bin/sh
### BEGIN INIT INFO
# Provides:          boot-identify-myself
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: identify-myself
# Description:       identify this computer to the main server upon
### END INIT INFO
#
# when using predictible network names for the interfaces,
# the pi doesn't seem to activate the interface correctly so
# this script will force the issue.
#
# it works by getting the interface name of the wired network
# device and using that to initialize dhcp

start() 
{
    interface=`ifconfig -a | grep "encap:Ethernet" | grep -oh -E "^[^ ]+"`
    dhclient $interface
    mount -a
}

stop() 
{
    : # do nothing
}

uninstall() 
{
    : # do nothing
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  uninstall)
    uninstall
    ;;
  retart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|uninstall}"
esac

Make sure the script is executible

sudo chmod 755 raspi-init-network

Activate the code so it will execute during the boot process by executing the update-rc.d command.

sudo update-rc.d raspi-init-network defaults 90

After this, I have not had a single issue and I was able to copy the code to all of my Pi units with the same steady results.

NOTE: If you are not mounting drives, you can leave out the "mount -a" line.

TWEAKS: If you are using your wifi you can change the line that starts out "interface=" and edit the first "grep" segment. This first grep grabs the entire line of the interface you wish to use. The second grep takes that line and only returns the interface name.

0

This is a simple fix

  1. Create a new file as follows
    sudo vim /etc/udev/rules.d/10-network-device.rules

  2. Place this text inside this file, using your device MAC address
    SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="eth0"

  3. reboot

  4. ifconfig should now show your network interface as eth0 not enxaabbccddeeff (enx+MAC address)

Kes
  • 101
  • 2
0

For me, running Debian Unstable on the Raspberry Pi 2, the symlink mentioned in the comment to the first answer was the right idea, too, but its name had to be different: ln -vis /dev/null /etc/udev/rules.d/80-net-setup-link.rules

Axel Beckert
  • 1,240
  • 14
  • 27