34

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.

  • 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 '15 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! – Jonathan Hartley Mar 22 '16 at 20:20
  • @heemayl's answer in the comment above did not work for me, on a fresh Ubuntu 15.10 install. – Jonathan Hartley Mar 22 '16 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. – Pinja-Liina Jalkanen Dec 18 '18 at 17:49
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"
  • 1
    This DID work for me on Ubuntu 15.10 (unlike higher-voted answers and comments on the question) – Jonathan Hartley Mar 22 '16 at 20:35
  • 1
    @steve-mohan This is the right answer and should be marked as correct. – Hubro Apr 1 '16 at 18:38
  • 5
    This works indeed as of 16.04. – EnzoR Jun 16 '16 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 '18 at 23:03
  • 1
    Worked for me in 16.04. ff:ff:ff:ff:ff:ff needed to be replaced with the MAC address. – Ken Shirriff Mar 16 '18 at 2:08
7

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.

  • This didn't work for me, and I would love to know why. – richvdh Feb 18 '16 at 1:38
  • This didn't work for me on Ubuntu 15.10 – Jonathan Hartley Mar 22 '16 at 20:22
  • This won't work as of 16.04. – EnzoR Jun 16 '16 at 9:26
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.

  • 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 '16 at 12:01
  • @Zanna That's done – Dmitriy Kozlov Sep 15 '16 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/… – ThePCpenguin May 19 '17 at 1:33
  • As of today (with all updates installed) this works. Thank you. – Erutan409 Aug 9 '17 at 15:04
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"
  • Does this change the name immediately, or only after a reboot? – Xen2050 Apr 15 '17 at 20:41
2

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

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.