Giter Club home page Giter Club logo

update-systemd-resolved's Introduction

update-systemd-resolved

Build Status

This is a helper script designed to integrate OpenVPN with the systemd-resolved service via DBus instead of trying to override /etc/resolv.conf, or manipulate systemd-networkd configuration files.

Since systemd-229, the systemd-resolved service has an API available via DBus which allows directly setting the DNS configuration for a link. This script makes use of busctl from systemd to send DBus messages to systemd-resolved to update the DNS for the link created by OpenVPN.

Prerequisites

This script requires:

Optional dependencies:

IP Parsing and Validation

If available, these will be used for IP address parsing and validation;1 otherwise update-systemd-resolved will use native Bash routines for this.

Logging

If available, the logger command included in the util-linux distribution will be used for logging. Otherwise, all logs will go to standard error using Bash's printf builtin.

Polkit Rules Generation

If available, these will be used for serializing the names of the users and groups allowed to call systemd-resolved's DBus methods to JSON lists for use within the generated polkit rules. Otherwise, update-systemd-resolved will fall back to native Bash routines for generating these lists.

Installation

If you are using a distribution of Linux with uses the Arch User Repository, the simplest way to install is by using the openvpn-update-systemd-resolved AUR package as this will take care of any updates through your package manager. Debian and Ubuntu also provide a .deb package in their distributions.

Alternatively, the package can be manually installed by running the following:

git clone https://github.com/jonathanio/update-systemd-resolved.git
cd update-systemd-resolved
make

Nix and NixOS

update-systemd-resolved exposes a Nix flake. You can incorporate this flake into your flake by adding it to your inputs:

# Your flake.nix
{
  inputs = {
    # Other inputs here...

    update-systemd-resolved.url = "github:jonathanio/update-systemd-resolved";
    update-systemd-resolved.inputs.nixpkgs.follows = "nixpkgs"; # optional
  };

  # Etc.
}

This flake provides the update-systemd-resolved package for several Linux architectures. It also provides the update-systemd-resolved NixOS module:

# Your flake.nix
{
  outputs = {nixpkgs, update-systemd-resolved, ...}: {
    nixosConfigurations.my-system = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        update-systemd-resolved.nixosModules.update-systemd-resolved
      ];
    };
  };
}

Please see the NixOS module documentation for available options.

To view all outputs provided by this flake, run the following command:

$ nix flake show 'github:jonathanio/update-systemd-resolved'

How to Enable

Make sure that you have systemd-resolved enabled and running. First, make sure that systemd-resolved.service is enabled and started:

systemctl enable systemd-resolved.service
systemctl start systemd-resolved.service

Next, you can either configure the system libraries to talk to it using NSS, or you can override the resolv.conf file to use systemd-resolved as a stub resolver (or both):

NSS and nssswitch.conf

Update your /etc/nsswitch.conf file to look up DNS via the resolve service (you may need to install the NSS library which connects libnss to systemd-resolved):

# Use /etc/resolv.conf first, then fall back to systemd-resolved
hosts: files dns resolve myhostname
# Use systemd-resolved first, then fall back to /etc/resolv.conf
hosts: files resolve dns myhostname
# Don't use /etc/resolv.conf at all
hosts: files resolve myhostname

The changes will be applied as soon as the file is saved.

Note that some Linux distributions manage /etc/nsswitch.conf, so manual edits to /etc/nsswitch.conf may disappear. Please consult your distribution's documentation for how to configure /etc/nsswitch.conf.

Polkit Rules

If you run the OpenVPN client as an unprivileged user, you may need to add polkit rules authorizing that user to perform the various DBus calls that update-systemd-resolved makes. Some installation methods bundle these rules; for instance, on Arch Linux, where openvpn-client@<name>.service instances run as the unprivileged openvpn user, the openvpn-update-systemd-resolved AUR package ships suitable rules in the file /etc/polkit-1/rules.d/10-update-systemd-resolved.rules.

Generating Polkit Rules

Warning

update-systemd-resolved strives to generate polkit rules with the smallest scope consistent with its proper functioning. Nonetheless, in order to avoid security risks, you are encouraged to review the generated polkit rules before installing them.

You can also generate suitable rules with (some variation on) the following commands:

$ update-systemd-resolved print-polkit-rules --polkit-allowed-user some-user --polkit-allowed-user another-user > ./10-custom-update-systemd-resolved.rules
$ sudo install -Dm0640 ./10-custom-update-systemd-resolved.rules /etc/polkit-1/rules.d/10-custom-update-systemd-resolved.rules

This will allow update-systemd-resolved to successfully make its DBus calls when invoked from OpenVPN client services that run as the users some-user or another-user.

You can also authorize members of specified groups with:

$ update-systemd-resolved print-polkit-rules --polkit-allowed-group some-group --polkit-allowed-group another-group > ./10-custom-update-systemd-resolved.rules
$ sudo install -Dm0640 ./10-custom-update-systemd-resolved.rules /etc/polkit-1/rules.d/10-custom-update-systemd-resolved.rules

This will allow update-systemd-resolved to successfully make its DBus calls when invoked from OpenVPN client services that run under the groups some-group or another-group.

Finally, you can generate rules that pull appropriate user and group values from OpenVPN systemd units with:

$ update-systemd-resolved print-polkit-rules --polkit-systemd-openvpn-unit my-openvpn-client.service
$ sudo install -Dm0640 ./10-custom-update-systemd-resolved.rules /etc/polkit-1/rules.d/10-custom-update-systemd-resolved.rules

Given:

$ systemctl show -P User my-openvpn-client.service
myuser
$ systemctl show -P Group my-openvpn-client.service
mygroup

The generated 10-custom-update-systemd-resolved.rules file will contain rules allowing the myuser user and members of the mygroup group to perform the requisite DBus calls.

You can run update-systemd-resolved print-polkit-rules with any combination of --polkit-allowed-user, --polkit-allowed-group, and --polkit-systemd-openvpn-unit. If called without options, update-systemd-resolved print-polkit-rules will attempt to derive appropriate user and group authorizations from a systemd OpenVPN unit matching [email protected], the systemd service template used for OpenVPN client services on distributions including Arch Linux.

Stub Resolver

The systemd-resolved service (since systemd-231) also listens on 127.0.0.53 via the lo interface, providing a stub resolver which any client can call to request DNS, whether or not it uses the system libraries to resolve DNS, and you no longer have to worry about trying to manage your /etc/resolv.conf file. This set up can be installed by linking to stub-resolv.conf:

ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

OpenVPN Configuration

Finally, update your OpenVPN configuration file and set the up and down options to point to the script, and down-pre to ensure that the script is run before the device is closed:

script-security 2
up /usr/local/libexec/openvpn/update-systemd-resolved
up-restart
down /usr/local/libexec/openvpn/update-systemd-resolved
down-pre

# If needed, to permit `update-systemd-resolved` to find utilities it depends
# on.  Adjust to suit your system.
#setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

up-restart

It is recommended to use up-restart in your configuration to ensure that upate-systemd-resolved is run on restarts - where the connection is re-established but the TUN/TAP device remained open (for example, where the original connection has timed out and persist-tun is enabled). If you do not have persist-tun set, or you use ping-exit instead of ping-timeout, you most likely will not need this.

down/pre-down with user/group

The down and down-pre options here may not work as expected where the openvpn daemon drops privileges after establishing the connection (i.e. when using the user and group options). This is because, by default, only the root user will have the privileges required to talk to systemd-resolved.service over DBus. The openvpn-plugin-down-root.so plug-in does provide support for enabling the down script to be run as the root user, but this has been known to be unreliable.

You can authorize unprivileged users or groups to revert the OpenVPN link's DNS settings during the "down" phase using the methods described in the "Polkit Rules" section.

Ultimately, dropping privileges shouldn't affect normal "down" operation, since systemd-resolved.service will remove all settings associated with the link (and therefore naturally update /etc/resolv.conf, if you have it symlinked) when the TUN or TAP device is closed. The option for down and down-pre just make this step explicit before the device is torn down rather than implicit on the change in environment.

Command Line Settings

Alternatively if you don't want to edit your client configuration, you can add the following options to your openvpn command:

openvpn \
  --script-security 2 \
  --setenv PATH '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' \
  --up /usr/local/libexec/openvpn/update-systemd-resolved --up-restart \
  --down /usr/local/libexec/openvpn/update-systemd-resolved --down-pre

