1

Update - Feb 21, 2020:

I never found an elegant way make NetworkManager assign a particular MAC address to the first/only Ethernet adapter on whatever system my disk happened to boot on. I also realized I may be able to solve my particular problem by reconfiguring my DHCP server to assign IP addresses based on system names, rather than MAC addresses. I also started configuring the network on most of my systems via systemd-networkd, rather than NetworkManager or netplan. (systemd-networkd may be better, but still has flaws IMO.) Finally, I am no longer confident that my Oct 14, 2019 update is correct. In other words, a default install of Ubuntu (maybe 19.10?) may no longer include the ifupdown package.

Update - Oct 14, 2019:

(Note: As of Feb 2020, I suspect this paragraph may be incorrect and/or out of date.) This week I installed the desktop version of Ubuntu 19.04. It appears the package ifupdown is installed by default on Ubuntu 19.04. (Yay!) Therefore, this question probably only applies to Ubuntu derivatives that have chosen to exclude the ifupdown package from their default install. And the question probably does not apply to Ubuntu itself. For this and other reasons, I expect I will prefer vanilla Ubuntu over any of its derivatives on all my future installs.

Original Question - Feb 26, 2019

In the (distant?) past, I could assign a MAC address to a network interface by adding the following stanza to to /etc/network/interfaces:

auto         eth0
iface        eth0
  hwaddress  00:12:34:56:78:9a

As of Lubuntu 18.04, this no longer works (because the ifupdown package is not installed by default).

My question is, what configuration file do I edit, and how do I edit it, so that NetworkManager will assign the fixed MAC address of my choice to eth0.

(Aside: Yes, I know that by default Ubuntu 18.04 renames eth0 to a "predictable" name like enp1s0. I have already disabled that renaming, so I do indeed have an eth0 interface on my system.)

I have glanced at the following documentation:

Based on the above documentation, I tried adding something like the below to /etc/NetworkManager/NetworkManager.conf:

[device]
match-device=interface-name:eth0
ethernet.assigned-mac-address=00:22:68:1c:59:b1

Unfortunately, the above does not seem to work.

My use case is that I have installed Lubuntu onto a USB stick. Upon boot of the USB stick on any system, I want NetworkManager to assign a predetermined and fixed MAC address to eth0.

  • as far as i know 18.04 uses netplan Probably this link helps you somehow bugs.launchpad.net/netplan/+bug/1718607 and netplan.io – AlexOnLinux Feb 27 '19 at 0:03
  • The docs says about assigned-mac-address: 'Note that this property only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address".' So maybe you need cloned-mac-address="00:22:68:1c:59:b1"? – Olorin Feb 27 '19 at 2:57
  • @mpb I wonder is NetworkManager is looking for the 'predictable' interface and not eth0. – Robert Baker Feb 27 '19 at 4:54
1

TLDR:

nmcli con show

look for your DEVICE (eth0) in the last column and use the name of the connection for the following command. Example, if the connection name is "Default":

sudo nmcli con modify Default 802-3-ethernet.cloned-mac-address 00:12:34:56:78:9a

Longer Answer:

nmcli --version

NetworkManager is in continuous development and sometimes configuration parameters or their names change. Some changes are confusing.

Contrast and compare:

And:

I faced the same problem with Xubuntu 18.04. Rant against compatibility-breaking configuration changes omitted.

| improve this answer | |
0

As said, the property in keyfile format, nmcli, and NetworkManager.conf is called ethernet.cloned-mac-address. Only on D-Bus API it's called ethernet.assigned-mac-address -- that has historic reasons.

Usually you would set this per profile, for example via nmcli connection modify "$PROFILE" ethernet.cloned-mac-address 00:22:68:1c:59:b1. By editing NetworkManager.conf you specify the default value that is used if the per-profile value is unspecified. That's explained in man NetworkManager.conf.

After modifying a profile, you need to reactivate it for the changes to take effect. Likewise, if you edit the default value in NetworkManager.conf, you need to reload it with SIGHUP and reactivate the profile.

Regarding predictable interface names: NetworkManager does not (re)name the device, that's commonly done by udev. You may restrict a profile to an interface by setting connection.interface-name to the name that was given to the device. You can see that name with ip link or nmcli device. Likewise the match-device=interface-name: setting for NetworkManager.conf.

| improve this answer | |

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.