11

As my built-in NIC was not supported by Ubuntu out-of-the-box I was forced to use a USB NIC for temporary installation-time Internet connection.

And the USB NIC has taken the eth0 name making the built-in NIC to become eth1.

Sure, this doesn't really matter but just for the system "prettiness" I would like eth1 to become eth0 letting any newly attached NIC to become eth1.

Is this possible?

3 Answers 3

11

It is possible. Please do:

gksudo gedit /etc/udev/rules.d/70-persistent-net.rules 

Swap eth0 and eth1. Proofread carefully, save and close gedit. Use any other text editor if you don't have gedit. Reboot immediately and you should be all set.

5
  • 7
    ... and first make a backup of the file
    – Rinzwind
    Nov 15, 2012 at 15:55
  • 7
    Just for the record: this is correct for 14.04, but 70-persistent-net.rules no longer exists as of Ubuntu 15.10. See askubuntu.com/questions/689501 for a solution that works for Ubuntu 15.10, 16.04, and later.
    – richvdh
    Jun 17, 2016 at 9:47
  • well, it might be correct for 14.04. There's been a bit of flux in this area in recent releases.
    – richvdh
    Jun 17, 2016 at 10:09
  • You are correct. When this was posted in 2012, it was the correct procedure. This procedure, as well as many other things, has changed in 15.10 et seq.
    – chili555
    Jun 17, 2016 at 14:53
  • As of 18.04, file is named 76-netnames.rules Jul 2, 2020 at 11:50
11

This renames em1 to eth0 for me on Ubuntu 14.04:

# Note: replace xx:xx... in the rule with the MAC address of your Nic>    
$ sudo vim /etc/udev/rules.d/75-persistent-net-generator.rules

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"

# Change "em1" to "eth0" in your interfaces file.
$ sudo vim /etc/network/interfaces

$ sudo reboot

Credit: Billf's answer here: https://bbs.archlinux.org/viewtopic.php?id=156375

FYI, this was what I was originally seeing in logs:

$ sudo grep eth0 /var/log/dmesg
[    2.976463] e1000e 0000:00:19.0 eth0: registered PHC clock
[    3.003714] e1000e 0000:00:19.0 eth0: (PCI Express:2.5GT/s:Width x1) 18:03:73:e9:f2:36
[    3.031177] e1000e 0000:00:19.0 eth0: Intel(R) PRO/1000 Network Connection
[    3.058399] e1000e 0000:00:19.0 eth0: MAC: 10, PHY: 11, PBA No: E041FF-0FF
[    3.153759] systemd-udevd[167]: renamed network interface eth0 to em1

Looks like systemd-udevd was doing negative work and renaming eth0 to em1 in the first place. Not sure how to stop it from doing that, but renaming back to eth0 seems to work.

For the enthusiast who wants to know more... http://linux.dell.com/files/whitepapers/consistent_network_device_naming_in_linux.pdf

1
  • 1
    Thank you so very, very much for this. All other's seem to miss the point.
    – sjas
    Nov 6, 2014 at 15:22
0

In Ubuntu Server 16.04LTS the 70-persistent-net.rules doesn't exist and a lot of posts didn't help. After 4 hours of searching I came up with this solution, and to my shock it actually worked!

sudo ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules

Then create the file using sudo vi /etc/systemd/network/10-internet.link and add the following

[Match] Path=pci-0000:(your device mac address)

[Link] Name=eth0 (or whatever you want to name it)

:wq to save the file

then reboot and adjust your /etc/network/interfaces file.. then reboot again

Hope this helps someone

2
  • Doesn't work. And shouldn't, AFAIU.
    – jno
    Nov 18, 2016 at 14:09
  • Does not work. just tested with 16.04 lts
    – Kendrick
    Dec 16, 2017 at 21:50

You must log in to answer this question.

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