DEV Community

BC
BC

Posted on

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

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
Enter fullscreen mode Exit fullscreen mode
$ nslookup google.com
Non-authoritative answer:
Name:   google.com
Address: 172.217.12.174
Name:   google.com
Address: 2607:f8b0:4006:819::200e
Enter fullscreen mode Exit fullscreen mode
$ dig +short google.com -t a
172.217.12.142
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
ferricoxide profile image
Thomas H Jones II

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.

Collapse
 
shiponkarmakar profile image
Shipon Karmakar

Informative post

Collapse
 
amaurybsouza profile image
Amaury Borges Souza

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