≡ Menu

Linux / Unix: Look Up IP Addresses

How can I look up IP addresses under UNIX or Linux operating systems using command line options?

You can use the following commands to lookup up an IP address:

[a] host command

[b] dig command

[c] nslookup command

You also need to know the full name of the server or workstation (PC) you are looking up. Open a command-line terminal (select Applications > Accessories > Terminal), and then type one of the following commands at the Linux / UNIX shell:
$ host server1.nixcraft.com
$ dig server1.nixcraft.com
$ nslookup server1.nixcraft.com
Replace server1 with the name of the server or workstation you want to look up, and nixcraft.com with the actual domain name. Please note that the nslookup command may be removed from many Linux distros and UNIX operating systems, so use host or dig to look up IP addresses. In this example lookup an IP addresses for www.cyberciti.biz:
$ host www.cyberciti.biz
Sample outputs:

www.cyberciti.biz has address
www.cyberciti.biz has IPv6 address 2607:f0d0:1002:51::4

The dig command is used to find out an IP address of www.cyberciti.biz:
$ dig www.cyberciti.biz
Sample outputs:

; <<>> DiG 9.7.0-P1 <<>> www.cyberciti.biz
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29656
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4

;www.cyberciti.biz.		IN	A

www.cyberciti.biz.	571513	IN	A

cyberciti.biz.		53113	IN	NS	ns2.p24.dynect.net.
cyberciti.biz.		53113	IN	NS	ns1.p24.dynect.net.
cyberciti.biz.		53113	IN	NS	ns3.p24.dynect.net.
cyberciti.biz.		53113	IN	NS	ns4.p24.dynect.net.

ns1.p24.dynect.net.	52988	IN	A
ns2.p24.dynect.net.	52989	IN	A
ns3.p24.dynect.net.	52988	IN	A
ns4.p24.dynect.net.	52988	IN	A

;; Query time: 0 msec
;; WHEN: Thu Apr 14 02:35:41 2011
;; MSG SIZE  rcvd: 201

The nslookup command is used to query www.cyberciti.biz:
$ nslookup www.cyberciti.biz
Sample outputs:


Non-authoritative answer:
Name:	www.cyberciti.biz

See also

Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 1 comment… add one }
  • NinjaSysadmin June 22, 2011, 2:13 pm

    If you know the IP Address but not the name, you can run dig -x and providing a Reverse DNS entry exists (why shouldn’t it) then you’ll get a response.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , ,