ESC
Start typing to search...

Using NetworkManager with DNSMasq and Slackware

dnsmasq on Slackware 14.2 is compiled without D-Bus.

lab$ dnsmasq -v | grep options Compile time options: IPv6 GNU-getopt no-DBus i18n no-IDN DHCP DHCPv6

The logs show NetworkManager trying to start dnsmasq, but failing:

dnsmasq[4466]: DBus not available: set HAVE_DBUS in src/config.h dnsmasq[4466]: FAILED to start up NetworkManager[3101]: dnsmasq exited with error: Configuration problem (1)

After downloading the source files and SlackBuild resources from a Slackware Mirror, validate the GPG  signature using the provided .asc file. Below are the contents of a directory after I assembled all the required pieces.

lab$ tree dnsmasq dnsmasq |– dnsmasq-2.78.tar.xz |– dnsmasq-2.78.tar.xz.asc |– dnsmasq.SlackBuild |– dnsmasq.leasedir.diff.gz |– doinst.sh.gz |– rc.dnsmasq.gz `– slack-desc

After extracting the Makefile from the dnsmasq source archive, we can see an elegant way of making the necessary changes in order to include D-Bus support.

Variables you may well want to override.

PREFIX = /usr/local BINDIR = $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man LOCALEDIR = $(PREFIX)/share/locale BUILDDIR = $(SRC) DESTDIR = CFLAGS = -Wall -W -O2 LDFLAGS = COPTS = RPM_OPT_FLAGS = LIBS =

We need to create a diff file we can use with the SlackBuild.

— Makefile.orig 2019-06-02 08:40:23.021249785 -0400 +++ Makefile 2019-06-02 08:40:39.254250171 -0400 @@ -26,7 +26,7 @@ DESTDIR = CFLAGS = -Wall -W -O2 LDFLAGS = -COPTS = +COPTS = -DHAVE_DBUS RPM_OPT_FLAGS = LIBS =

Then we modify the SlackBuild:

— dnsmasq.SlackBuild.orig 2019-06-02 06:27:31.409060328 -0400 +++ dnsmasq.SlackBuild 2019-06-02 10:07:21.487373810 -0400 @@ -24,7 +24,7 @@ VERSION=${VERSION:-$(echo dnsmasq-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-1_slack14.2}

-NUMJOBS=${NUMJOBS:-" -j7 “} +NUMJOBS=${NUMJOBS:-” -j2 “}

Automatically determine the architecture we’re building on:

if [ -z “$ARCH” ]; then @@ -54,6 +54,7 @@ -exec chmod 644 {} ;

zcat $CWD/dnsmasq.leasedir.diff.gz | patch -p1 –verbose –backup –suffix=.orig || exit 1 +zcat $CWD/dnsmasq.makefile.diff.gz | patch -p1 –verbose –backup –suffix=.orig || exit 1

make $NUMJOBS all-i18n PREFIX=/usr MANDIR=/usr/man || exit 1 make install-i18n PREFIX=/usr DESTDIR=$PKG MANDIR=/usr/man || exit 1

There are a few configuration options we need to make before we reinstall.

Create a new file under /etc/NetworkManager/conf.d/00-dnsmasq.conf with the following contents:

[main] dns=dnsmasq

Then under /etc/NetworkManager/dnsmasq.d/dnsmasq.conf insert:

listen-address=127.0.0.1 cache-size=1000

Restart NetworkManager.

/etc/rc.d/rc.networkmanager restart

Now we can remove the old instance of dnsmasq and install the patched version:

lab$ upgradepkg –reinstall /tmp/dnsmasq-2.78-x86_64-1_slack14.2.txz

No need to manually start dnsmasq as NetworkManager will work its magic:

NetworkManager[3101]: dns-plugin[0x184a190]: starting dnsmasq… dnsmasq[8946]: started, version 2.78 cachesize 1000 dnsmasq[8946]: compile time options: IPv6 GNU-getopt DBus i18n no-IDN … dnsmasq[8946]: DBus support enabled: connected to system bus

When all of that is complete you may want to blacklist dnsmasq from being updated automatically.

Edit /etc/slackpkg/blacklist and add ‘dnsmasq‘ to the end of the file.

Now if everything worked /etc/resolv.conf should contain the loopback address and the logs should show the configuration options chosen for dnsmasq.

Thanks for reading.

Share