I have this config on Ubuntu 20.04.3 LTS server:
# nmcli con show
NAME UUID TYPE DEVICE
ethernet-enp0s31f6 ecccc29f-bd3f-4bbf-82ce-b1d1978576a1 ethernet enp0s31f6
l2tp-testnet 3be6e607-60f4-4ae3-a703-07ab7c360d10 vpn --
- My problem is the following. When the system boots up and the ethernet connection is established, then it automatically connects the L2TP connection.
- If ethernet is disconnected, and reconnected after a while, then L2TP is also reconnected.
- However, if the L2TP connection is disconnected from the server side, then it is never reconnected.
The documentation is here: https://developer-old.gnome.org/NetworkManager/stable/settings-connection.html and as far as I can tell, my configuration is correct:
- the
autoconnect-slaves
option is not effective, because VPN connections are not "slaves" but "secondaries"
- the
autoconnect
option cannot be used for VPN connections (the documentation clearly states this)
- the
secondaries
option is already set (see full config below)
- the
autoconnect-retries
is already set to zero (and it means forever) for both ethernet and L2TP
What should I change if I want it to auto-reconnect forever unconditionally? For example, after the server side has closed the connection, and maybe its address has changed etc.
The trivial answer is to write a bash script that does that, and put it into a cron job. But there must be a better way! NetworkManager already has options to auto-reconnect. I believe I'm just missing the right options.
Details below.
Ethernet connection config:
[connection]
id=ethernet-enp0s31f6
uuid=ecccc29f-bd3f-4bbf-82ce-b1d1978576a1
type=ethernet
autoconnect-priority=10
autoconnect-retries=0
interface-name=enp0s31f6
permissions=
secondaries=3be6e607-60f4-4ae3-a703-07ab7c360d10;
timestamp=1639241162
[ethernet]
mac-address-blacklist=
[ipv4]
dns-search=
method=auto
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
[proxy]
L2TP connection config:
[connection]
id=l2tp-testnet
uuid=3be6e607-60f4-4ae3-a703-07ab7c360d10
type=vpn
autoconnect-retries=0
permissions=
timestamp=1637757281
[vpn]
gateway=ddns.my.server.not.telling
ipsec-enabled=yes
ipsec-esp=aes256-sha1,aes128-sha1
ipsec-ike=aes256-sha2_256-modp2048,aes256-sha2_256-modp1536,aes256-sha2_256-modp1024,aes256-sha1-modp2048,aes256-sha1-modp1536,aes256-sha1-modp1024
ipsec-psk=not_telling
lcp-echo-failure=5
lcp-echo-interval=30
mru=1400
mtu=1400
password-flags=0
refuse-chap=yes
refuse-eap=yes
refuse-mschap=yes
refuse-pap=yes
user=my_user_name
persistent=true
service-type=org.freedesktop.NetworkManager.l2tp
[vpn-secrets]
password=not_telling
[ipv4]
dns=192.168.88.254;
dns-search=testnet;88.168.192.in-addr.arpa;88.10.in-addr.arpa;
ignore-auto-dns=true
ignore-auto-routes=true
method=auto
never-default=true
route1=192.168.88.0/24,192.168.88.254,2
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
ip6-privacy=0
method=disabled
[proxy]