[meta-virtualization] [PATCH 4/4] dnsmasq: allow net interfaces to config their own dnsmasq instance

Mark Asselstine mark.asselstine at windriver.com
Tue Nov 22 10:56:16 PST 2016


This addition to dnsmasq allows an interface to define a dnsmasq
configuration file as /var/lib/dnsmasq/%i/dnsmasq.conf and have their
dnsmasq instance controlled via systemctl dnsmasq@%i.service (where
'%i' is the interface name).

To use this simply create the dnsmasq.conf file as above and enable
the systemd service like:

Signed-off-by: Mark Asselstine <mark.asselstine at windriver.com>
---
 recipes-support/dnsmasq/dnsmasq/dnsmasq at .service | 12 ++++++++++++
 recipes-support/dnsmasq/dnsmasq_2.%.bbappend     | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 recipes-support/dnsmasq/dnsmasq/dnsmasq at .service
 create mode 100644 recipes-support/dnsmasq/dnsmasq_2.%.bbappend

diff --git a/recipes-support/dnsmasq/dnsmasq/dnsmasq at .service b/recipes-support/dnsmasq/dnsmasq/dnsmasq at .service
new file mode 100644
index 0000000..9e36a36
--- /dev/null
+++ b/recipes-support/dnsmasq/dnsmasq/dnsmasq at .service
@@ -0,0 +1,12 @@
+[Unit]
+Description=DHCP and DNS caching server for %i.
+After=network.target
+
+[Service]
+ExecStart=/usr/bin/dnsmasq -k --conf-file=/var/lib/dnsmasq/%i/dnsmasq.conf
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=on-failure
+RestartSec=5
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-support/dnsmasq/dnsmasq_2.%.bbappend b/recipes-support/dnsmasq/dnsmasq_2.%.bbappend
new file mode 100644
index 0000000..2acfd0c
--- /dev/null
+++ b/recipes-support/dnsmasq/dnsmasq_2.%.bbappend
@@ -0,0 +1,16 @@
+# Allow individual network interfaces to easily configure
+# their own dnsmasq instance.
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += " \
+    file://dnsmasq@.service \
+    "
+
+do_install_append() {
+    install -d ${D}/${sysconfdir}/systemd
+    install -d ${D}/${sysconfdir}/systemd/system
+    install -m 644 ${WORKDIR}/dnsmasq at .service ${D}/${sysconfdir}/systemd/system/.
+}
+
+FILES_${PN} += "${sysconfdir}/systemd/system/dnsmasq at .service"
-- 
2.7.4



More information about the meta-virtualization mailing list