3

Setup:

A debian jessie device connection via ppp to the internet

We use systemd-networking and no /etc/network/interface at all.

systemd-resolved is used for DNS.

Versions:

systemctl --version
systemd 230
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
armv7l GNU/Linux
kernel 4.4.14-v7+

(versions are the ones from jessie-backports)

This works fine for Ethernet + W-Lan, but fails for ppp.

Reason: the custom hook up scripts

0000usepeerdns 000resolvconf

are still writing to /etc/resolv.conf instead of connecting to the dbus server systemd-resolved provides.

so i am trying to get the PPP interface to have DNS resolution, which should be possible by calling SetLinkDNS via DBUS from what i did read (links at the end)

Get the interface ID (5 in our case)

ip l
..
5: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 700 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 3                                                         
link/ppp    
..

Read out current status of link interface 5

busctl introspect org.freedesktop.resolve1 /org/freedesktop/resolve1/link/_35 |grep DNS 
.DNS                                property  a(iay)    0                 -

set DNS on Interface 5 with 1 IPV4 Address (google DNS as example) (whats the explanation of the 3rd integer?)

busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' 5 1 2 4 8 8 8 8
Link ppp0 is managed.

Read out values, still empty, so it failed to insert those value.

busctl introspect org.freedesktop.resolve1 /org/freedesktop/resolve1/link/_35 |grep DNS 
.DNS                                property  a(iay)    0  

So how do i debug this further to finally get it working?

falling back to /etc/network/interfaces or a "normal" /etc/resolv.conf is not an option.

Resources i used (plus a lot more but those are the relevant ones):

systemd Github Issue Tracker

freedesktop wiki network manager

jonathanio VPN DNS issue tracker

VPN DNS change script from jonathanio

1
  • 1
    The third integer is the address family (IPv4 = AF_INET = 2, IPv6 = AF_INET6 = 10).
    – LeBlue
    Mar 14, 2018 at 15:50

2 Answers 2

3

the issue was happening because the network was already managed by systemd.

Disabling the management of systemd-resolved in the corresponding /etc/systemd/network/ file.

Reloading and restarting the deamons systemctl daemon-reload systemctl restart systemd-resolved made the error message Link ppp0 is managed disappear.

I figured this out by reading more, asking in the freenode #systemd irc channel ,getting some pointer help there and reading the sourcecode.

Following sets the DNS on the interface 5 to the google DNS

busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' 5 1 2 4 8 8 8 8
1
  • 1
    Note: this issue has been fixed in systemd 243 - now you can set DNS (via resolveconf or D-BUS) for interfaces managed by systemd-networkd as well.
    – god
    Mar 11, 2020 at 10:42
1

Old fixed bugs aside, if you happen to be using systemd-resolved.service, it is much easier today with resolvectl/systemd-resolve (On the system I'm testing on, these two are actually the same executable under different names). The busctl method still works well, though it is a little difficult to remember the syntax, especially for multiple DNS servers.

The examples below assume either 8.8.8.8 as the sole DNS server or 8.8.8.8 with 8.8.4.4. The device being set is also being assumed to be ppp0.

resolvectl

I find this to be the simplest today:

resolvectl dns ppp0 8.8.8.8 8.8.4.4

To view the status:

resolvectl status

systemd-resolve

I haven't found how to assign two DNS server addresses using systemd-resolve, though I suspect it would be simple:

systemd-resolve --interface=ppp0 --set-dns=8.8.8.8

To view the status (note how the output is identical to resolvectl's output):

systemd-resolve --status

busctl

busctl with one DNS server:

busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' $(ip link show dev tun0 | sed 's/:.*//') 1 2 4 8 8 8 8

The syntax of the fields after SetLinkDNS are "signature" 'ia(iay)', "device id" 7 (I had 7 this time, the id you get will differ), "number of DNS Servers" 1, IPv4 addresses seem to require the next two parameters to be 2 and 4, and then finally the four octets of the IP: 8 8 8 8. Thus, for the two DNS servers, you would use:

busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' $(ip link show dev tun0 | sed 's/:.*//') 2 2 4 8 8 8 8 2 4 8 8 4 4

You can get more information about the method/signature via:

busctl introspect org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager

To get the current DNS status:

busctl get-property org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager DNS

There's probably a more direct way to get the device id from /proc/net ; but ip link ... | sed ... was the first that came to mind.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .