[Dnsmasq-discuss] Reload dnsmasq when systemd-networkd.service receives a new IPv6 prefix and assigns IPv6 address for it

M. Buecher maddes+dnsmasq at maddes.net
Sat Sep 2 12:50:58 BST 2017


Hi everybody,

dnsmasq is used in my small LAN at home and it provides static interface 
ids to a few servers for Global Unicast Addresses (GUA, 2000::/3) too.
The GUA prefix from my ISP is advertised via RA by my router (M+O+A 
flags set).
As the prefix from my ISP changes from time to time I restart dnsmasq 
manually so that it reads the new prefix via the dhcp-range constructor 
method.
Of course I would prefer that this would happen automatically.

Has anyone setup such an similar automatic reloading on a new prefix?

OS is Raspbian 9.0 "Stretch" (Debian derivative).
Network config via systemd-networkd.service and *not* Debian's default 
ifupdown legacy compatibility networking.service.
Another possible alternative would be dhcpcd [https://roy.marples.name].

Kind regards
Maddes


>>> /etc/systemd/network/ethernet.network:
[Match]
Name=en*

[Network]
IPv6AcceptRA=yes
LinkLocalAddressing=ipv6
IPv6Token=::a:b:c:d
IPv6PrivacyExtensions=yes

[Address]
## ULA
Address=fd00:1:2:3:a:b:c:d/64


>>> /lib/systemd/system/dnsmasq.service:
[Unit]
Description=dnsmasq - A lightweight DHCP and caching DNS server
Requires=network.target
Wants=nss-lookup.target
Before=nss-lookup.target
After=network.target

[Service]
Type=forking
PIDFile=/run/dnsmasq/dnsmasq.pid

# Test the config file and refuse starting if it is not valid.
ExecStartPre=/usr/sbin/dnsmasq --test

# We run dnsmasq via the /etc/init.d/dnsmasq script which acts as a
# wrapper picking up extra configuration files and then execs dnsmasq
# itself, when called with the "systemd-exec" function.
ExecStart=/etc/init.d/dnsmasq systemd-exec

# The systemd-*-resolvconf functions configure (and deconfigure)
# resolvconf to work with the dnsmasq DNS server. They're called liek
# this to get correct error handling (ie don't start-resolvconf if the
# dnsmasq daemon fails to start.
ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf


ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target





More information about the Dnsmasq-discuss mailing list