Creating a wildcard DNS lookup for .local pointing to 127.0.01

To allow you to create dynamic on the fly dev hosts. This is part of a bigger post coming soon..  The end goal is to document how I create a new vhost in my local nginx configuration just by creating a new directory.

For the DNS,  I need every *.local subdomain to resolve to 127.0.0.1 without me having to go into /etc/hosts and add it each time.

In /etc/dnsmasq.conf

listen-address=127.0.0.1
port=53
address=/.local/127.0.0.1
bind-interfaces
server=8.8.8.8

In /etc/systemd/resolved.conf

DNSStubListener=no

In /etc/resolv.conf

nameserver 127.0.0.1

Then restart both services.

sudo systemctl restart NetworkManager
systemctl restart dnsmasq

If restarting network manager causes the /etc/resolv.conf settings to be overwritten.  Edit /etc/NetworkManager/NetworkManager.conf and add this line

[main]
dns=none

If lookup doesn’t work for applications and utilities such as curl and wget. But nslookup works then check out
/etc/nsswitch.conf

If the hosts: line looks like this?
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname
Then move the dns to before the NOTFOUND section and reboot.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.