Last Updated: February 25, 2016
·
2.123K
· keplrz

Set up wildcard subdomains with dnsmasq on archlinux

Install dnsmasq on archlinux:

$ sudo pacman -S dnsmasq

Edit /etc/dnsmasq.conf. The example map foo.bar and its subdomains to localhost:

# /etc/dnsmasq.conf

address=/foo.bar/127.0.0.1
...
listen-address=127.0.0.1

Put following line into /etc/resolv.conf.head to make the first nameserver in /etc/resolv.conf point to localhost:

nameserver 127.0.0.1

Restart the network, or you will need to put above line into /etc/resolv.conf manually.

Start, stop or restart dnsmasq:

$ sudo systemctl start dnsmasq
$ sudo systemctl stop dnsmasq
$ sudo systemctl restart dnsmasq

Enable dnsmasq at startup:

$ sudo systemctl enable dnsmasq

Done.