brew install dnsmasq
I will run my dnsmasq nameserver locally under 127.0.0.1:53 and will resolve a wildcard domain *.ml-dev.test
to an local IP. Look for the line listen-address
and address
sudo vim /opt/homebrew/etc/dnsmasq.conf
- Update the config file as following
#except-interface=
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
#listen-address=
listen-address=127.0.0.1
....
# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
#address=/double-click.net/127.0.0.1
address=/.localtest.me/10.0.0.18
- Make sure there is no other dnsmasq service is running
ps aux | grep dnsmasq
dnguyen 16635 0.5 0.0 407962096 112 s025 U+ 11:15AM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox dnsmasq
- Launch dnsmasq with sudo
sudo brew services start dnsmasq
dnguyen 16635 0.5 0.0 407962096 112 s025 U+ 11:15AM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox dnsmasq
nobody 16065 0.2 0.0 408665232 944 ?? Ss 11:12AM 0:00.23 /opt/homebrew/opt/dnsmasq/sbin/dnsmasq --keep-in-foreground -C /opt/homebrew/etc/dnsmasq.conf -7 /opt/homebrew/etc/dnsmasq.d,*.conf
$ dig wow.localtest.me @127.0.0.1
; <<>> DiG 9.10.6 <<>> wow.ml-dev.test @127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61146
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;wow.localtest.me. IN A
;; ANSWER SECTION:
wow.localtest.me. 0 IN A 10.0.0.18
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jan 10 11:20:47 PST 2024
;; MSG SIZE rcvd: 60
- Create a directory
/etc/resolver
and add the new file/etc/resolver/ml-dev.test
nameserver 127.0.0.1
- Test if Mac's using your dnsmasq server
sudo dscacheutil -flushcache
$ dscacheutil -q host -a name argocd.localtest.me
name: argocd.localtest.me
ip_address: 10.0.0.18