For a project I need to intercept/redirect DNS queries to a VM, which in turn runs
dnsmasq. This VM is hosted by xhyve and when connected to the network, the setup works well; I have an file in
/etc/resolver.conf/test.io which has:
nameserver 192.168.64.20 search_order 1
dig node.test.io @192.168.64.20 or
dig node.test.io give the expected results.
But when going offline, there is a problem. It seems that when macOS is not connected to a network, it only allows
/etc/resolver.conf/* entries to work when they use
I tried setting up a port-forwarding, like:
$ echo " rdr pass inet proto udp from any to 127.0.0.1 port 53 -> 192.168.64.20 port 53 " | sudo pfctl -ef -
nameserver 127.0.0.1 search_order 1
However, the domain
test.io can not be found when I try to do a
dig node.test.io @localhost. The VM is still reachable as
dig node.test.io @192.168.64.20 still gets resolved.
scutil --dns gives the following:
resolver #9 domain : test.io nameserver : 127.0.0.1 flags : Request A records, Request AAAA records reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address) order : 1
nslookup does not seem to handle resolver well, so I have also tried to use curl/wget and the browser to see if queries got resolved correctly. Also, no difference with
dns-sd. All failed...