Skip to content

Instantly share code, notes, and snippets.

@dargmuesli
Created November 7, 2022 20:12
Show Gist options
  • Save dargmuesli/47f023b093cf0928a9aff3ccc4a4e03a to your computer and use it in GitHub Desktop.
Save dargmuesli/47f023b093cf0928a9aff3ccc4a4e03a to your computer and use it in GitHub Desktop.
DNS setup instructions for development .test TLD resolution on localhost.

DNS

Within development of a DargStack, access to the web apps should be routed via the locally resolved domain [project_name].test and its subdomains. Therefore one needs to configure the local DNS resolution to make this address resolvable. This can either be done by simply adding this domain and all subdomains to the operation system's hosts file or by setting up a local DNS server. An advantage of the latter method is that subdomain wildcards can be used and thus not every subdomain needs to be defined separately.

Here is an example configuration for dnsmasq that uses the local DNS server on top of the router's advertised DNS server:

Instructions for Arch Linux

/etc/dnsmasq.conf

# Files to read resolv configuration from.
conf-file=/etc/dnsmasq-openresolv.conf
resolv-file=/etc/dnsmasq-resolv.conf

# Limit to machine-wide requests.
listen-address=::1,127.0.0.1

# Wildcard DNS.
address=/.test/127.0.0.1

# Enable logging (systemctl status dnsmasq).
#log-queries

/etc/NetworkManager/NetworkManager.conf

[main]

# Don't touch `/etc/resolv.conf`.
rc-manager=resolvconf

/etc/resolvconf.conf

# Limit to machine-wide requests.
name_servers="::1 127.0.0.1"

# Files to output resolv configuration to.
dnsmasq_conf=/etc/dnsmasq-openresolv.conf
dnsmasq_resolv=/etc/dnsmasq-resolv.conf

Then run sudo resolvconf -u!

Instructions for Ubuntu & Debian

/etc/dnsmasq.conf

# Files to read resolv configuration from.
resolv-file=/etc/resolvconf/resolv.conf.d/original

# Limit to machine-wide requests.
listen-address=::1,127.0.0.1

# Wildcard DNS.
address=/.test/127.0.0.1

# Enable logging (systemctl status dnsmasq).
#log-queries

/etc/NetworkManager/NetworkManager.conf

[main]

# Don't touch `/etc/resolv.conf`.
rc-manager=resolvconf
systemd-resolved=false # for Ubuntu and Debian

/etc/resolvconf/resolv.conf.d/head

nameserver=::1
nameserver=127.0.0.1

If on WSL:

/etc/wsl.conf

[network]
generateResolvConf = false

[boot]
command="dpkg-reconfigure --frontend=noninteractive resolvconf && resolvconf -u && service docker start && service dnsmasq start && service resolvconf start"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment