#StandWithUkraine
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.
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):
domain.loc 127.0.0.1 | |
workspace1.domain.loc 127.0.0.1 | |
workspace2.domain.loc 127.0.0.1 | |
workspace3.domain.loc 127.0.0.1 |
Or multinode scaled DNS-based app. All these cases make management via editing /etc/hosts
file not super handly
Create file ./bind_inventory/run_bind.sh
:
#!/bin/bash | |
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 127.0.0.1:53:53/udp --restart=always -d tracklify_local_bind |
./bind_inventory/Dockerfile
:
FROM jpillora/dnsmasq | |
ADD dnsmasq.conf /etc/dnsmasq.conf |
./bind_inventory/dnsmasq.conf
:
# this is file with DNS rules, here we map all domain.loc and subdomains to 127.0.0.1 | |
address=/domain.loc/127.0.0.1 |
Run DNS container:
./bind_inventory/run_bind.sh
Replace Resolve
record in /etc/systemd/resolved.conf
to look like:
[Resolve] | |
DNS=127.0.0.1 | |
Domains=~. | |
DNSStubListener=yes | |
#FallbackDNS= | |
#LLMNR=no | |
#MulticastDNS=no | |
#DNSSEC=no | |
#DNSOverTLS=no | |
#Cache=no-negative | |
#ReadEtcHosts=yes |
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.