3 ways to get a domain's IP address - Linux Tips

0xbf profile image Bo ・1 min read

We can use ping, nslookup and dig to get a domain's IP:

$ ping google.com
PING google.com((2607:f8b0:4006:819::200e)) 56 data bytes
$ nslookup google.com
Non-authoritative answer:
Name:   google.com
Name:   google.com
Address: 2607:f8b0:4006:819::200e
$ dig +short google.com -t a


markdown guide

Thing to bear in mind is, if a given DNS target has multiple A records, your response from (especially) ping can be quite variable (e.g., if your target has three IPs and there's no record-caching effects in play, each time you ping you could end up with any one of those three IPs being selected). Both dig and nslookup will at least return all the A records ...but are less-frequently installed on hosts.

Things get really if your target's DNS is being managed by a some kind of policy-service. Depending on the actions of that policy-service, you can get really variable responses.


I studied dig command and, it is very options for searching IP's.