Tip

The --setenv PATH option shown above is intended to allow update-systemd-resolved to find its prerequisites. Depending on your system's configuration, you may not need --setenv PATH, or you may need to specify a different PATH value than the one shown above.

Or, you can add the following argument to the command-line arguments of openvpn, which will use the update-systemd-resolve.conf file instead:

openvpn --config /usr/local/share/doc/openvpn/update-systemd-resolved.conf

Note

The path to update-systemd-resolved.conf may differ depending on how you installed update-systemd-resolved. Additionally, both the file's path and its contents are subject to change in future releases. Rather than using the example configuration file directory, you may want to copy the file to another location and then run openvpn --config <other-location>/update-systemd-resolved.conf.

🪛 Usage 🔧

update-systemd-resolved works by processing the dhcp-option commands set in OpenVPN, either through the server, or the client, configuration. Note that there are no local or system options to be configured. All configuration for this script is handled through OpenVPN, including, for example, the name of the interface to be configured.

🎚️ Options 🎛️

⚙️ DNS

Setting DNS servers
Examples
  • 0.0.0.0
  • 0.0.0.0:5353
  • 0.0.0.0#my.resolver.net
  • 0.0.0.0:5353#my.resolver.net
  • ::1
  • [::1]:5353
  • ::1#my.resolver.net
  • [::1]:5353#my.resolver.net
Description

This sets the DNS servers for the link and can take any IPv4 or IPv6 address.

DBus call

SetLinkDNS, SetLinkDNSEx

⚙️ DNS6

Setting IPv6-only DNS servers
Examples
  • ::1
  • [::1]:5353
  • ::1#my.resolver.net
  • [::1]:5353#my.resolver.net
Description

This sets the DNS servers for the link and can take only IPv6 addresses.

DBus call

SetLinkDNS, SetLinkDNSEx

⚙️ DOMAIN or ADAPTER_DOMAIN_SUFFIX

Setting the primary domain
Examples
  • example.com
Description

The primary domain for this host. If set multiple times, the first provided is used as the primary search domain for bare hostnames. Any subsequent DOMAIN options will be added as the equivalent of DOMAIN-SEARCH options. All requests for this domain as well will be routed to the DNS servers provided on this link.

DBus call

SetLinkDomains

⚙️ DOMAIN-SEARCH

Setting secondary domains
Examples
  • example.com
Description

Secondary domains which will be used to search for bare hostnames (after any DOMAIN, if set) and in the order provided. All requests for this domain will be routed to the DNS servers provided on this link.

DBus call

SetLinkDomains

⚙️ DOMAIN-ROUTE

Routing DNS queries
Examples
  • example.com
Description

All requests for these domains will be routed to the DNS servers provided on this link. They will not be used to search for bare hostnames, only routed. A DOMAIN-ROUTE option for . (single period) will instruct systemd-resolved to route the entire DNS name-space through to the DNS servers configured for this connection (unless a more specific route has been offered by another connection for a selected name/name-space). This is useful if you wish to prevent DNS leakage.

DBus call

SetLinkDomains

⚙️ DNSSEC

Enabling DNSSEC
Examples
  • yes, true
  • no, false
  • default
  • allow-downgrade
Description

Control of DNSSEC should be enabled (yes, true) or disabled (no, false), or allow-downgrade to switch off DNSSEC only if the server doesn't support it, for any queries over this link only, or use the system default (default).

DBus call

DNSSEC

⚙️ FLUSH-CACHES

Flushing DNS caches
Examples
  • yes, true
  • no, false
Description

Whether or not to flush all local DNS caches. Enabled by default.

DBus call

FlushCaches

⚙️ RESET-SERVER-FEATURES

Resetting learnt DNS server feature levels
Examples
  • yes, true
  • no, false
Description

Whether or not to forget learnt DNS server feature levels.

DBus call

ResetServerFeatures

⚙️ RESET-STATISTICS

Resetting resolver statistics
Examples
  • yes, true
  • no, false
Description

Whether or not to reset resolver statistics.

DBus call

ResetStatistics

⚙️ DEFAULT-ROUTE

Default DNS query routing
Examples
  • yes, true
  • no, false
Description

If true, this link's configured DNS servers are used for resolving domain names that do not match any link's configured Domains= setting. If false, this link's configured DNS servers are never used for such domains, and are exclusively used for resolving names that match at least one of the domains configured on this link.

DBus call

DNSDefaultRoute

⚙️ DNS-OVER-TLS

Enabling DNS-over-TLS
Examples
  • yes, true
  • no, falseopportunisticdefault
Description

If true all connections to the server will be encrypted. Note that this mode requires a DNS server that supports DNS-over-TLS and has a valid certificate. If the hostname was specified in DNS= by using the format address#server_name it is used to validate its certificate and also to enable Server Name Indication (SNI) when opening a TLS connection. Otherwise the certificate is checked against the server's IP. If the DNS server does not support DNS-over-TLS all DNS requests will fail. When set to opportunistic DNS request are attempted to send encrypted with DNS-over-TLS. If the DNS server does not support TLS, DNS-over-TLS is disabled. Note that this mode makes DNS-over-TLS vulnerable to "downgrade" attacks, where an attacker might be able to trigger a downgrade to non-encrypted mode by synthesizing a response that suggests DNS-over-TLS was not supported. If set to false, DNS lookups are send over UDP. If set to default, uses the system default.

DBus call

SetLinkDNSOverTLS

⚙️ LLMNR

Enabling Link-Local Multicast Name Resolution
Examples
  • yes, true
  • no, falseresolvedefault
Description

When true, enables Link-Local Multicast Name Resolution on the link. When set to resolve, only resolution is enabled, but not host registration and announcement. If set to default, uses the system default.

DBus call

SetLinkLLMNR

⚙️ MULTICAST-DNS

Enabling Multicast DNS
Examples
  • yes, true
  • no, falseresolvedefault
Description

When true, enables Multicast DNS support on the link. When set to resolve, only resolution is enabled, but not host or service registration and announcement. If set to default, uses the system default.

DBus call

SetLinkMulticastDNS

⚙️ DNSSEC-NEGATIVE-TRUST-ANCHORS

Configuring DNSSEC Negative Trust Anchors
Examples
  • trusted.org
Description

If specified and DNSSEC is enabled, look-ups done via the interface's DNS server will be subject to the list of negative trust anchors, and not require authentication for the specified domains, or anything below it. Use this to disable DNSSEC authentication for specific private domains, that cannot be proven valid using the Internet DNS hierarchy. By default, update-systemd-resolved does not set any negative trust anchors.

DBus call

SetLinkDNSSECNegativeTrustAnchors

Example

push "dhcp-option DNS 10.62.3.2"
push "dhcp-option DNS 10.62.3.3"
push "dhcp-option DNS6 2001:db8::a3:c15c:b56e:619a"
push "dhcp-option DNS6 2001:db8::a3:ffec:f61c:2e06"
push "dhcp-option DOMAIN example.office"
push "dhcp-option DOMAIN example.lan"
push "dhcp-option DOMAIN-SEARCH example.com"
push "dhcp-option DOMAIN-ROUTE example.net"
push "dhcp-option DOMAIN-ROUTE example.org"
push "dhcp-option DNSSEC yes"

This, added to the OpenVPN server's configuration file will set two IPv4 DNS servers and two IPv6 and will set the primary domain for the link to be example.office. Therefore if you try to look up the bare address mail then mail.example.office will be attempted first. The domains example.lan and example.com are also added as an additional search domain, so if mail.example.office fails, then mail.example.lan will be tried next, followed by mail.example.com.

Requests for example.net and example.org will also be routed through to the four DNS servers listed, but they will not be appended (i.e. mail.example.net will not be attempted, nor mail.example.org, if mail.example.office or mail.example.com do not exist).

Finally, DNSSEC has been enabled for this link (and this link only).

DNS Leakage

Important

Required reading: systemd-resolved.service and VPNs. This document includes, among other things, an overview of search domains, routing domains, and systemd-resolved's default-route boolean settings. Understanding these concepts will help you configure your local systemd-resolved instance to ensure that DNS queries go where you want them to go.

DNS Leakage is something to be careful of when using any VPN or untrusted network, and it can heavily depend on how you configure your normal DNS settings as well as how you configure the DNS on your VPN connection.

