Score:0

Network Manager settings not sticking after reboot

tm flag

I'm attempting to automatically establish a VPN connection after reboot. I created the profile via the network manager GUI and everything works well. I can use nm-connection-editor to edit the ethernet (and wifi) config to check the "Automatically connect to VPN." If I restart either interface (wlan0 or eth0), the VPN connection will be established.

When I reboot, however, the VPN connection is not established over eth0. When I re-run nm-connection-editor, the auto connect to VPN box is now unchecked. If I re-check it and restart the interface, the VPN is once again automatically established. Rebooting again reverts the setting. Each time I check that box after rebooting, a NEW config file is generated in /etc/NetworkManager/system-connections. It starts with netplan-eth0, then netplan- and gets a 1-up number with each new save.

netplan-eth0-626dd384-8b3d-3690-9511-192b2c79b3fd-1.nmconnection
netplan-eth0-626dd384-8b3d-3690-9511-192b2c79b3fd.nmconnection
netplan-eth0.nmconnection

The wireless connection actually works flawlessly. If I disable the wired connection and use only wifi, the VPN is established immediately upon rebooting.

All of my troubleshooting of netplan and all the options in NetworkManager have come up empty. I'm trying to set up a raspi to send to a relative and want it to establish a vpn connection by just plugging it in to ethernet, so I need it to work with the wired connection. Any help is appreciated.

Below is a paste of netplan-eth0.nmconnection. Note that it is the "secondaries" option that ties the VPN to this interface. If I had to guess, NetworkManager is ignoring this config for eth0 after rebooting.

[connection]
id=netplan-eth0
uuid=626dd384-8b3d-3690-9511-192b2c79b3fd
type=ethernet
interface-name=eth0
metered=2
permissions=
secondaries=f3f0c99a-c2c5-47fd-9bce-9104f3665dfc;
timestamp=1638470039

[ethernet]
mac-address-blacklist=
wake-on-lan=0

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=eui64
dns-search=
method=ignore
Score:0
tm flag

After much troubleshooting and reading about netplan, I've solved this problem. The Raspberry Pi distro of Ubuntu includes the file /etc/netplan/10-rpi-ethernet-eth0.yaml. The code for this file:

network:
  ethernets:
    eth0:
      # Rename the built-in ethernet device to "eth0"
      set-name: eth0
      dhcp4: true
      optional: true

What I assume happens every reboot is that the NetworkManager regenerates a new eth0 config because the internal one is being renamed. This was made clear when I changed the default name of the eth0 connection, which was "netplan-eth0" in the "nmcli connection show" list. I renamed it to just "eth0" with all of the properties I wanted (including the "secondaries" for the VPN connection), but when I rebooted it reverted back to a generic name: "netplan-eth0" with all of the default options.

Simply removing "10-rpi-ethernet-eth0.yaml" file fixed the problem. I haven't experienced any side effects yet. Maybe this file is only important the first time you boot up before NetworkManager knows anything about the device.

Now when I boot, the VPN connection is automatically established if eth0 achieves connection.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.