extra domains not removed from resolv.conf when VPN disconnects

Bug #1717995 reported by Roland Dreier
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Fix Released
High
Dimitri John Ledkov

Bug Description

I use a VPN (network manager "vpnc" config) to connect to my work network. The gateway is "webvpn.purestorage.com". When I connect, I get "purestorage.com" added to the "search" line in my /etc/resolv.conf (and /run/resolvconf/interface/systemd-resolved) - which makes perfect sense, the VPN passes this info to me and then I can connect to systems within the work network without having to use a FQDN.

The bug (which is a regression from older versions of Ubuntu) is that when I lose my connection to the VPN (either because I disconnect explicitly, or because the network goes down or I suspend my laptop), the "purestorage.com" domain is not removed from those "search" lines. And for some reason this prevents me from resolving webvpn.purestorage.com (which prevents me from reconnecting to the VPN).

In particular, if I connect and disconnect my VPN, I get:

 $ systemd-resolve webvpn.purestorage.com
webvpn.purestorage.com: resolve call failed: No appropriate name servers or networks for name found

If I then edit /etc/resolv.conf by hand to remove all the purestorage.com entries from the search line - in other words, change

 $ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search home.digitalvampire.org purestorage.com dev.purestorage.com

to

 $ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search home.digitalvampire.org

and change nothing else, then:

 $ systemd-resolve webvpn.purestorage.com
webvpn.purestorage.com: 192.30.189.1
                        (vpn.purestorage.com)

-- Information acquired via protocol DNS in 25.9ms.
-- Data is authenticated: no

I'm not sure if the bug is in systemd, network manager, or some other package, but I'm happy to try any debugging that is helpful to resolve this (no pun intended).

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: systemd 234-2ubuntu10
ProcVersionSignature: Ubuntu 4.12.0-13.14-generic 4.12.10
Uname: Linux 4.12.0-13-generic x86_64
ApportVersion: 2.20.7-0ubuntu1
Architecture: amd64
CurrentDesktop: GNOME
Date: Mon Sep 18 11:20:17 2017
InstallationDate: Installed on 2016-09-01 (381 days ago)
InstallationMedia: Ubuntu 16.10 "Yakkety Yak" - Alpha amd64 (20160901)
MachineType: LENOVO 20FRS2FK00
ProcEnviron:
 TERM=screen
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.12.0-13-generic root=UUID=30d5ada5-835d-4cf7-96cf-3329c0316107 ro quiet splash vt.handoff=7
SourcePackage: systemd
UpgradeStatus: Upgraded to artful on 2017-07-26 (53 days ago)
dmi.bios.date: 07/13/2017
dmi.bios.vendor: LENOVO
dmi.bios.version: N1FET53W (1.27 )
dmi.board.asset.tag: Not Available
dmi.board.name: 20FRS2FK00
dmi.board.vendor: LENOVO
dmi.board.version: SDK0J40697 WIN
dmi.chassis.asset.tag: No Asset Information
dmi.chassis.type: 31
dmi.chassis.vendor: LENOVO
dmi.chassis.version: None
dmi.modalias: dmi:bvnLENOVO:bvrN1FET53W(1.27):bd07/13/2017:svnLENOVO:pn20FRS2FK00:pvrThinkPadX1Yoga1st:rvnLENOVO:rn20FRS2FK00:rvrSDK0J40697WIN:cvnLENOVO:ct31:cvrNone:
dmi.product.family: ThinkPad X1 Yoga 1st
dmi.product.name: 20FRS2FK00
dmi.product.version: ThinkPad X1 Yoga 1st
dmi.sys.vendor: LENOVO

Revision history for this message
Roland Dreier (roland.dreier) wrote :
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Could you paste the output from
$ systemd-resolved --status
when the system is in a bad state? That is, system mentions the domains in /etc/resolv.conf when it should not have.

Changed in systemd (Ubuntu):
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Dimitri John Ledkov (xnox)
Revision history for this message
Roland Dreier (roland.dreier) wrote :

 $ systemd-resolve webvpn.purestorage.com
webvpn.purestorage.com: resolve call failed: No appropriate name servers or networks for name found
 $ systemd-resolve --status
Global
          DNS Domain: home.digitalvampire.org
                      purestorage.com
                      dev.purestorage.com
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 3 (wlp4s0)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 2001:470:1f05:221::1
                      10.1.0.1
          DNS Domain: home.digitalvampire.org