By default, systemd-resolved will send all DNS queries to at least one DNS server on every link configured with DNS servers. The first to reply back with a valid query is the one returned to the client, and the last to return back a failure (assuming all other queries also failed) will also be returned to the client.

The changes in this handling come in when you start using the DOMAIN, DOMAIN-SEARCH and DOMAIN-ROUTE options. The three differ in how domains are treated for searching bare domains, but all three work exactly the same when it comes to how it routes domains to specific DNS servers.

Any domain added using DOMAIN, DOMAIN-SEARCH, or DOMAIN-ROUTE will be added explicitly to the VPN link and therefore any queries for domain suffixes which match these will be routed through this link, and only this link. Any other domains which do not match these will revert back to distributing the queries across all links.

There are two ways to override this:

Preventing Leakage in on untrusted networks

If you want to prevent DNS queries leaking over untrusted networks (for example, over public WiFi hotspots), then you need to tell systemd-resolved to send all DNS queries over the VPN link. To do this, add the following to your server or client VPN configurations respectively:

# Server Configuration
push "dhcp-option DOMAIN-ROUTE ."
# Client Configuration
dhcp-option DOMAIN-ROUTE .

All DNS queries (which do not match a more explicit entry on another link) will now be routed over the VPN only.

Preventing Leakage to Corporate networks

In an alternate situation, you may want to have DNS queries specifically routed over the VPN for corporate or private network access, but you don't want your general DNS queries to be visible to anyone who has access to the logs of the corporate DNS servers.

This option cannot be directly managed by update-systemd-resolved as you need to configure the network settings of other links to send all queries by default to your nominated DNS server (e.g. over ens0 or wlp2s0 for your Ethernet or Wireless network cards). This needs to be configured under the [Network] section of your .network file for your interface in /etc/systemd/network. For example:

[Network]
DHCP=yes
DNS=8.8.8.8
DNS=8.8.4.4
Domains=.

When you connect, all domains except those explicitly listed using the DOMAIN, DOMAIN-SEARCH, or DOMAIN-ROUTE options of your VPN link will be sent to the DNS server of your nominated link.

Concurrent Configuration

Note that these two options are mutually exclusive, as if you establish a VPN link with DOMAIN-ROUTE set to . while you have also configured it inside a .network file via systemd-networkd, then you will have two links responsible for routing all queries, and so both links will get all requests.

How to manage the DNS settings of other links while the VPN is operational is outside the scope of this script at this time.

Known Issues

There are a number of known issues relating to some third-party servers and services:

NetworkManager

Compatibility with this script

This script may not be compatible with certain versions of NetworkManager. It seems that NetworkManager overrides the up command to use its own helper script (nm-openvpn-service-openvpn-helper). The script that ships with NetworkManager only supports DNS and DOMAIN options (not DNS6, DOMAIN-SEARCH and DOMAIN-ROUTE, nor DNSSEC overrides). It may also be liable to set the other network interfaces to route ~. DNS queries (i.e the whole name-space) to the LAN or ISP DNS servers, making it difficult to override using DOMAIN - see the DNS leakage section.

Managed interface DNS leakage

