September 12

In unix/linux we have a utility called nslookup. Which is very useful to query internet naming servers.

Man Page for nslookup

1) Lets see how to retrieve the ip address from the URL ( eg. www.google.com )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ nslookup www.google.com
Server:        218.186.2.16
Address:    218.186.2.16#53
 
Non-authoritative answer:
Name:    www.google.com
Address: 173.194.38.147
Name:    www.google.com
Address: 173.194.38.146
Name:    www.google.com
Address: 173.194.38.145
Name:    www.google.com
Address: 173.194.38.144
Name:    www.google.com
Address: 173.194.38.148

If you want only the ip address, then you can awk the output of the nslookup output.

1
2
3
4
5
6
7
8
9
$ nslookup www.google.com | awk '/Address/&&!/#/'
Address: 173.194.38.176
Address: 173.194.38.179
Address: 173.194.38.180
Address: 173.194.38.178
Address: 173.194.38.177
 
$ nslookup www.facebook.com | awk '/Address/&&!/#/'
Address: 66.220.149.94

If you type the above ip addresses, then you will be directed to corresponding website.