Link 2 (enp0s31f6)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Revision history for this message
Roland Dreier (roland.dreier) wrote :

I wonder if the issue has anything to do with the fact that the VPN creates a new network link that disappears when the VPN goes down - note that the purestorage.com domains are listed for tun0 when the VPN is up. When I turn off the VPN, tun0 disappears but the purestorage.com domains stay in the Global part of the status output:

 $ systemd-resolve --status
Global
          DNS Domain: home.digitalvampire.org
                      purestorage.com
                      dev.purestorage.com
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 17 (tun0)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 10.231.255.252
                      10.230.255.252
          DNS Domain: purestorage.com\032dev.purestorage.com
                      purestorage.com
                      dev.purestorage.com

Link 3 (wlp4s0)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 2001:470:1f05:221::1
                      10.1.0.1
          DNS Domain: home.digitalvampire.org

Link 2 (enp0s31f6)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I believe I have a fix for this. There is a feedback loop which was not closed, with resolved re-reading /etc/resolv.conf and thus DNS domains leaking from per-link scope, into the global scope, and staying there, even when the link is dead / gone.

Changed in systemd (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Roland Dreier (roland.dreier) wrote :

Great, let me know if you want me to try anything out.

Revision history for this message
Walter Garcia-Fontes (walter-garcia) wrote :

I'm experiencing this same issue.

A workaround that works for me is to remove my vpn domain from /etc/resolv.conf. The last line of this file looks as follows after a successful VPN connection:

search Home myvpndomain

where the last term is the domain of my vpn (vpn.bla.com). The workaround is to remove it and leave:
search Home
then restart the network-manager service and the VPN reconnects.

Otherwise I have to restart the computer to be able to connect to the VPN after a successful connection. I mean: after a computer restart, VPN always connects, but if I disconnect I cannot reconnect to the VPN unless I restart the computer or do the workaround.

I have a big confusion on how /etc/resolv.conf is managed nowadays in Ubuntu. I have at least three different system processes generating a resolv.conf.

systemd-resolved:
/run/systemd/resolve/resolv.conf

network-manager:
/run/NetworkManager/resolv.conf

and resolvconf:
/run/resolvconf/resolv.conf

My actual /etc/resolv.conf is a symbolic link to this last one. At some point I tried to have only network-manager manage /etc/resolv.conf. Everything works fine, but when I connect to VPN it can't resolve any DNS outside of the private network.

The resolv.conf generated by systemd-resolved has the same problem as the one generated by resolvconf, when the VPN reconnects the VPN domain is not removed from the "search" line.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 234-2ubuntu12

---------------
systemd (234-2ubuntu12) artful; urgency=medium

  [ Dimitri John Ledkov ]
  * debian/rules: do not strip test-copy.
    This insures test-copy is large enough for test-copy tests to pass.
    (LP: #1721203)

  [ Michael Biebl ]
  * Drop systemd-timesyncd.service.d/disable-with-time-daemon.conf.
    All major NTP implementations ship a native service file nowadays with a
    Conflicts=systemd-timesyncd.service so this drop-in is no longer
    necessary. (Closes: #873185) (LP: #1721204)

 -- Dimitri John Ledkov <email address hidden> Wed, 04 Oct 2017 13:28:34 +0100

Changed in systemd (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Faron Anslow (faron-anslow) wrote :

I still have this problem. When I disconnect from a VPN, the various resolv files retain a search line and DNS lookup fails for the domain associated with the VPN (in this case, my university). Luckily, this is fairly easy to work around (I no longer reboot to try to fix my network). Did I miss something? Or has the fix been committed, but not yet propagated out into a new systemd package in the repos? The post above seems to indicate that the version 234-2ubuntu12 and above would have the fix. I have 234-2ubuntu12.2 which I presume is newer.

here's output from dpkg-query -s systemd:

fanslow@sano:~$ dpkg-query -s systemd
Package: systemd
Status: install ok installed
Priority: important
Section: admin
Installed-Size: 11704
Maintainer: Ubuntu Developers <email address hidden>
Architecture: amd64
Multi-Arch: foreign
Version: 234-2ubuntu12.2
Replaces: udev (<< 228-5)
Depends: libacl1 (>= 2.2.51-8), libapparmor1 (>= 2.9.0-3+exp2), libaudit1 (>= 1:2.2.1), libblkid1 (>= 2.19.1), libc6 (>= 2.25), libcap2 (>= 1:2.10), libcryptsetup4 (>= 2:1.4.3), libgcrypt20 (>= 1.7.0), libgpg-error0 (>= 1.14), libidn11 (>= 1.13), libip4tc0 (>= 1.6.0+snapshot20161117), libkmod2 (>= 5~), liblz4-1 (>= 0.0~r130), liblzma5 (>= 5.1.1alpha+20120614), libmount1 (>= 2.26.2), libpam0g (>= 0.99.7.1), libseccomp2 (>= 2.3.1), libselinux1 (>= 2.1.9), libsystemd0 (= 234-2ubuntu12.2), util-linux (>= 2.27.1), mount (>= 2.26), adduser, procps
Pre-Depends: libc6 (>= 2.8)
Recommends: libpam-systemd, dbus
Suggests: systemd-container, policykit-1
Breaks: apparmor (<< 2.9.2-1), ifupdown (<< 0.8.5~), laptop-mode-tools (<< 1.68~), systemd-shim (<< 10-3~), udev (<< 228-5)
Conffiles:
 /etc/dhcp/dhclient-enter-hooks.d/resolved 17323c120a8bb9f8453c24b43d900203
 /etc/dhcp/dhclient-exit-hooks.d/timesyncd a891f21f45b0648b7082d999bf424591
 /etc/pam.d/systemd-user 3d97692a0125712fcfbd7ddf756f7696
 /etc/systemd/journald.conf b89a22c219efce8b3700feafc61e0c18
 /etc/systemd/logind.conf aeeac805b4bfb7450183ce346999dd38
 /etc/systemd/resolved.conf cda783b1a7bc2e01f2268b9df3c71934
 /etc/systemd/system.conf adc308320471c75a60e07184cf2ebb05
 /etc/systemd/timesyncd.conf 4e1cf2b5f85dff6c1f186135b9f66a85
 /etc/systemd/user.conf 675370e2d80a4ad957202e68c1b4aaee
Description: system and service manager
 systemd is a system and service manager for Linux. It provides aggressive
 parallelization capabilities, uses socket and D-Bus activation for starting
 services, offers on-demand starting of daemons, keeps track of processes using
 Linux control groups, maintains mount and automount points and implements an
 elaborate transactional dependency-based service control logic.
 .
 systemd is compatible with SysV and LSB init scripts and can work as a
 drop-in replacement for sysvinit.
 .
 Installing the systemd package will not switch your init system unless you
 boot with init=/bin/systemd or install systemd-sysv in addition.
Homepage: https://www.freedesktop.org/wiki/Software/systemd
Original-Maintainer: Debian systemd Maintainers <email address hidden>

Revision history for this message
Walter Garcia-Fontes (walter-garcia) wrote :

Same for me. I really don't understand how /etc/resolv.conf should be managed in Ubuntu 17.04. I have the setup described in comment #7. I tried to have only network-manager manage /etc/resolv.conf, but then I loose name resolution in containers.

I think we should open a new bug report, as this one marked with "Fix released" will never get attention. It may also something worth investigating upstream.

Revision history for this message
mrvanes (mrvanes) wrote :

It seems this systemd bug is related and is supposed to be fixed. I still experience the problem however:
https://github.com/systemd/systemd/issues/7305

Revision history for this message
mrvanes (mrvanes) wrote :

The fix is incorporated in 236, but the systemd developer suggests the fix could be backported to 234. What version of systemd will be in bionic?

Revision history for this message
pureblood (freeseek) wrote :

I have had the same exact problem since I have upgraded to 17.10. In my case it does not even involve the VPN. When I come back from work, if I had suspended the laptop without restarting it, then I cannot connect to the computers from work.

If I restart resolvconf with:
$ sudo /etc/init.d/resolvconf restart
The problem persists.

If I edit the file /run/resolvconf/interface/systemd-resolved with
$ sudo emacs -nw /run/resolvconf/interface/systemd-resolved
... remove the work computer name in the line starting with search ...
$ sudo /etc/init.d/resolvconf restart
Then it works fine.

I hope this bug is well understood and the fix is on its way. It seems like a bit of a corner case, but it is indeed a serious bug.

Revision history for this message
Artem Astafyev (artem-astafyev) wrote :

Still have it in Ubuntu 19.10.

Revision history for this message
Alberto Donato (ack) wrote :

I still see this in 20.04

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.