There is a regression with versions of NetworkManager 1.2.6 through 1.26.4 (see LP#1671606 and LP#1688018) which means that it will automatically set all normal network interfaces with ~. for DNS routing. This means that even if you set dhcp-option DOMAIN-ROUTE . for your VPN connection, you will still leak DNS queries over potentially insecure networks.

If you are concerned by potentially leaking DNS on systems which use NetworkManager, you may need to configure an additional script into NetworkManager which change the domain routing settings on all non-VPN interfaces.

This issue was fixed in NetworkManager version 1.26.6; now, NetworkManager only enables the DefaultRoute option on managed interfaces.

DNSSEC Issues

$ resolvectl query eu-central-1.console.aws.amazon.com
eu-central-1.console.aws.amazon.com: resolve call failed: DNSSEC validation failed: no-signature
# or
$ resolvectl query eu-central-1.console.aws.amazon.com
eu-central-1.console.aws.amazon.com: resolve call failed: DNSSEC validation failed: incompatible-server

If you are seeing failed queries in your logs due to DNSSEC issues, support may be partially or fully enabled and you are now working with a server which does not support this extension. You may therefore need to set DNSSEC to no (or maybe just allow-downgrade) in your VPN configuration.

dhcp-option DNSSEC allow-downgrade

Issues with Ubuntu and Fedora

Ubuntu

The NSS interface for systemd-resolved may be deprecated and has already been flagged for deprecation in Ubuntu (see LP#1685045 for details). In this case, you should use the Stub Resolver method now.

Fedora

Fedora 28 makes use of authselect to manage the NSS settings on the system. Directly editing nsswitch.conf is not recommended as it may be overwritten at any time if authselect is run. Proper overrides may not yet be possible - see the authselect project repository for details. However, like Ubuntu, the Stub Resolver method is recommended here too.

Note that Fedora 33 enables systemd-resolved by default and configures /etc/nsswitch.conf to use the systemd-resolved NSS interface; see the Fedora changelog entry for details.

How to help

If you can help with any of these areas, or have bug fixes, please fork and raise a Pull Request for me.

I have built a basic test framework around the script which can be used to monitor and validate the calls made by the script based on the environment variables available to it at run-time. Please add a test for any new features you may wish to add, or update any which are wrong, and test your code by running ./run-tests from the root of the repository. There are no dependencies on run-tests - it runs 100% bash and doesn't call out to any other program or language.

GitHub Actions are enabled on this repository: Click the link at the top of this README to see the current state of the code and its tests.

Development notes

Please see HACKING.md for notes on developing update-systemd-resolved.

Licence

GPL

Author

Jonathan Wright [email protected]

Footnotes

  1. Required for translating numerical labels like 1.2.3.4 to the byte arrays recognized by the SetLinkDNS() function on systemd-resolved's org.freedesktop.resolve1.Manager D-Bus interface).

update-systemd-resolved's People

Contributors

adq avatar arjenschol avatar cmadamsgit avatar edu4rdshl avatar ekristen avatar flungo avatar genisysram avatar jonathanio avatar mbiebl avatar nocnokneo avatar perlun avatar phr0ze avatar piotr-dobrogost avatar scop avatar thecodingrobot avatar tomeon avatar wfdewith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

update-systemd-resolved's Issues

Allow ordering (before, after) of new DNS nameservers

It would be handy if update-systemd-resolved let one specify whether new nameservers should take precedence or not over existing nameservers.

In my case update-systemd-resolved is updating my /etc/resolv.conf from the default:

nameserver 192.168.1.254
search home.gateway

to:

nameserver 192.168.1.254
nameserver 10.34.0.99
search home.gateway corp.company.com

That is perfectly sensible default behaviour, but in my particular case I'd like the order swapped:

nameserver 10.34.0.99
nameserver 192.168.1.254
search corp.company.com home.gateway

so that hostnames with differing internal and external IPs resolve to the internal IP, not the external.

(Thanks for writing update-systemd-resolved - it's now an indispensable part of any openvpn setup)

cant connect after running make

I read through your guide and gave it a whirl.

Using ubunjtu 16.04.
Openvpn v: 2.3.10
iprout2 v: 4.3.0
systemd: 229

I replaced myhostname with my computers hostname and updated the /etc/nsswitch.conf so it looks like

hosts: files resolve dns myHOSTNAME

service systemd-resolved status show that the service is running.

Looks like network-manager is running and connected just fine. Gussing the dns isnt getting resolved. at least I dont think it is.

How would I go about fixing the issue or removing what was made/done in the makefile?

Thanks.

busctl' exited with status 1

am getting the following error:

Mon Sep  4 13:46:25 2017 ERROR: Linux route add command failed: external program exited with error status: 2
Mon Sep  4 13:46:25 2017 Initialization Sequence Completed
^CMon Sep  4 13:46:47 2017 event_wait : Interrupted system call (code=4)
Mon Sep  4 13:46:47 2017 /usr/bin/ip route del 198.51.100.100/32
Mon Sep  4 13:46:47 2017 /usr/bin/ip route del 0.0.0.0/1
RTNETLINK answers: No such process
Mon Sep  4 13:46:47 2017 ERROR: Linux route delete command failed: external program exited with error status: 2
Mon Sep  4 13:46:47 2017 /usr/bin/ip route del 128.0.0.0/1
RTNETLINK answers: No such process
Mon Sep  4 13:46:47 2017 ERROR: Linux route delete command failed: external program exited with error status: 2
Mon Sep  4 13:46:47 2017 /etc/openvpn/scripts/update-systemd-resolved tun0 1500 1587 10.7.0.2 255.255.0.0 init
<14>Sep  4 13:46:47 update-systemd-resolved: Link 'tun0' going down
Link tun0 is managed.
<8>Sep  4 13:46:47 update-systemd-resolved: 'busctl' exited with status 1
Mon Sep  4 13:46:47 2017 WARNING: Failed running command (--up/--down): external program exited with error status: 1
Mon Sep  4 13:46:47 2017 Exiting due to fatal error

searched the closed issues but failed to understand the origin of the issue

No script type specified

Hi, I'm experiencing an issue using this script with OpenVPN 2.3.12, on Arch Linux with SystemD v231.

I can correctly connect to VPN, but my resolv.conf it's not changed.

Here's my connection log, which seems to correctly run /etc/openvpn/update-systemd-resolved:

set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: TUN/TAP TX queue length set to 100
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /usr/bin/ip link set dev tun0 up mtu 1500
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /usr/bin/ip addr add dev tun0 local 192.168.255.6 peer 192.168.255.5
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /etc/openvpn/update-systemd-resolved tun0 1500 1541 192.168.255.6 192.168.255.5 init
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /usr/bin/ip route add <<remote_ip>>/32 via 192.168.0.254
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /usr/bin/ip route add 0.0.0.0/1 via 192.168.255.5
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /usr/bin/ip route add 128.0.0.0/1 via 192.168.255.5
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: /usr/bin/ip route add 192.168.255.1/32 via 192.168.255.5
set 17 19:36:50 luiss-arch-port openvpn@luigi[8184]: Initialization Sequence Completed

Here's my vpn-client conf:

client
nobind
dev tun
key-direction 1
remote-cert-tls server
verb 4
remote <<server_url>> 1194 udp

key-direction 1

redirect-gateway def1

script-security 2
setenv PATH /usr/bin
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved

client
nobind
dev tun
key-direction 1
remote-cert-tls server
verb 4
remote <<server_url>> 1194 udp

key-direction 1

redirect-gateway def1

script-security 2
setenv PATH /usr/bin
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved

Here's script permissions:
-rwxr-xr-x 1 root root 11191 17 set 18.24 update-systemd-resolved*

My resolv.conf file keeps untouched after connection (and also the nslookup command is not using the DNS I specified server side).

Thanks for any kind of help.

Regards
Luigi
Italy

Please document required system tools

For example update-systemd-resolved.sh uses ip command which on Fedora is located at /usr/sbin/ip yet README suggests setting PATH to /usr/bin.
Generally, in order to establish how PATH should look like one should know which system tools are being used.

Update for OpenVPN 2.4

Two problems with OpenVPN 2.4:

  1. Error message when stopping service:
Broadcast message from systemd-journald@melforce (Mon 2016-12-12 22:24:49 MSK):

update-systemd-resolved[14692]: `busctl' exited with status 1
  1. Config syntax changed (update README):
up ../update-systemd-resolved
down ../update-systemd-resolved
down-pre

Add some configuration feature

Hello,
I'd like to configure two things if possible:

  1. Add DNS domains on the link as routing domains only, not search domains
  2. Ability to set DNSSEC= for the link

How to remove the router's local IP address from the DNS Servers

The output of systemd-resolve --status shows that the first DNS server on the interface eno1 (ethernet?) is 192.168.1.254, which is basically my ISP box.

I symlinked /etc/resolv.conf to /etc/systemd/resolve/resolv.conf, and tried editing the latter file to remove the unwanted DNS, but my changes weren't saved. How to configure the chosen DNS servers?

It's really a problem because when using openvpn, even with the up/down scripts properly configured, I will have DNS leaks...

How to remove this DNS server?
thanks a lot for your help.

update-systemd-resolved failing to update DNS settings in Ubuntu 18.04

This script was working a few days ago for me. Had to rebuild my laptop and now it is not working.
Currently running ubuntu 18.04

It looks like it sets the DNS servers from the output. But actually does not add them.

Mon Mar 11 14:56:34 2019 /etc/openvpn/scripts/update-systemd-resolved tun0 1500 1572 172.30.0.6 172.30.0.5 init
<14>Mar 11 14:56:34 update-systemd-resolved: Link 'tun0' coming up
<14>Mar 11 14:56:34 update-systemd-resolved: Adding IPv4 DNS Server 10.248.16.1
<14>Mar 11 14:56:34 update-systemd-resolved: Adding IPv4 DNS Server 10.248.240.1
<14>Mar 11 14:56:34 update-systemd-resolved: Setting DNS Domain example.com
<14>Mar 11 14:56:34 update-systemd-resolved: SetLinkDNS(8 2 2 4 10 248 16 1 2 4 10 248 240 1)
<14>Mar 11 14:56:34 update-systemd-resolved: SetLinkDomains(8 1 example.com false)
Mon Mar 11 14:56:34 2019 /sbin/ip route add 10.248.240.0/20 via 172.30.0.5
Mon Mar 11 14:56:34 2019 /sbin/ip route add 10.248.32.0/20 via 172.30.0.5
Mon Mar 11 14:56:34 2019 /sbin/ip route add 10.248.16.0/20 via 172.30.0.5
Mon Mar 11 14:56:34 2019 /sbin/ip route add 10.248.0.0/20 via 172.30.0.5
Mon Mar 11 14:56:34 2019 /sbin/ip route add 172.30.0.1/32 via 172.30.0.5

===============================================================================
                             Device details (tun0)
===============================================================================
GENERAL.DEVICE:                         tun0
-------------------------------------------------------------------------------
GENERAL.TYPE:                           tun
-------------------------------------------------------------------------------
GENERAL.HWADDR:                         
-------------------------------------------------------------------------------
GENERAL.MTU:                            1500
-------------------------------------------------------------------------------
GENERAL.STATE:                          100 (connected)
-------------------------------------------------------------------------------
GENERAL.CONNECTION:                     tun0
-------------------------------------------------------------------------------
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/8
-------------------------------------------------------------------------------
IP4.ADDRESS[1]:                         172.30.0.6/32
IP4.GATEWAY:                            
IP4.ROUTE[1]:                           dst = 10.248.32.0/20, nh = 172.30.0.5, mt = 0
IP4.ROUTE[2]:                           dst = 10.248.0.0/20, nh = 172.30.0.5, mt = 0
IP4.ROUTE[3]:                           dst = 172.30.0.1/32, nh = 172.30.0.5, mt = 0
IP4.ROUTE[4]:                           dst = 10.248.240.0/20, nh = 172.30.0.5, mt = 0
IP4.ROUTE[5]:                           dst = 10.248.16.0/20, nh = 172.30.0.5, mt = 0
-------------------------------------------------------------------------------
IP6.ADDRESS[1]:                         fe80::6d14:7405:78e6:5d4f/64
IP6.GATEWAY:                            
-------------------------------------------------------------------------------

Refactor Unit Tests

There could be some improvements around the handling of the unit tests. Including:

  • Make foreign_option_* into an array: This will help with ordering, cleaning up after tests, and make it easier to work with and expand. Will need conversion out into the foreign_option_* variables however for internal processing, but will make the writing of tests easier and less error prone.
  • dev could probably be random alongside the ifindex value: the script can never be configured for it, and it should never know it, and so to set it in the tests has no real purpose.
  • Tests should only output in colour on colour-capable terminals.

Integrate with NetworkManager OpenVPN

Hi, actually how do I integrate this script with NetworkManager ? Where should I put this script ?

When running using cli to connect to openvpn, the script working and I can access to my internal server using internal dns. Other hostname that not in my internal dns will be access using my local network.

But if I call from networkmanager ( gui ) , the script never run.

Ubuntu 20.04 - DNS pushed by the ovpn server shown in status, but not reflecting in resolv.conf

Hi there,

The ovpn server's DNS push is reflecting fine in systemd-resolved --status:

`Link 17 (tun0)
      Current Scopes: DNS        
DefaultRoute setting: yes        
       LLMNR setting: yes        
MulticastDNS setting: no         
  DNSOverTLS setting: no         
      DNSSEC setting: no         
    DNSSEC supported: no         
  Current DNS Server: 192.168.0.2
         DNS Servers: 192.168.0.2

Link 3 (enx8c04ba783dde)
      Current Scopes: none
DefaultRoute setting: no  
       LLMNR setting: yes 
MulticastDNS setting: no  
  DNSOverTLS setting: no  
      DNSSEC setting: no  
    DNSSEC supported: no  

Link 2 (wlo1)
      Current Scopes: DNS    
DefaultRoute setting: yes    
       LLMNR setting: yes    
MulticastDNS setting: no     
  DNSOverTLS setting: no     
      DNSSEC setting: no     
    DNSSEC supported: no     
  Current DNS Server: 1.1.1.1
         DNS Servers: 1.1.1.1
          DNS Domain: ~.`

But the /etc/resolv.conf still shows only 127.0.0.53. and dig to an internal domain doesnt work.

Symlink is to stub-resolv.conf:
/etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

I've disabled the dns in NetworkManager.conf also, and set the vpn's dns priority as -42. Still doesnt seem to work.

Finally I disabled systemd-resolved service and switched to coredns, but then the connection itself is failing with this error:
WARNING: Failed running command (--up/--down): external program exited with error status: 1
Exiting due to fatal error

How can we solve this in Ubuntu 20.04 without having to disable this service? What could be the issue here?

Error if IPv6 address is valid but didn't match recommendation

I stumbled across update-systemd-resolved's accuracy in following RFC5952 (A Recommendation for IPv6 Address Text Representation). Section 4.1 claims 'single 16-
bit 0000 field MUST be represented as 0'.

update-systemd-resolved exits with an error if this recommendation is violated. This completely prevents openvpn from establishing the connection.

openvpn[5638]: <8>Sep  3 15:51:06 update-systemd-resolved: 'fd00:ff:0:2:301:64::3' is not a valid IPv6 address: single '0' fields should not be compressed
ovpn-client[5638]: WARNING: Failed running command (--up/--down): external program exited with error status: 1
ovpn-client[5638]: Exiting due to fatal error

For me it was not an expected behaviour that a program exits with an error if an IP address is valid but just didn't match a recommendation. I think it would be better to just log a warning instead exit with error.

Support new "DNSDefaultRoute" option?

In version 240 of systemd there's the new option DNSDefaultRoute introduced by systemd/systemd#11050 with the following description:

Takes a boolean argument. If true, this link's configured DNS servers are used for resolving domain names that do not match any link's configured Domains= setting. If false, this link's configured DNS servers are never used for such domains, and are exclusively used for resolving names that match at least one of the domains configured on this link. If not specified defaults to an automatic mode: queries not matching any link's configured domains will be routed to this link if it has no routing-only domains configured.

Probably it should be supported somehow :)

Can Not Enable and Start systemd-resolved.service

Hi @jonathanio, using CentOS Linux release 7.5.1804 I am not successful enabling and starting systemd-resolved.service. I will recap highlights in my quest:

  1. Follwed instructions here. Receiving Failed to execute operation: No such file or directory
  2. Updated /etc/nsswitch.conf as follows: hosts: files resolve dns myhostname
  3. Reviewed issues #46, #45, #37, #27 and #25. #23 speaks to the issue but the conclusion didn't specifically outline the fix. (Unless I am over looking an obvious comment.)

Any guidance?

I did confirm resolution via global DNS provider in local LAN while connected via OpenVPN client using: nslookup (hostname) (dns server)

Commandline parameters to up/down helpers seem unstable

My OpenVPN version (2.4.6) calls the up/down helpers with different arguments than this script expects

/etc/openvpn/scripts/update-systemd-resolved tun0 1500 1555 10.235.97.2 255.255.255.128 init

However, the variables dev and script_type are passed via ENV. I see no need to rely on parameter parsing.

DNS servers not set when multiple are pushed in same command

When an openvpn server pushes, via dhcp-option "DNS 8.8.8.8 1.1.1.1" update-systemd-resolved does not set any DNS servers. The previously used script update-resolv-conf did properly handle such a server-side push command.

This can be fixed by changing the server to use two dhcp-option DNS commands, but I don't have access to alter the server in my use cases.

The fix should be to iterate over all arguments in a dhcp-option DNS command.

logger --id fails with "Operation not permitted"

Hey there! First let me say thanks a lot for this useful script.

I just found a minor issue while following systemlogs with journalctl -fe

Mar 31 20:21:01 karotte openvpn[6961]: /etc/openvpn/update-systemd-resolved tun0 1500 1556 some.company.ip.v4 255.255.255.0 init
Mar 31 20:21:01 karotte openvpn[6961]: + logger -s --id=6971 -t update-systemd-resolved -p user.info -- 'Link '\''tun0'\'' coming up'
Mar 31 20:21:01 karotte openvpn[6961]: logger: send message failed: Operation not permitted
Mar 31 20:21:01 karotte openvpn[6961]: <14>Mar 31 20:21:01 update-systemd-resolved[6971]: Link 'tun0' coming up

i used "set -x" to get some more debugging infos during the logger run.

While this fails when executed from within update-systemd-resolved i works when executed from the commandline

Console:

i|karotte ~ # logger -s --id=6971 -t update-systemd-resolved -p user.info -- 'Link '\''tun0'\'' coming up'
<14>Mar 31 20:31:40 update-systemd-resolved[6971]: Link 'tun0' coming up

Journal:

Mar 31 20:31:40 karotte update-systemd-resolved[7075]: Link 'tun0' coming up

Changing the script like shown below gets rid of the error

diff --git a/update-systemd-resolved b/update-systemd-resolved
index 422d105..db2cc13 100755
--- a/update-systemd-resolved
+++ b/update-systemd-resolved
@@ -32,7 +32,7 @@ DBUS_NODE="/org/freedesktop/resolve1"
 SCRIPT_NAME="${BASH_SOURCE[0]##*/}"
 
 log() {
-  logger -s --id="$$" -t "$SCRIPT_NAME" "$@"
+  logger -s -t "$SCRIPT_NAME" "$@"
 }

This happens using systemd-233-r1 on gentoo linux

Any ideas what might be going on here?

DNS settings lost on network changes (up-restart enabled)

I believe the issue in #53 are probably the same, just that the fix applied only works in some cases.

I have a laptop that has ethernet and wifi, when any network change occurs, the DNS settings are lost for the VPN tunnel, even if the VPN hasn't been restarted. For example, the VPN is going over the ethernet, the WiFi gets disconnected and reconnected, the settings are then lost.

Status after initial connection

$ systemd-resolve --status tun1
Link 30 (tun1)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 10.1.3.12
          DNS Domain: abc.local

Disconnect wifi, VPN still running via Ethernet, not loss of VPN connection, but DNS settings are lost.

$ systemd-resolve --status tun1
Link 30 (tun1)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Settings in openvpn conf do include up-restart

up /etc/openvpn/update-systemd-resolved
up-restart
down /etc/openvpn/update-systemd-resolved
down-pre

Only relevant syslog lines that I can see are below

Jan  7 07:24:19 SUQLD-L0365 wpa_supplicant[1165]: nl80211: deinit ifname=p2p-dev-wlp3s0 disabled_11b_rates=0
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1655]: reading /etc/resolv.conf
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1415]: reading /etc/resolv.conf
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1415]: using nameserver 127.0.0.53#53
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1655]: using nameserver 127.0.0.53#53
Jan  7 07:24:19 SUQLD-L0365 NetworkManager[1311]: <info>  [1578353059.5907] audit: op="radio-control" arg="wireless-enabled:0" pid=7938 uid=10006 result="success"
Jan  7 07:24:19 SUQLD-L0365 NetworkManager[1311]: <info>  [1578353059.5909] manager: rfkill: WiFi now disabled by radio killswitch
Jan  7 07:24:19 SUQLD-L0365 dbus-daemon[1138]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.25' (uid=0 pid=1311 comm="/usr/sbin/NetworkManager --no-daemon " label="unconfined")
Jan  7 07:24:19 SUQLD-L0365 systemd[1]: Starting Network Manager Script Dispatcher Service...
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1415]: reading /etc/resolv.conf
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1655]: reading /etc/resolv.conf
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1415]: using nameserver 127.0.0.53#53
...
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1415]: using nameserver 127.0.0.53#53
Jan  7 07:24:19 SUQLD-L0365 systemd[1]: Started Network Manager Script Dispatcher Service.
Jan  7 07:24:19 SUQLD-L0365 dbus-daemon[1138]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1655]: using nameserver 127.0.0.53#53
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1655]: reading /etc/resolv.conf
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1655]: using nameserver 127.0.0.53#53
Jan  7 07:24:19 SUQLD-L0365 nm-dispatcher: req:1 'down' [wlp3s0]: new request (2 scripts)
Jan  7 07:24:19 SUQLD-L0365 nm-dispatcher: req:1 'down' [wlp3s0]: start running ordered scripts...
Jan  7 07:24:19 SUQLD-L0365 dnsmasq[1415]: reading /etc/resolv.conf

Running OpenVPN 2.4.4 on Ubuntu 18.04 with update-systemd-resolved (openvpn-systemd-resolved) package version 1.2.7-1. I can't see anything in the 1.3.0 release that would fix this issue.

Allow script to be run with dropped privileges

Is there an option to run the script with dropped privileges as a specific user?

In case that's trivially doable please excuse my ignorance, but I could not find a way.

Could the script be adapted to work without root?
In principle the call to busctl could be wrapped in a sudo call yes?
Then we could add an unprivileged user to the /etc/sudoers file with this specific command.

Do you plan on supporting that?

Not using the DNS servers after period of time

Hi,

I'm getting DHCP-Options that push DNS servers , domain search and specific routes.
After some period of time connected to the VPN, my dns queries stop going through my dns server.

when doing systemd-resolve --status i still see the dns server in the interface, but for some reason this dns server is not used for the queries...

Any ideas?

The problematic domain is "gmistick.internal" , is that a problem?

dnssec

hello, i use your script quite long time. I've never had a problem with it. i use nordvpn under arch linux. from few days something was wrong because i dont have internet so i switch to windows and see that nordvpn servers works fine. after i uninstall your script i can connect to internet with my nordvpn so somethings after latest arch updates was wrong. i suspect latest update for systemd may cause this bug because the same errors i found in arch board:
https://bbs.archlinux.org/viewtopic.php?id=240427

in /etc/resolv.conf i have this entry
hosts: files resolve myhostname

and when i check status for
systemctl status systemd-resolved.service
i have many errors with DNSSEC validation failed

after few hours of testing what its wrong i figure out that i must edit
sudo nano /etc/systemd/resolved.conf
and change from
#DNSSEC=allow-downgrade
to
DNSSEC=no

after this change i can still use your script and i have internet when i connect to nordvpn but maybe
you know something more why it stops working ? or you must update your script for new systemd release?

Calling functions on script_type.

Hi

Sanitize $script_type with "declare -f" makes it easy to inject own functions.
One could easily exploit the script.
ex.
mycat(){ /bin/cat /etc/openvpn/credentials/password; };
export -f mycat;
export script_type=mycat; /etc/openvpn/update-systemd-resolved tun0

whole 'main' function is just bad.

openvpn not passing dhcp-option (not a problem with update-systemd-resolved)

Thanks for this script, it's very useful and helpful. I ran into an odd issue with my version of openvpn (debian stretch opevnpn 2.4.0, and stretch-backports 2.4.3) where dhcp-option pushes don't get passed to the up/down script at all. I'm not sure why this is the case, so I though I'd open an issue here in case other folks have also seen this, or if anyone has a solution.

The openvpn log contains:

Options error: Unrecognized option or missing or extra parameter(s) in [PUSH-OPTIONS]:X: dhcp-option

For all dhcp-options (where X is the option position in the PUSH).

With some additional debugging in update-systemd-resolved, I was able to confirm that these options get swallowed by openvpn and aren't passed as foreign_option_ at all. As a workaround, I'm calling update-systemd-resolved with a wrapper that looks something like:

#!/usr/bin/env bash

export foreign_option_100="dhcp-option DOMAIN domain.com"
export foreign_option_101="dhcp-option DOMAIN-SEARCH domain.com. domain.net. domain.org."

$(dirname $0)/update-systemd-resolved $@

Seems to work, although the search list ends up in the systemd generated resolve file as fqdn.com.\x032fqdn.net.\x032fqdn.org. for some reason - I'm not sure what is escaping the spaces, but it does seem to work OK.

Anyway, if anyone has seen this and has a solution, I'd appreciate it - searches have so far not turned up anything. Additionally, perhaps the wrapper is useful to anyone else who needs to inject additional options to update-systemd-resolved.

fixed dns and search domains

I want to set my custom dns server and domains search, is that possible ?

nameserver X.X.X.X
nameserver X.X.X.X
search abc.domain.com def.domain.com domain.com

running the script in docker container

when i tried running this in a container i was blocked by 2 things:
1/ use of logger (that points to /dev/log that does not exist in a container)
2/ use of busctl (which results in Failed to connect to bus: No such file or directory).

i addressed the first by making logger into echo.
the second is more complex :)

is there a way to run it in a container?
if not - what is the equivalent of "busctl call" when running in a container?

how to reproduce:
start a debian 9 container.
sudo apt update
sudo apt install nano less wget dbus openvpn openvpn-systemd-resolved -y
sudo sed -i -e 's/logger -s --id="$$" -t/echo/g' /etc/openvpn/update-systemd-resolved

create config.ovpn and vpn.login

make sure the config has:
script-security 2
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved
down-pre

and then
sudo openvpn --config config.ovpn --auth-user-pass vpn.login > openvpn.log 2>&1 &

the result:

update-systemd-resolved -p user.info -- SetLinkDNS(...)
Failed to connect to bus: No such file or directory
update-systemd-resolved -p user.emerg -- 'busctl' exited with status 1

Installation location inconsistencies

The Makefile installs the script to /etc/openvpn/scripts/update-systemd-resolved but the AUR package installs to /etc/openvpn/update-systemd-resolved and the documentation in the README.md also assumes that this is where the script is installed to. I suggest that either the Makefile is updated or the AUR package and documentation are so that the installation location and instructions are consistent regardless of what method is used for installation.

DNS failing

package's version:
openvpn-systemd-resolved: 1.3.0-3
openvpn: 2.4.7-1ubuntu2

root@xps-13:~# openvpn --version
OpenVPN 2.4.7 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Sep  5 2019
library versions: OpenSSL 1.1.1c  28 May 2019, LZO 2.10
Originally developed by James Yonan
Copyright (C) 2002-2018 OpenVPN Inc <[email protected]>
Compile time defines: enable_async_push=no enable_comp_stub=no enable_crypto=yes enable_crypto_ofb_cfb=yes enable_debug=yes enable_def_auth=yes enable_dependency_tracking=no enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown enable_fast_install=needless enable_fragment=yes enable_iproute2=yes enable_libtool_lock=yes enable_lz4=yes enable_lzo=yes enable_maintainer_mode=no enable_management=yes enable_multihome=yes enable_pam_dlopen=no enable_pedantic=no enable_pf=yes enable_pkcs11=yes enable_plugin_auth_pam=yes enable_plugin_down_root=yes enable_plugins=yes enable_port_share=yes enable_selinux=no enable_server=yes enable_shared=yes enable_shared_with_static_runtimes=no enable_silent_rules=no enable_small=no enable_static=yes enable_strict=no enable_strict_options=no enable_systemd=yes enable_werror=no enable_win32_dll=yes enable_x509_alt_username=yes with_aix_soname=aix with_crypto_library=openssl with_gnu_ld=yes with_mem_check=no with_sysroot=no

config file

client
dev tun
proto udp
remote vpn.xxx.com 1194
resolv-retry infinite
nobind
;user nobody
;group nobody
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
comp-lzo
;pull dhcp-options

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

starting

root@xps-13:~# openvpn xxxVPN.ovpn 
Wed Jan  1 12:35:11 2020 OpenVPN 2.4.7 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Sep  5 2019
Wed Jan  1 12:35:11 2020 library versions: OpenSSL 1.1.1c  28 May 2019, LZO 2.10
Wed Jan  1 12:35:11 2020 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Wed Jan  1 12:35:11 2020 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Wed Jan  1 12:35:11 2020 TCP/UDP: Preserving recently used remote address: [AF_INET]18.228.104.124:1194
Wed Jan  1 12:35:11 2020 UDP link local: (not bound)
Wed Jan  1 12:35:11 2020 UDP link remote: [AF_INET]x.x.x.x:1194
Wed Jan  1 12:35:13 2020 [server] Peer Connection Initiated with [AF_INET]18.228.104.124:1194
Wed Jan  1 12:35:14 2020 TUN/TAP device tun0 opened
Wed Jan  1 12:35:14 2020 /sbin/ip link set dev tun0 up mtu 1500
Wed Jan  1 12:35:14 2020 /sbin/ip addr add dev tun0 local 10.99.0.42 peer 10.99.0.41
Wed Jan  1 12:35:14 2020 /etc/openvpn/update-resolv-conf tun0 1500 1553 10.99.0.42 10.99.0.41 init
dhcp-option DNS 10.104.1.130
Wed Jan  1 12:35:19 2020 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Wed Jan  1 12:35:19 2020 Initialization Sequence Completed

resolv.conf after connecting

root@xps-13:~$ 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 10.104.1.130
nameserver 127.0.0.53
search home tendawifi.com

then some how DNS is resolved

root@xps-13:~# nslookup kibana-teahupoo.aws.xxx.com
Server:     10.104.1.130
Address:    10.104.1.130#53

Non-authoritative answer:
kibana-teahupoo.aws.xxx.com canonical name = kibana-prod.aws.xxx.com.
Name:   kibana-prod.aws.xxx.com
Address: 10.103.4.184

but not for ping

root@xps-13:~# ping kibana-teahupoo.aws.xxx.com
ping: kibana-teahupoo.aws.xxx.com: Name or service not known

or browser

This site can’t be reached kibana-teahupoo.aws.xxx.com’s server IP address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN

systemd-resolve --status

root@xps-13:~$ systemd-resolve --status
Global
       LLMNR setting: no
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 10.104.1.130
         DNS Servers: 10.104.1.130
          DNS Domain: tendawifi.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 (tun0)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 2 (wlp2s0)
      Current Scopes: DNS
DefaultRoute setting: yes
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 192.168.5.1
         DNS Servers: 192.168.5.1
          DNS Domain: ~.
                      tendawifi.com

Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.

root@xps-13:/etc/openvpn# systemctl status systemd-resolved.service
● systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-01-02 09:58:48 CET; 25min ago
     Docs: man:systemd-resolved.service(8)
           https://www.freedesktop.org/wiki/Software/systemd/resolved
           https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
           https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
 Main PID: 12478 (systemd-resolve)
   Status: "Processing requests..."
    Tasks: 1 (limit: 4915)
   Memory: 3.1M
   CGroup: /system.slice/systemd-resolved.service
           └─12478 /lib/systemd/systemd-resolved

ene 02 10:17:07 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:17:07 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:17:15 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:18:41 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:18:41 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:18:41 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:19:02 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:19:02 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:19:02 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
ene 02 10:19:12 xps-13 systemd-resolved[12478]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.

any clue ?
same config is running fine on a debian 10
this is a Ubuntu 19.10

Pushed DNS servers are added at the end of the list and not used as a result

The script is run, but when I investigated resolv.conf I find this::

nameserver 8.8.8.8 <- manually added to systemd config
nameserver 8.8.4.4 <- manually added to systemd config
nameserver a.b.c.d <- pushed by ISP
# Too many DNS servers configured, the following entries may be ignored.
nameserver e.f.g.h  <- pushed by ISP
nameserver 1.1.1.1 <- pushed by OpenVPN
nameserver 1.0.0.1 <- pushed by OpenVPN

This has 2 issues:

  1. DNSes provided by VPN are not used
  2. DNS leak occurs

IMO the script should replace DNS servers somehow, or at least provide an option to do this.

DNS leakage on Ubuntu 18.10.

I'm experiencing DNS leakage using this script in which the IP addresses of my ISP's DNS servers are visible. Strangely, the IP addresses of my VPN's DNS servers are also visible. I'm running an OpenVPN server connected to a Comcast router.

From DNS Leak Test:

IP Hostname ISP
208.67.219.70 m41.pao.opendns.com OpenDNS, LLC
208.67.219.14 m4.pao.opendns.com OpenDNS, LLC
76.96.15.73 sjos-cns05.nlb.sjc1.comcast.net Comcast Cable
208.67.219.29 m21.pao.opendns.com OpenDNS, LLC
... ... ...

systemd-resolve --status reports that everything is fine with the tunnel, so I assume I'm leaking traffic to some other interface:

Global
       LLMNR setting: no
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
          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 4 (tun0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 208.67.220.220
         DNS Servers: 208.67.222.222
                      208.67.220.220
          DNS Domain: ~.

Link 3 (wlp4s0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 75.75.76.76
         DNS Servers: 75.75.75.75
                      75.75.76.76
                      2001:558:feed::1
                      2001:558:feed::2
          DNS Domain: ~.
                      hsd1.ca.comcast.net

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

OpenVPN client configuration:

...
script-security 2
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved
down-pre

# Prevent DNS leakage.
dhcp-option DOMAIN-ROUTE .

I know very little about networking, so I apologize if this is a trivial issue. Any insight would be greatly appreciated.

Multiple DNS domains

I have a case where there are 2 DNS Servers, lets say, 192.168.20.20 and 10.1.10.10. There are also 2 domains domain1.local and domain2.local. When the script resolves it creates a link between both servers and a link for the first domain. But it won't link the second domain.

Following the log:
Mon Nov 5 01:10:23 2018 /etc/openvpn/scripts/update-systemd-resolved tun0 1500 1560 10.15.1.2 255.255.255.0 init
<14>Nov 5 01:10:23 update-systemd-resolved: Link 'tun0' coming up
<14>Nov 5 01:10:23 update-systemd-resolved: Adding IPv4 DNS Server 192.168.20.20
<14>Nov 5 01:10:23 update-systemd-resolved: Adding IPv4 DNS Server 10.1.10.10
<14>Nov 5 01:10:23 update-systemd-resolved: Setting DNS Domain domain1.local
<14>Nov 5 01:10:23 update-systemd-resolved: SetLinkDNS(11 2 2 4 192 168 20 20 2 4 10 1 10 10)
<14>Nov 5 01:10:23 update-systemd-resolved: SetLinkDomains(11 1 domain1.local false)

Any ideas?

Add instructions on how to route all requests through vpn connection

Great script!

Just a documentation request:

By default, systemd-resolved queries all interfaces. If you want to avoid dns leak, it seems you need to force it to only use the link created by openvpn. It seems it is a simple a using "dhcp-option DOMAIN-ROUTE ." in your config file -- that is a dot/period instead of a specific domain name. The dot/period matches all domain names.

I think it would be nice to add that as an example in the documentation since this is the behavior a lot of people want.

I would also put a note to remind people that on the client side, it is only dhcp-option xxx that you put, not push "dhcp-option xxx"

To summarize this is what I added to my client config (added the first line to your instructions)

dhcp-option DOMAIN-ROUTE .
script-security 2
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved
down-pre

Add common file

Would you consider adding a file containing the extra config needed?

script-security 2
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
up /etc/openvpn/scripts/update-systemd-resolved
down /etc/openvpn/scripts/update-systemd-resolved
down-pre

So that when installing the Arch AUR package, instead of needing to change any .conf files or add all those separate config parameters to the openvpn command, we could just add --config ../scripts/common.conf (assuming the file is in /etc/openvpn/scripts/common.conf) to the end of the ExecStart line in /usr/lib/systemd/system/[email protected] and it would work. That way the file would be kept up-to-date here.

Or is this something I need to ask to the AUR package maintainer?

Support Multiple Search Domains

The script seems to support only 1 (the last) search domain even when multiple are passed in the openvpn push / pull options
...
<14>Jun 17 11:56:17 update-systemd-resolved: Link 'tun0' coming up
<14>Jun 17 11:56:17 update-systemd-resolved: Adding IPv4 DNS Server 10.10.10.1
<14>Jun 17 11:56:17 update-systemd-resolved: Adding IPv4 DNS Server 10.10.10.2
<14>Jun 17 11:56:17 update-systemd-resolved: Adding IPv4 DNS Server 10.10.10.3
<14>Jun 17 11:56:17 update-systemd-resolved: Setting DNS Domain foo.bar.example.com
<14>Jun 17 11:56:17 update-systemd-resolved: Setting DNS Domain bar.example.com
<14>Jun 17 11:56:17 update-systemd-resolved: Setting DNS Domain example.com
<14>Jun 17 11:56:17 update-systemd-resolved: SetLinkDNS(7 3 2 4 10 10 10 1 2 4 10 10 10 2 2 4 10 10 10 3)
<14>Jun 17 11:56:17 update-systemd-resolved: SetLinkDomains(7 1 example.com false)
...

$ systemd-resolve --status
...
Link 6 (tun0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 10.10.10.1
10.10.10.2
10.10.10.3
DNS Domain: example.com
...

(Names and IPs changed to protect the innocent)

Flush DNS cache on add/remove DNS server

A workflow for a user using a VPN might go like this:

  • Not connected to VPN
  • Attempt to visit website
  • systemd-resolved resolves website and caches result
  • Find website is blocked by ISP
  • Connect to VPN, using this script to get DNS servers from VPN
  • Attempt to visit website again to avoid blocking

However, because systemd-resolved has cached the DNS request from the previous attempt, the visit to the website fails.

One can work around this manually by systemd-resolved --flush-cache

It seems more appropriate to invalidate the DNS cache every time this script adds/removes a DNS server so that systemd-resolved will attempt to resolve DNS requests with the newly provided VPN DNS servers when required.

Please have the script flush systemd-resolved DNS cache on every add/remove.

pre-down is an "Unrecognized option or missing parameter"

It looks like this was updated a couple days ago, so I may be doing something wrong with my configuration, but openvpn isn't recognizing pre-down as valid. It is (predictably) not a valid route-pre-down script, and a simple down fails out since tun0, as expected, does not exist. I could not find a mention of pre-down in the man pages anywhere.

I have not had much time to poke at the manual, but could we write a complementary route-pre-down to handle this?

OpenVPN 2.3.11
iproute2 4.7.0
systemd 231

Invalid device name: 'tun0'

Hi,

I get the above error when trying to start the openvpn-client service. When using update-resolv-conf.sh instead it starts up correctly (ignoring DNS issues).

systemd-resolved configuration lost when disconnecting network in NetworkManager

Hey!

This issue may not be 100% related to update-systemd-resolved, but I've noticed that when disconnecting any network (eg. wireless one, not tun/tap) in NetworkManager, systemd-resolved configuration set by update-systemd-resolved is lost:

$ systemd-resolve --status | grep -i tun0 -A 7
Link 62 (tun0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 10.0.0.1
          DNS Domain: something.tld

$ nmcli d disconnect wlp4s0
Device 'wlp4s0' successfully disconnected.

$ systemd-resolve --status | grep -i tun0 -A 7
Link 62 (tun0)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

$ nmcli d connect wlp4s0
Device 'wlp4s0' successfully activated with '7522603b-237a-46f5-a8f9-e501b9b7a16a'.

$ systemd-resolve --status | grep -i tun0 -A 7
Link 62 (tun0)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

My OpenVPN client has persist-tun option turned on. VPN connection works perfectly fine after reconnection. OpenVPN client restart fixes it of course.

Is there anyone aware of a way to fix this?

$ NetworkManager -V
1.10.6
$ systemd-resolve --version
systemd 237
$ lsb_release -d
Description:    Ubuntu 18.04 LTS

Not a recognized DHCP setting: 'DISABLE-NBT'

I have pasted this into my ovpn file:

script-security 2
up /etc/openvpn/scripts/update-systemd-resolved 
down-pre /etc/openvpn/scripts/update-systemd-resolved
push "dhcp-option DNS 8.8.8.8"

I want to set the DNS Server to 8.8.8.8.
But when i run the openvpn file, i get this output.

Wed Mar 15 13:02:55 2017 /etc/openvpn/scripts/update-systemd-resolved tun0 1500 1570 25.0.8.6 255.255.255.0 init
<14>Mar 15 13:02:55 update-systemd-resolved[5469]: Link 'tun0' coming up
<14>Mar 15 13:02:55 update-systemd-resolved[5469]: Adding IPv4 DNS Server 25.0.0.1
<12>Mar 15 13:02:55 update-systemd-resolved[5469]: Not a recognized DHCP setting: 'DISABLE-NBT'
<14>Mar 15 13:02:55 update-systemd-resolved[5469]: SetLinkDNS(12 1 2 4 25 0 0 1)

I don't know why the dns server is always set to 25.0.0.1 .

Would be nice if you could help

authselect user-nsswitch.conf in Fedora

Fedora is offering authselect as configuration tool for /etc/nsswitch.conf. Using it would involve putting custom configuration into /etc/authselect/user-nsswitch.conf.

This has been found after seeing erranous behaviour of DNS resolution after introducing these scripts and implied changes to the system.

More is documented in

Reverse DNS lookup not working on local IPs

Hi @jonathanio , thanks very much for your script. I've used it for some time and it addresses DNS leakage issues for me when using OpenVPN.

One behaviour though I have noticed is that using the DOMAIN ROUTE . option breaks local reverse DNS lookup. When I don't have OpenVPN running (and the script has not updated the DNS servers), I can happily do a reverse DNS lookup on local IPs. However, when the script does its work, local reverse DNS queries do not make it to the gateway (local DNS server) - they instead go over the OpenVPN tunnel and as a result return NXDOMAIN.

I realise the behaviour of DOMAIN ROUTE . is to ensure that all DNS queries not related to the DNS domain specifically associated with another interface, are routed to the default route interface. Local domain name lookups work fine, since my local domain is listed on the non-tunnel interface as the DNS domain. Is there some way of replicating that behaviour for reverse DNS lookups? That is, I want both DNS lookups on local domain names, and reverse DNS lookups on local IPs, to be directed to the local DNS server, rather than going down the tunnel.

Thanks!

Can't update DNS using OpenVPN

Hi,

I'm having an issue despite following the setup. I'm currently running Ubuntu 16.04 Xenial and using openvpn.

I'm having DNS issues connecting to some AWS hosted applications.

I've installed the update-systemd-resolved binaries and enabled/started the service. Also added the following config to my *.ovpn configuration file:

setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
script-security 2
up /etc/openvpn/scripts/update-systemd-resolved
down /etc/openvpn/scripts/update-systemd-resolved
down-pre

And this to my /etc/nsswitch.conf:

# Use systemd-resolved first, then fall back to /etc/resolv.conf
hosts: files resolve dns myhostname
# Use /etc/resolv.conf first, then fall back to systemd-resolved
hosts: files dns resolve myhostname

When I start the openvpn with my credentials, I can definitely see that the UP/DOWN scripts have been added:

UP:

Wed Oct 18 15:18:33 2017 us=576640 /etc/openvpn/scripts/update-systemd-resolved tun0 1500 1544 11.185.11.138 11.185.11.137 init
<14>Oct 18 15:18:33 update-systemd-resolved: Link 'tun0' coming up
<14>Oct 18 15:18:33 update-systemd-resolved: Adding IPv4 DNS Server xxx.x.x.x (dns name server ip)
<14>Oct 18 15:18:33 update-systemd-resolved: SetLinkDNS(21 1 2 4 10 185 0 2)

Wed Oct 18 15:18:21 2017 us=776291   up_script = '/etc/openvpn/scripts/update-systemd-resolved'

DOWN:

Wed Oct 18 15:18:53 2017 us=130312 /etc/openvpn/scripts/update-systemd-resolved tun0 1500 1544 11.185.11.138 11.185.11.137 init
<14>Oct 18 15:18:53 update-systemd-resolved: Link 'tun0' going down

Wed Oct 18 15:18:21 2017 us=776296   down_script = '/etc/openvpn/scripts/update-systemd-resolved'

However I don't see any changes to my /etc/resolv.conf file, I was expecting to see something like

nameserver xxx.x.x.x in there with my DNS nameserver

But all I see is:

nameserver 192.168.72.8

And I still can't resolv the DNS for my AWS hosted apps, any suggestions?

`busctl' exited with status 1

On my Debian system fails with this:
...
<14>Sep 1 22:16:26 update-systemd-resolved[1320]: Adding IPv4 DNS Server 193.181.14.10
<14>Sep 1 22:16:26 update-systemd-resolved[1320]: Adding IPv4 DNS Server 193.181.14.11
<14>Sep 1 22:16:26 update-systemd-resolved[1320]: SetLinkDNS(7 2 2 4 193 181 14 10 2 4 193 181 14 11)
Link tun0 is managed.
<8>Sep 1 22:16:26 update-systemd-resolved[1320]: `busctl' exited with status 1
Thu Sep 1 22:16:26 2016 WARNING: Failed running command (--up/--down): external program exited with error status: 1
Thu Sep 1 22:16:26 2016 Exiting due to fatal error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.