35

I decided to do a clean install of 15.10, and as a result, need to reinstall MATLAB. MATLAB licenses are tied to the the eth0 hardware address.

My Ethernet card is listed as enp1s0, and I need to rename it to eth0. only lo is listed in /etc/network/interfaces, and /etc/udev/rules.d/70-persistent-net.rules does not exist, so I'm unsure where to start.

4
  • 1
    You can define a udev rule to rename the interface as eth0..lets say the MAC address of the interface is xx:XX:xx:YY:yy:ZZ then you can create a file in /etc/udev/rules.d/ e.g. 99-rename-net.rules and put SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:XX:xx:YY:yy:ZZ", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" in the file..if you don't know the MAC address then you can get it from /sys/class/net/enp1so/address file..
    – heemayl
    Oct 24, 2015 at 22:35
  • @heemayl if you added that comment as an answer, then people could comment on it more easily and discuss why it seems to work for some people and not for others. Hugs! Mar 22, 2016 at 20:20
  • @heemayl's answer in the comment above did not work for me, on a fresh Ubuntu 15.10 install. Mar 22, 2016 at 20:30
  • In the above, @jdnz suggested using systemd's .link files, but some others suggested that this did not work for them. It most likely did not work because after editing the link files the initramfs must be updated. So, follow @jndz's answer first, and then follow the answer I linked above.
    – pinjaliina
    Dec 18, 2018 at 17:49

5 Answers 5

29

My solution to this was to create a file /etc/udev/rules.d/10-rename-network.rules with the content:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ff:ff:ff:ff:ff", NAME="eth0"
5
  • 1
    This DID work for me on Ubuntu 15.10 (unlike higher-voted answers and comments on the question) Mar 22, 2016 at 20:35
  • 1
    @steve-mohan This is the right answer and should be marked as correct.
    – Hubro
    Apr 1, 2016 at 18:38
  • 5
    This works indeed as of 16.04.
    – EnzoR
    Jun 16, 2016 at 9:29
  • Since this is the top answer -- just want to note what actually worked for me .. had to change a grub config and regenerate the boot command so to disable renaming of the network interfaces as described here: itzgeek.com/how-tos/mini-howtos/…
    – qodeninja
    Jan 6, 2018 at 23:03
  • 1
    Worked for me in 16.04. ff:ff:ff:ff:ff:ff needed to be replaced with the MAC address. Mar 16, 2018 at 2:08
10

I had the same problem and adding files to /etc/udev/rules.d/ did not help. The issue seems to be in the use of Predictable Network Interface Names as described here. To create your own manual naming scheme, i.e., to name your device "eth0" for MATLAB, you can create your own .link files in /etc/systemd/network/ as described here.

Specifically, I created a file /etc/systemd/network/10-eth.link with the contents

[Match]
MACAddress=ff:ff:ff:ff:ff:ff
[Link]
Name=eth0

replacing ff:ff:ff:ff:ff:ff with the MAC address of the device I wanted to change. After reboot the name was as desired.

4
  • 1
    This didn't work for me, and I would love to know why.
    – richvdh
    Feb 18, 2016 at 1:38
  • 1
    This didn't work for me on Ubuntu 15.10 Mar 22, 2016 at 20:22
  • 1
    This won't work as of 16.04.
    – EnzoR
    Jun 16, 2016 at 9:26
  • This worked for me on SLES 15 with nmcli. May 14, 2020 at 20:19
6

If for any reason answer suggested by @zab doesnt work for you, you can also disable this naming scheme like it made here. But the method proposed by @zab is potentially safer

I just did not include biosdevname=0 to command line argument, it seems to be turned off by default.

Following steps schould be made:

$ sudo nano /etc/default/grub

At the line GRUB_CMDLINE_LINUX add net.ifnames=0

GRUB_CMDLINE_LINUX="[previous parameters] net.ifnames=0"

Then generate new grub file:

$ sudo grub-mkconfig -o /boot/grub/grub.cfg

At the end reboot system.

4
  • 1
    Could you please elaborate so that this answer will still be useful if that link is not available in the future?
    – Zanna
    Sep 14, 2016 at 12:01
  • @Zanna That's done Sep 15, 2016 at 12:42
  • 2
    After countless attempts at everything on the entire internet, this is what fixed ethernet for me. My situation (for Google Searches in the future) was no ethernet after installing Linux Mint (or Ubuntu) via Serva / PXE because the stupid network adapter uses predictable network interface name instead of eth0. The instructions were found here: itzgeek.com/how-tos/mini-howtos/… May 19, 2017 at 1:33
  • As of today (with all updates installed) this works. Thank you.
    – Erutan409
    Aug 9, 2017 at 15:04
3

I had this issue running 16.04 Server (minimal) on a raspberry pi 3 and none of the posted answers helped. What solved the problem was disabling Predictable Network Interface Names as descripbed here: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

by running this command:

ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
1
  • This is the definitive way to revert to the old behavior, but the other solutions here will allow better control over which exact interface has what name, as opposed to letting the numbering change e.g. when your laptop is docked vs undocked.
    – Adam Katz
    Mar 23, 2020 at 14:59
2

This worked for me on 16.04 server as eno1 was showing when I did ifconfig -a. I had to bring up the interface as ifconfig eno1 up then I did the following:

vi /etc/udev/rules.d/10-network.rules

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ff:ff:ff:ff:ff", NAME="eth0"
2
  • Does this change the name immediately, or only after a reboot?
    – Xen2050
    Apr 15, 2017 at 20:41
  • This last item, 10-network.rules is what worked for me using Ubuntu-18 on Mac Parallels VM, otherwise I had an "enp0s5" name for ETH0 Jan 9, 2022 at 1:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .