nm-l2tp / NetworkManager-l2tp

L2TP and L2TP/IPsec support for NetworkManager
GNU General Public License v2.0
486 stars 83 forks source link

[openSUSE] resolv.conf not updated after disconnect #162

Closed dmelikhov closed 3 years ago

dmelikhov commented 3 years ago

While I'm only connected to my home network, my /etc/resolv.conf looks like this: (1)

### /etc/resolv.conf is a symlink to /var/run/netconfig/resolv.conf
### autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/network/config file:
#     NETCONFIG_DNS_STATIC_SEARCHLIST
#     NETCONFIG_DNS_STATIC_SERVERS
#     NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
#     NETCONFIG_DNS_POLICY=''
#
# See also the netconfig(8) manual page and other documentation.
#
### Call "netconfig update -f" to force adjusting of /etc/resolv.conf.
nameserver 1.1.1.1

After I connect to my company's L2TP/IPsec VPN: (2)

# ...
### Call "netconfig update -f" to force adjusting of /etc/resolv.conf.
nameserver 10.x.x.x
nameserver 8.8.8.8
nameserver 1.1.1.1

And when I disconnect the VPN I expect resolv.conf to be (1) again, but it is still (2).

OS: openSUSE Leap 15.2, openSUSE Tumbleweed NetworkManager-l2tp: 1.8.0, 1.8.6

Workaround: sudo netconfig update -f

dkosovic commented 3 years ago

in /etc/ppp/netconfig after the following lines :

###
### remove comment chars to trace this script:
###
exec &>/tmp/${ACTION//\//-}.$$.trace
set -x
echo 1>&2 "$0: $@"
env  1>&2

I added the following lines :

case "$6" in
  nm-*-service-*|/org/freedesktop/NetworkManager/PPP/*)
        # NetworkManager handles it
        exit 0
        ;;
esac

but I also had to reboot as netconfig was still doing weird things until the reboot.

The script changes are based on what is in Ubuntu's /etc/ppp/ip-up.d/000resolvconf and /etc/ppp/ip-down.d/000resolvconf.

Basically the issue is that pppd shouldn't be touching /etc/resolv.conf if NetworkManager is being used.

dkosovic commented 3 years ago

/etc/ppp/netconfig is part of the openSUSE sysconfig source and the sysconfig-netconfig RPM. I've opened a pull request with the fix.

dkosovic commented 3 years ago

My pull request for the /etc/ppp/netconfig modification was rejected as it was not the correct way to do it.

See following openSUSE sysconfig issue for more details and a NETCONFIG_DNS_POLICY workaround :

dmelikhov commented 3 years ago

I've applied the workaround, many thanks for the investigation you did!