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:
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: ;; ->>HEADERThe 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.206See also
- Linux / UNIX: DNS Lookup Command Tutorial for more information.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 1 comment... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
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.