I want to use a DNS server on my machine to resolve lookups for all names ending in .dev.

I've created /etc/resolver/dev to do this, and checked that it works for A records:

› dscacheutil -q host -a name blah.blah.dev
name: blah.blah.dev

So far, so gravy.

However, what I really need to do is use the local DNS server to resolve SRV queries.

When I point Ruby directly at the local DNS server, it can resolve the queries OK:

>> Resolv::DNS.new(
    nameserver: '',
    search: 'dev',
    ndots: 1
=> [#<Resolv::DNS::Resource::IN::SRV:0x007faa192fc720 @priority=0, @weight=0, @port=5200, @target=#<Resolv::DNS::Name:>, @ttl=0>]

However, when I use the OS X defaults, the name is not resolved:

>> Resolv::DNS.new.getresources(
=> []

Using tcpdump, I can see that in the former situation, the resolution happens (and succeeds!) over the loopback interface:

› sudo tcpdump -i lo0 -s 0 -B 524288 -w ~/Desktop/DumpFile-with-nameserver.pcap
› tcpdump -s 0 -r DumpFile-with-nameserver.pcap
reading from file DumpFile-with-nameserver.pcap, link-type NULL (BSD loopback)
14:11:18.532418 IP localhost.mphlpdmc > localhost.domain: 10530+ SRV? _http._tcp.demo-service-foo.dev. (55)
14:11:18.532575 IP localhost.domain > localhost.mphlpdmc: 10530* 1/0/0 SRV 0 0 (84)

In the latter situation (without manually specifying the nameserver), the resolution query goes out over the network, and fails as you'd expect:

› sudo tcpdump -i en0 -s 0 -B 524288 -w ~/Desktop/DumpFile-default.pcap
› tcpdump -s 0 -r DumpFile-default.pcap
reading from file DumpFile-default.pcap, link-type EN10MB (Ethernet)
14:09:35.567565 IP > o2.mobilewifi.domain: 21300+ SRV? _http._tcp.demo-service-foo.dev. (55)
14:09:35.643653 IP o2.mobilewifi.domain > 21300 NXDomain 0/1/0 (130)

So, to me it looks like the /etc/resolver/* system is used for A-type queries, but not for SRV?

I can't find confirmation for this in any documentation, however…

Is there a way for me to be able to use /etc/resolver for SRV lookups?

  • Did you ever make any progress on this? I need to do exactly the same thing. – Reid Oct 12 '17 at 19:57

You must log in to answer this question.

Browse other questions tagged .