Skip to content

Instantly share code, notes, and snippets.

@beslovas
Last active September 30, 2024 08:09
Show Gist options
  • Save beslovas/d7c7fdf2c8262f7a2aabf68369a5c7aa to your computer and use it in GitHub Desktop.
Save beslovas/d7c7fdf2c8262f7a2aabf68369a5c7aa to your computer and use it in GitHub Desktop.
Wildcard DNS for localhost on linux distributions running systemd-resolved

Setup wildcard DNS on localhost using systemd-resolved and dnsmasq

Tested distributions

Ubuntu 20.04 
Linux Mint 20+

systemd-resolved

mkdir /etc/systemd/resolved.conf.d

cat << EOF > /etc/systemd/resolved.conf.d/docker.conf
[Resolve]
DNS=127.0.0.1
Domains=~docker
EOF

service systemd-resolved restart

dnsmasq

apt install dnsmasq

echo -e "bind-interfaces\naddress=/docker/127.0.0.1\n\n$(cat /etc/dnsmasq.conf)" > /etc/dnsmasq.conf

systemctl enable dnsmasq.service
@stephdl
Copy link

stephdl commented Sep 30, 2024

thanks it made my day :p

I added no-resolv to dnsmasq.conf to avoid to query back systemd-resolved for the dns query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment