Chozmao / MyBlog

0 stars 0 forks source link

RDNSSD installation on Ubuntu 20.04 and set to work with systemd.resolve service #9

Closed Chozmao closed 3 years ago

Chozmao commented 3 years ago

rdnssd introduction

rdnssd is a daemon program providing client-side support for DNS configuration using the Recursive DNS Server (RDNSS) option, as described in RFC 5006. Its purpose is to supply IPv6 DNS resolvers through stateless autoconfiguration, carried by Router Advertisements.

rdnssd installation

sudo apt install -y rdnssd

rdnssd configuration

In order to make rdnssd work with systemd.resolve service on Ubuntu 20.04 (resolvconf service on old Ubuntu version), we have to modify the hook file of rdnssd (/etc/rdnssd/merge-hook). merge-hook is a script, which will be called whenever its own resolv.conf (/var/run/rdnssd/resolv.conf) is updated. And this script will overwrite the /etc/resolv.conf file. This action causes a problem on Ubuntu 20.04, because /etc/resolv.conf is symlinked from /run/sysmted/resolve/resolv.conf. Symlink is broken after that.

ls -l /etc/resolv.conf 
lrwxrwxrwx 1 root root 32 Mai 20 15:09 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf

As a workaround, we change the merge-hook file to make it write the /run/systemd/resolve/resolv.conf file instead of the /etc/resolv.conf file. This prevent the symlink to be broken.

vim /etc/rdnssd/merge-hook
    # change the sysconfdir path to point to systemd.resolve
    #sysconfdir='/etc'
    sysconfdir='/run/systemd/resolve'

Note: to enable stateless address auto configuration (SLAAC) for IPv6 on Ubuntu, run commands:

echo 1 > /proc/sys/net/ipv6/conf/$interface/autoconf
echo 2 > /proc/sys/net/ipv6/conf/$interface/accept_ra

​ to disable:

echo 0 > /proc/sys/net/ipv6/conf/$interface/autoconf
echo 0 > /proc/sys/net/ipv6/conf/$interface/accept_ra