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
OR
$ dig server1.nixcraft.com
OR
$ 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 75.126.153.206 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 ;; QUESTION SECTION: ;www.cyberciti.biz. IN A ;; ANSWER SECTION: www.cyberciti.biz. 571513 IN A 75.126.153.206 ;; AUTHORITY SECTION: 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. ;; ADDITIONAL SECTION: ns1.p24.dynect.net. 52988 IN A 208.78.70.24 ns2.p24.dynect.net. 52989 IN A 204.13.250.24 ns3.p24.dynect.net. 52988 IN A 208.78.71.24 ns4.p24.dynect.net. 52988 IN A 204.13.251.24 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; 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:
Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: Name: www.cyberciti.biz Address: 75.126.153.206
See also
- Linux / UNIX: DNS Lookup Command Tutorial for more information.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 0 comments… add one now }