Skip to content

Instantly share code, notes, and snippets.

@beslovas
Last active July 12, 2022 09:20
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment