How do I find the IP address of a website using Linux terminal?
Finding the public IP address of a website’s server is quite easy. In fact, there are several command line tools you can use to find the IP address of a website.
In an earlier article, I showed you how to find IP address in Linux. In this one, I am going to show you some of those commands here.
Commands to find IP address of a website in Linux
Do note that you might have to install some of these utilities mentioned here. Good news is that they are available in the default repositories of most Linux distributions. You can easily install them using the package manager of your distribution.
Method 1: Get website IP address with dig command
The syntax is simple.
A sample output for the dig command looks like this:
; <<>> DiG 9.11.3-1ubuntu1.5-Ubuntu <<>> facebook.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2224
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;facebook.com. IN A
;; ANSWER SECTION:
facebook.com. 198 IN A 188.8.131.52
;; Query time: 67 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Apr 03 17:57:12 IST 2019
;; MSG SIZE rcvd: 57
You can see the IP address of the website in the ‘ANSWER SECTION’.
Facebook has tons of servers and you may see a different IP address based on your geo-location and time. You shouldn’t find it unusual.
Method 2: Use nslookup command to find IP address of website in Linux
Like Dig, nslookup command is also used for querying the DNS records. nslookup stands for ‘name server lookup’.
You might need to install nslookup. If you have sudo access, you can use your Linux distribution’s installation command to install this tool. On Debian and Ubuntu, the command below will install nslookup:
sudo apt install nslookup
Once you have the tool, just use it in the following fashion:
For example, if I try to get the IP address of Facebook.com, this is the output I get:
Method 3:Get IP address of website using host command
Like the above two, host is also a DNS lookup utility. But unlike the above two commands, the output of the host command is neat and precise. It just displays the IPv4 and IPv6 addresses of a website.
You can use it like this:
Sample output would be like this:
facebook.com has address 184.108.40.206
facebook.com has IPv6 address 2a03:2880:f139:83:face:b00c:0:25de
facebook.com mail is handled by 10 msgin.vvv.facebook.com.
Method 4: Get website’s IP address with ping command in Linux
Let’s see how to get the IP address of a website with the ping command in Linux.
Ping command is used to check whether the remote host is up or not. You can use either the server’s IP address or the URL. The syntax is pretty much the same.
A sample output for facebook.com looks like this:
PING facebook.com (220.127.116.11) 56(84) bytes of data.
64 bytes from edge-star-mini-shv-01-sin2.facebook.com (18.104.22.168): icmp_seq=1 ttl=52 time=203 ms
64 bytes from edge-star-mini-shv-01-sin2.facebook.com (22.214.171.124): icmp_seq=2 ttl=52 time=163 ms
64 bytes from edge-star-mini-shv-01-sin2.facebook.com (126.96.36.199): icmp_seq=3 ttl=52 time=248 ms
--- facebook.com ping statistics ---
4 packets transmitted, 3 received, 25% packet loss, time 3001ms
rtt min/avg/max/mdev = 163.965/205.339/248.902/34.713 ms
You’ll have to use Ctrl+C to stop the ping command.
So you just saw three networking tools that would give you the same result. I hope this quick Linux tip helped you to find the IP address of a website in Linux terminal.
In a related post, you may also read about finding the default gateway IP in Linux.
If you have any questions or suggestions, please leave a comment below. Don’t forget to subscribe to the newsletter and get all the new tutorials once each week, for free.