Tutorials

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

Command: ifconfig

OR

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

Commands:

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

Have something to say about this article? Comment below or share it with us on Facebook or Twitter.

Yeahhub.com
Step by step hacking tutorials about wireless cracking, kali linux, metasploit, ethical hacking, seo tips and tricks, malware analysis and scanning.
https://www.yeahhub.com/

Leave a Reply

Your email address will not be published. Required fields are marked *

two × two =