Sunday, May 06, 2007

Lookup an Internet Protocol (IP) Address for a URL

Sometimes it might be necessary to lookup an IP address for a URL. The nslookup command can provide you that capability. Here's an example.

#nslookup some_urlname.com

Here's the output of nslookup
Server: xxx.xxx.net (DNS server)
Address: x.x.x.1

Non-authoritative answer:
Name: xxxx.com
Addresses: xxx.xxx.xxx.12 xx.xx.xxx.13 (the IP addresses for some_urlname.com)

Here are some more examples using nslookup
# nslookup

Default Server: XXX.XXXX.net
Address: XXX.XXX.X.1

Nameservers

> set type=ns
> some_urlname.com
Server: XX.XXXX.net
Address: XXX.XXX.X.1

Non-authoritative answer:
some_urlname.com nameserver = ns5.some_urlname.com
some_urlname.com nameserver = ns8.some_urlname.com
some_urlname.com nameserver = ns9.some_urlname.com
some_urlname.com nameserver = ns2.some_urlname.com
some_urlname.com nameserver = ns1.some_urlname.com
some_urlname.com nameserver = ns3.some_urlname.com
some_urlname.com nameserver = ns4.some_urlname.com

Authoritative answers can be found from:
ns5.some_urlname.com internet address = XXX.XX.X.7
ns8.some_urlname.com internet address = XX.XX.XX.X
ns9.some_urlname.com internet address = XX.XX.XX.X
ns2.some_urlname.com internet address = XXX.XX.X.X
ns1.some_urlname.com internet address = XX.XXX.XX.9
ns3.some_urlname.com internet address = XX.XXX.X.X
ns4.some_urlname.com internet address = XX.XX.X.X

Mail servers

> set type=mx
> some_urlname.com
Server: XXX.XXXX.net
Address: XX.XXX.XX.1

Non-authoritative answer:
some_urlname.com preference = 1, mail exchanger = e.mx.mail.some_urlname.com
some_urlname.com preference = 1, mail exchanger = f.mx.mail.some_urlname.com
some_urlname.com preference = 1, mail exchanger = g.mx.mail.some_urlname.com
some_urlname.com preference = 1, mail exchanger = a.mx.mail.some_urlname.com
some_urlname.com preference = 1, mail exchanger = b.mx.mail.some_urlname.com
some_urlname.com preference = 1, mail exchanger = c.mx.mail.some_urlname.com
some_urlname.com preference = 1, mail exchanger = d.mx.mail.some_urlname.com
Authoritative answers can be found from:
some_urlname.com nameserver = ns2.some_urlname.com
some_urlname.com nameserver = ns1.some_urlname.com
some_urlname.com nameserver = ns3.some_urlname.com
some_urlname.com nameserver = ns4.some_urlname.com
some_urlname.com nameserver = ns5.some_urlname.com
some_urlname.com nameserver = ns8.some_urlname.com
some_urlname.com nameserver = ns9.some_urlname.com
e.mx.mail.some_urlname.com internet address = X.X.X.11
f.mx.mail.some_urlname.com internet address = X.X.X.2
f.mx.mail.some_urlname.com internet address = X.X.X.X
g.mx.mail.some_urlname.com internet address = X.X.X.X
g.mx.mail.some_urlname.com internet address = XX.XXX.XXX.X
a.mx.mail.some_urlname.com internet address = X.XX.XX.X
b.mx.mail.some_urlname.com internet address = XX.XXX.X.X
c.mx.mail.some_urlname.com internet address = X.X.X.13
c.mx.mail.some_urlname.com internet address = XXX.XX.XX.X
d.mx.mail.some_urlname.com internet address = X.X.X.12
ns2.some_urlname.com internet address = X.XX.XXX.X
ns1.some_urlname.com internet address = X.X.XX.X
ns3.some_urlname.com internet address = XX.XX.XX.X
ns4.some_urlname.com internet address = XX.XXX.X.3
>

2 comments:

St├ęphane said...

Alternatively, you could use the simple ping command :

hostname# ping -a some_host
some_host (192.168.12.13) is alive

And this has the advantage of resolving through DNS, NIS, files, ... depending on what is configured in /etc/nsswitch.conf .

esofthub said...

thanks stephane, I appreciate the input.