x32x01

ADMINISTRATOR
ip-address-find-1131x642.png


What is IP Address
A unique number consisting of four parts separated by dots. Every device on the Internet (and on any network) must have a unique IP address to participate and be part of it. An example of an IP address is: 192.168.1.1.

This article will show you how to find the IP address of your local machine through command line in LINUX. To get your internal IP, you can run the following commands:

Example 1 – Ifconfig
The ifconfig command is used to configure a network interface (that is, to associate an IP address with a network device). If you run ifconfig without any command-line arguments, the command displays information about current network interfaces.
Code:
ifconfig
OR
Code:
ifconfig -a


Example 2 – ip addr
To get the depth information of your network interfaces like IP Address, MAC Address information, use the following command as shown below.
Code:
ip addr


Example 3 – hostname
The hostname command is used to show or set a computer’s host name and domain name. It is one of the most basic of the network administrative utilities.
Code:
hostname -I


Example 4 – nmcli
nmcli is a command-line tool for controlling NetworkManager and reporting network status. It can be utilised as a replacement for nm-applet or other graphical clients.

It is also used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.
Code:
nmcli


Code:
nmcli device show


Example 5 – ip route
IP route command is used to configure the static route. Static routes are the most secure way of routing. They will also increase overall network performance. These features are extremely helpful in small network.
Code:
ip route get 1.2.3.4 | awk ‘{print $7}’


And with the help of below commands, you can easily get your external public IP address directly from the command line:
Code:
curl ipinfo.io/ip
curl ifconfig.me
dig +short myip.opendns.com @resolver1.opendns.com
curl checkip.dyndns.org
host myip.opendns.com resolver1.opendns.com

 
Top