Spawn local DNS server for development (instead of /etc/hosts file)

Today, 20th March 2023, Ukraine is still bravely fighting for democratic values, human rights and peace in whole world. Russians ruthlessly kill all civilians in Ukraine including childs and destroy their cities. We are uniting against Putinโ€™s invasion and violence, in support of the people in Ukraine. You can help by donating to Ukrainian's army.

Image for a hint

Assume you have to manage multiple domains in your local setup, for example, you have a multi-workspace host-name based app (like web-version of Slack in the past):


Or multinode scaled DNS-based app. All these cases make management via editing /etc/hosts file not super handly

Create file ./bind_inventory/ :

SCRIPTDIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# TODO: add record to /etc/systemd/resolve.conf file
docker build $SCRIPTDIR -t tracklify_local_bind
sudo docker run -p --restart=always -d tracklify_local_bind


FROM jpillora/dnsmasq
ADD dnsmasq.conf /etc/dnsmasq.conf


# this is file with DNS rules, here we map all domain.loc and subdomains to

Run DNS container:


Replace Resolve record in /etc/systemd/resolved.conf to look like:


3. Restart systemd-resolved

sudo systemctl restart systemd-resolved

4. Test if it's working run.

host domain.loc
host sub.domain.loc

In case it didn't work try restarting Linux.

After the restart just test if the host the command returns host for domain.loc domain.

Ivan Borshchov profile picture
Nov 22, 2021
by Ivan Borshchov
Did it help you?
Yes !