dnsmasq forwarding zones

If you are using dnsmasq and need to forward a DNS zone to a specific DNS server, add this to your /etc/dnsmasq.conf


If you don’t have the file /etc/dnsmasq.conf check for directory /etc/dnsmasq.d and there create a file named /etc/dnsmasq.d/my-zones with the content of your zones

That means that requests made do *.test will be forwarded to for *.sopas to and so on

In case you have the file /etc/resolv.conf it probably contains a like this:


That means that you “probably” you are using dnsmasq.

dnsmasq –test

To check configuration file(s) syntax, execute:

$ dnsmasq --test

After doing this, you can test by doing a ping or dig, example:

dig @ my-app.test +short

assuming is running dnsmasq

To test that your domain can be resolved from the specified DNS’s:

dig @ domain.test +short

A full /etc/dnsmasq.conf example:

# send 'domain=home.lan' in DHCP response so that machines
# configured through DHCP will come under 'home.lan' domain.

# will not read /etc/resolv.conf to get upsteram nameservers

# Tells dnsmasq to forward anything with the domain of test to dns server

# upstream nameserver

# Listen to requests only coming from the local machine

# cache 1000 names

Find the --conf-dir

In some systems the dnsmasq.conf in not located in /etc/dnsmasq.conf to find what --config-dir is used, you can try to do this:

$ ps -ef | grep -i dnsmasq
nbody    3655  1056  0 09:00 ?        00:00:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address= --cache-size=0 --conf-file=/dev/null --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d

In this example the configuration directory is: --conf-dir=/etc/NetworkManager/dnsmasq.d

For getting the command line arguments passed to a running process this can be used:

$ ps -fp <pid>

or if you have a procfs:

$ cat /proc/<pid>/cmdline