Before we start running a command to find the IP addresses from the domain name. First, we will discuss briefly IP address and domain names. An IP address is a unique identifier that is assigned to each device connected to a computer network and uses Internet protocol for communication.
A computer uses this address to send data to a specific computer. IPv4 and IPv6 are two versions of IP addresses available nowadays. Every computer with an IP address has an IPv4 address and many of them are starting to use IPv6.
Ahead in this article, we will discuss to find the IP address from a domain name in a Unix terminal.
Different versions of IP address
Currently, there are two versions of IP addresses that are in use –
IPv4 defines an IP address as a 32-bit number which is consists of four fields separated by a dot. IP addresses are written and displayed in a human-readable form. So each field of the address is a decimal representation of the 8-bit binary number. Example of IPv4 address – 220.127.116.11
In recent decades the internet grows massively. because of this growth and depletion of IPv4 addresses, a new version of IP (i.e. IPv6) was standardized in 1998. IPv6 address has 8 groups of hexadecimal numbers each separated by a colon. It uses 128 bits for a single IPv6 address. Example of IPv6 address – 2606:2800:220:1:248:1893:25c8:1946
What is a domain name?
The Internet is a big network of computers that are interconnected to each other. Each computer on the internet is identified by a unique address called IP address. An IP is a series of decimal or hexadecimal numbers separated by a dot or colon. It typically looks something like 18.104.22.168 which is comparatively difficult to remember. Now imagine what if you had to visit your favorite website with IP. A domain name is used to solve this problem. For example – google.co.in, example.com, etc.
Find IP using the host command
In Unix host is a simple utility to perform DNS lookups. It is normally used to convert the domain name to IP address and vice versa. When no argument is given it prints a short summary of arguments and options that can be used with it. To find the IP using the host command follow the steps given below –
1. Open your terminal by pressing ctrl+alt+t
2. And then type the following command and press enter-
As you can see above it display both IPv4 and IPv6 addresses. Now if you want to find the host whose IP is 22.214.171.124, then use the host command and pass the IP as the argument –
To display the short summary of options and argument, use the host command as given below –
Or if you want to know more about host command see its manual page –
Find IP using nslookup
Nslookup or name server lookup is a command-line tool useful in getting information from the domain name server. It is available for various operating systems. Nslookup is used to troubleshoot DNS related problems. To obtain IP which is mapped to a domain name, use the following command in your terminal –
For example –
You can also perform a reverse DNS lookup by providing IP address as an argument to the nslookup command.
To know more about nslookup command see its manual page with –