How to make NetworkManager use `/etc` configs and where `/run` connections come from?
1
vote
2
answers
503
views
I have a Petalinux board (a Trenz Electronic with an AMD/Xilinx Zynq UltraScale+ MPSoC) which boots up with a wrong network connection config (no DHCP). It has no configs in
/etc
:
$ ls /etc/NetworkManager/system-connections/
$
After configuring the connection with sudo nmcli con mod eth0 ...
it works fine. (I modify the ipv4 and ipv6 config, like [here on stackoverflow](https://stackoverflow.com/questions/60654764/switch-from-static-ip-to-dhcp-using-nmcli/60668424#60668424).) And it creates a permanent config file in /etc
:
/etc/NetworkManager/system-connections/eth0.nmconnection
But, after a reboot NetworkManager creates a new /run
config, which somehow takes precedence over my connection in /etc
:
$ nmcli -f TYPE,FILENAME,UUID,NAME,DEVICE connection
TYPE FILENAME UUID NAME DEVICE
ethernet /run/NetworkManager/system-connections/eth0.nmconnection 99e39a32-c0ab-4b3f-be16-75a9bdff1277 eth0 eth0
loopback /run/NetworkManager/system-connections/lo.nmconnection 5d84c484-4214-47e4-8f00-01f7730200b3 lo lo
ethernet /etc/NetworkManager/system-connections/eth0.nmconnection fb365147-6ad9-47a0-a5c8-fbea10080ece eth0 --
Here, the rogue 99e39a32
from /run
got connected to the eth0
device, and my /etc
connection config fb365147
stays idle.
How to correctly and permanently save a connection config in NetworkManager, or make it use /etc
config as the only template for the eth0
connection? Where does it even get the configs for /run
? How come it does not use /etc
to create /run
configs?
There are posts saying the NetworkManager creates connections per user. I.e. the suggestion was something like /etc
is root and somehow other connections get used for my user. But I don't think that's the case here. nmcli
does not let me modify a connection without root permissions.
There is a number of similar questions on the internet: (https://unix.stackexchange.com/questions/501260/where-does-network-manager-store-settings) (I don't have /etc/netplan
file which is mentioned in a comment there), (https://stackoverflow.com/questions/77558991/how-to-stop-network-manager-creating-connections-under-run-networkmanager-syste) , (https://superuser.com/questions/1404124/how-do-i-make-persistent-changes-with-nmcli-in-non-interactive-mode) . But they don't help in my case.
**Update:**
There is some info how the /run
config comes about thanks to the log journalctl -u NetworkManager
after booting the computer with [loggin] level=TRACE
in /etc/NetworkManager/NetworkManager.conf
:
NetworkManager: [1734374462.9312] device (eth0): carrier: link connected
NetworkManager: [1734374462.9313] ethtool: ETHTOOL_GSET, eth0: success
NetworkManager: [1734374462.9317] device[e5c0e28febbc1b13] (eth0): unmanaged: flags set to [platform-init,!user-settings=0x4/0x14/unmanaged/unrealized], set-managed [user-settings=0x10])
NetworkManager: [1734374462.9318] device[e5c0e28febbc1b13] (eth0): unmanaged: flags set to [!platform-init,!user-settings=0x0/0x14/managed/unrealized], set-managed [platform-init=0x4])
NetworkManager: [1734374462.9318] device[e5c0e28febbc1b13] (eth0): unmanaged: flags set to [!sleeping,!platform-init,!user-settings=0x0/0x15/managed/unrealized], set-managed [sleeping=0x1])
NetworkManager: [1734374462.9319] dbus-object[e5c0e28febbc1b13]: export: "/org/freedesktop/NetworkManager/Devices/2"
NetworkManager: [1734374462.9329] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
NetworkManager: [1734374462.9349] settings: auto-default: cannot create auto-default connection for device eth0: already has a profile
[1734374462.9356] Connection 'eth0' differs from candidate 'eth0' in ipv4.addresses, ipv4.gateway, ipv4.method
NetworkManager: [1734374462.9357] manager: (eth0): assume: generated connection 'eth0' (b807ebb2-d7a5-4b26-82c1-c321a6e7d5ba)
NetworkManager: [1734374462.9357] device[e5c0e28febbc1b13] (eth0): assume-state: set guess-assume=0, connection=(null)
NetworkManager: [1734374462.9370] keyfile: commit: b807ebb2-d7a5-4b26-82c1-c321a6e7d5ba (eth0) added as "/run/NetworkManager/system-connections/eth0.nmconnection" (nm-generated,volatile,external)
I guess the question now is what it means by Connection 'eth0' differs from candidate 'eth0' ...
- what is that candidate? I.e. probably there is some more config for the eth0
device itself, and when the /etc
config conflicts with that one, NetworkManager creates a new one?
I tried adding this file with no change in the behavior (it's probably deprecated):
$ cat /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
**Update 2:**
Just to point out, I have tried adding no-auto-default
config, but it made no difference in this case:
/etc/NetworkManager/NetworkManager.conf
[main]
no-auto-default=*
# or no-auto-default=eth0
And adding the connection in /etc/network/interfaces
also did not help:
# Wired interfaces
auto eth0
iface eth0 inet dhcp
hwaddress ether
I think, as @telcoM suggested, it is a Petalinux-specific behavior. You define the settings for the eth0 device when the image is built (and apparently NetworkManager can somehow read settings from the device or what?), and [you cannot modify ethernet settings in Petalinux after the image has been built](https://adaptivesupport.amd.com/s/question/0D54U000089gXtiSAE/how-can-i-change-the-network-ip-address-in-the-running-petalinux-on-zynq-mpsoc?language=en_US) . Probably, there is nothing that you can modify in uboot ZynqMP>
console either.
So, what I ended up doing is: [rename my connection](https://wrightrocket.blogspot.com/2018/11/network-manager-nmcli.html) to eth0dhcp
and add a systemd unit that connects it after the boot.
sudo nmcli c mod fb365147-6ad9-47a0-a5c8-fbea10080ece con-name eth0dhcp
The connection config looks like:
$ sudo cat /etc/NetworkManager/system-connections/eth0.nmconnection
[connection]
id=eth0dhcp
uuid=fb365147-6ad9-47a0-a5c8-fbea10080ece
type=ethernet
autoconnect=false
interface-name=eth0
timestamp=1734377647
[ethernet]
mac-address=
[ipv4]
method=auto
[ipv6]
addr-gen-mode=default
method=auto
[proxy]
And the one-shot systemd unit:
[Unit]
Description=UP the eth0dhcp for eth0 after boot
After=network.target
Requires=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
ExecStart=nmcli con up eth0dhcp
SuccessExitStatus=0
Restart=on-failure
RestartSec=20
StartLimitInterval=300
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
It's enough of a workaround in my case. Later we'll just build images with whatever settings that are needed.
Asked by xealits
(2267 rep)
Dec 16, 2024, 04:26 PM
Last activity: Dec 17, 2024, 01:16 PM
Last activity: Dec 17, 2024, 01:16 PM