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
$ dig
$ nslookup
Replace server1 with the name of the server or workstation you want to look up, and 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
$ host
Sample outputs: has address has IPv6 address 2607:f0d0:1002:51::4

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

; > DiG 9.7.0-P1 >
;; global options: +cmd
;; Got answer:
;; ->>HEADER

The nslookup command is used to query
$ nslookup
Sample outputs:


Non-authoritative answer:

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • NinjaSysadmin Jun 22, 2011 @ 14:13

    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.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum