5

I'm aware that in older versions of linux I was able to rename the network interface from /etc/udev/rules.d/70-persistent-net.rules, however this file is missing in Ubuntu 16.04.

  • This is an OK enough place to ask this question, but I would really recommend asking Ubuntu-specific questions at AskUbuntu (askubuntu.com). Usually the response times are better there too. – BH2017 Dec 6 '16 at 20:24
  • I have faith in this forum :P – joebegborg07 Dec 6 '16 at 20:40
2

Create the /etc/udev/rules.d/70-persistent-net.rules file as follows :

sudo nano /etc/udev/rules.d/70-persistent-net.rules

add the following line:

# PCI device 0x10ec:0x8xxxx (ethernet_module_here)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="3x:17:ef:6f:s2:2h", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x168c:0xyyy (wifi_module_here)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="74:e5:ii:uu:de:nn", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

Run sudo ifconfig to get the mac adress and change it with yours here :ATTR{address}=="74:e5:ii:uu:de:nn"

CtrlO then press Enter exit with CtrlX

Disable the Predictable Network Interface Names with:

ln -sf /dev/null /lib/udev/rules.d/80-net-setup-link.rules

This will overwrite the existing file, so, optionally, back it up before executing the command.

Bring up your interface:

ip link set eth0 up
ip link set eth0 down

Alternative methode:

Edit your grub configuration file:

sudo nano /etc/default/grub

add net.ifnames=0 biosdevname=0 to GRUB_CMDLINE_LINUX="" like this:

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

update grub.cfg :sudo grub-mkconfig -o /boot/grub/grub.cfg

Edit your /etc/network/interfaces to change interface name then reboot.

  • Thanks for your reply @GAD3R. The udev rules seem to have been moved to /lib/udev/rules.d/ with newer Ubuntu version, however the 70-persistent-net.rule is still not there. – joebegborg07 Dec 6 '16 at 20:40
  • 1
    I think ln -s should be changed to ln -sf, otherwise, the existing file won't be overwritten. – Marcus Apr 13 '18 at 10:07
  • the proposed method isn't a good option on machines with lots of interfaces. Please be aware that you should have an entry for every interface and unfortunately, in newer versions of Ubuntu, there isn't an easy way to generate the /etc/udev/rules.de/70-persistent-net.rules file. You need to do it by hand and be super careful otherwise you might need to change it by hand connecting directly to the Linux machine. – Georgе Stoyanov Jul 15 at 13:33
1

For me it worked modifying /etc/udev/rules.d/70-persistent-net.rules. However I had to remove the kernel from that line.

Eg:

# PCI device 0x10ec:0x8xxxx (ethernet_module_here)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="3x:17:ef:6f:s2:2h", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth0"

# PCI device 0x168c:0xyyy (wifi_module_here)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="74:e5:ii:uu:de:nn", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="wlan0"

I am on Ubuntu 16.04

1

For people new to this or struggling with it, GAD3R's answer is correct, however if you're following the first method it is worth noting the following two points:

  1. /etc/udev/rules.d/70-persistent-net.rules may not actually exist (in which case you need to create it).

  2. If /lib/udev/rules.d/80-net-setup-link.rules DOES exist, you will get an error message indicating as such when trying to use the "ln -s" command and will need to rename it before setting a symbolic link to /dev/null (for complete beginners: "it's a safer option than deleting").

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.