The IP address of any machine can be found on Linux by different commands, these commands are discussed in this article.
How to find IP address using the command in Linux
There are different commands in Linux to find IP addresses, majorly there are two types of IP addresses; public and private IP addresses; the private ip address is that which is unique and assigned to every machine and the public IP address is used to connect the device to the internet.
To find out the public IP address, we can use the ifconfig.me command with curl:
The other way to find it is by running the ipinfo command:
The api command is also used to display the public IP address:
The checkip command method can be used to find the IP address:
The last convenient command used to find out the public IP address is:
To find the private IP addresses, we can simply use the “ip address” command:
Instead of an address, we can also use “addr” or simply “a” with the IP command:
The other way to find the IP address is by using the command of ip config, but before it may be you have to install the package of net-tools if you are using Debian-Ubuntu based Linux distributions by the command:
Once the net-tools are installed, we can find out the ip address using the command:
The hostname command is used to find out the DNS name but it can also be used to find the IP addresses:
The IP route command can also be used to get the IP address:
One of the most common methods used to find the IP address is the nmcli command, in which we can display the device and show its details:
We can display the hostname IP simply using the “hostname” command with the “-I” option:
The IP address is used to identify the machine on the internet, send, and receive the data on the particular machine. The IP address of every machine is unique and it helps the internet communicate the information among different machines. In this article, we have discussed different commands by which we can find out the ip address of the machine in Linux. We explain the commands for finding both; public and private IP addresses in Linux.