Ubuntu 16.04 - Change interface name

26,643

Solution 1

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.

Solution 2

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").

Solution 3

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

Share:
26,643

Related videos on Youtube

joebegborg07
Author by

joebegborg07

Updated on September 18, 2022

Comments

  • joebegborg07
    joebegborg07 almost 2 years

    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.

    • identify
      identify over 7 years
      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.
    • joebegborg07
      joebegborg07 over 7 years
      I have faith in this forum :P
  • joebegborg07
    joebegborg07 over 7 years
    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.