Skip to content

Latest commit

 

History

History
57 lines (38 loc) · 1.45 KB

dns.md

File metadata and controls

57 lines (38 loc) · 1.45 KB

DNS

There is dozen of possibilities to avoid to touch host file and benefit from domain wilcards.

I use dnsmasq, a small dns server.

Linux way

Arch and Debian comes with a dnsmasq packaged with the NetworkManager utility.

To redirect all your local domains (ie. *.test),

1 - Check NetworkManager use dnsmasq as DNS resolver:

File: /etc/NetworkManager/NetworkManager.conf

[main]
dns=dnsmasq

2 - Add an entry to /etc/NetworkManager/dnsmasq.d/ and restart NetworkManager:

# echo "address=/test/127.0.0.1" > /etc/NetworkManager/dnsmasq.d/docker
# systemctl restart NetworkManager

3 - Verify /etc/resolv.conf content, it should be:

search home
nameserver 127.0.0.1

macOS way

macOS doesn't bundle dnsmasq but we can install it via homebrew. First you need to know IP address of your running docker-machine.

$ brew update
$ brew install dnsmasq
$ echo "address=/test/$(docker-machine ip xxx)" > /usr/local/etc/dnsmasq.conf
$ sudo mkdir -p /etc/resolver
$ sudo tee /etc/resolver/test >/dev/null <<EOF
nameserver 127.0.0.1
EOF
$ sudo brew services start dnsmasq

More info here and there.

Docker way

Not tested but it seems an interesting way to do it, read here.