Get Linux IP Address from Command Line – 5 Ways

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:

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.

Command: ifconfig


Command: 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.

Command: 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.

Command: 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.

Command: nmcli

Command: 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.

Command: ip route get | awk ‘{print $7}’

And with the help of below commands, you can easily get your external public IP address directly from the command line:


dig +short

You may also like:

Sarcastic Writer

Step by step hacking tutorials about wireless cracking, kali linux, metasploit, ethical hacking, seo tips and tricks, malware analysis and scanning.

Related Posts