1

I stopped using nslookup a decade ago because dig superseded it. Now I'm creating custom files in /etc/resolver/ and finding that everything works... except dig (and nslookup).

Actually, I'd prefer to fix dig than to use something else. I write a lots of scripts that use those common tools. I don't like having to code 2 different solutions.

2
  • 1
    Local overrides bypass DNS resolution so you won't see that with DNS tools. Nov 2, 2016 at 3:12
  • This works but is a pain to have to do dig @$(awk '/nameserver/{print $2; exit}' /etc/resolver/ec2) prodmongo11.ec2 Nov 2, 2016 at 3:55

1 Answer 1

3

How about host?

The host command is very similar to dig except it's much more simple and doesn't have the very technical info (if you don't need it). So, for example, a host lookup would look something as follows:

$ host apple.stackexchange.com

apple.stackexchange.com has address 151.101.129.69
apple.stackexchange.com has address 151.101.193.69
apple.stackexchange.com has address 151.101.65.69
apple.stackexchange.com has address 151.101.1.69

You can also specify which DNS server you want to use by adding it to the command:

$ host apple.stackexchange.com 8.8.8.8
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

apple.stackexchange.com has address 151.101.193.69
apple.stackexchange.com has address 151.101.129.69
apple.stackexchange.com has address 151.101.1.69
apple.stackexchange.com has address 151.101.65.69

And if you absolutely need it, you can add -a to get the same output as a dig command:

$ host -a apple.stackexchange.com 8.8.8.8
Trying "apple.stackexchange.com"
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26262
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;apple.stackexchange.com.   IN  ANY

;; ANSWER SECTION:
apple.stackexchange.com. 299    IN  A   151.101.129.69
apple.stackexchange.com. 299    IN  A   151.101.65.69
apple.stackexchange.com. 299    IN  A   151.101.193.69
apple.stackexchange.com. 299    IN  A   151.101.1.69

Received 105 bytes from 8.8.8.8#53 in 39 ms
1
  • host ignores /etc/resolver it's useless to me. Nov 2, 2016 at 3:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .