Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 660 Bytes

2.2-dns-setup-via-systemd-resolved.md

File metadata and controls

18 lines (14 loc) · 660 Bytes

I hate systemd-resolved.

But if you really want to use it, this should do the trick (use in a cloud-init template):

Configure consul dns via systemd-resolved

cat <<EOF > "/etc/systemd/resolved.conf"
DNS=127.0.0.1
Domains=~consul
EOF

Persist our iptables rules

iptables -t nat -A OUTPUT -d localhost -p udp -m udp --dport 53 -j REDIRECT --to-ports 8600
iptables -t nat -A OUTPUT -d localhost -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 8600
iptables-save > /etc/iptables/iptables.rules

Restart

echo "Restarting systemd-resolved so that consul DNS config takes effect..."
systemctl restart systemd-resolved