Sometimes you need to use DNS on non-standard port. MacOS does not allow that. The following recipe helps to overcome this restriction.
First, install dnsmasq:
brew install dnsmasq
Second, edit /usr/local/etc/dnsmasq.conf:
port=53
bogus-priv
resolv-file=/usr/local/etc/resolv.conf
no-poll
server=/service.consul/2a04:AAAA:AAAA::BBBB:1#8600
listen-address=127.0.0.1
In the example above, I configure the search domain service.consul to be resolved via Consul at IPv6 address 2a04:AAAA:AAAA::BBBB:1 and port 8600.
Third, place your name servers in /usr/local/etc/resolv.conf:
nameserver 2a04:AAAA:AAAA::2
nameserver 8.8.8.8
nameserver 8.8.4.4
Fourth, start the service:
sudo brew services start dnsmasq
This command will create a service file /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist and run it.
Finally, add localhost as name server in the network settings: