Linux

Find How Linux Get IP Address From Command

[ad_1]

How many commands you know to get IP address on your Linux systems? In this article, we’ll discuss a few ways to get IP address as well as public IP on Linux.

  1. ifconfig command
  2. ip addr
  3. Hostname -I command
  4. nmcli command
  5. ip route
  6. Graphical Method
  7. Display Public IP address

1) ifconfig command

ifconfig is short for interface configuration. It’s a widely used command line tool used for configuration & viewing of ip addresses,  and enabling/disabling network interfaces.

Note: ifconfig command is deprecated, try using ip command.

ifconfig / ifconfig -a

ifconfig with no arguments will display statistics of all active interfaces. This is the same as running ifconfig -a

Example

Output

ifconfig {interface name}

To get an IP address of a specific network interface, run ifconfig followed by an interface name

Example

Output

2) ip addr

ip addr is yet another command you can use to get an IP address of a system and other interface statistics

Example

Output

3) Hostname -I command

To get the IP address of active network connections, run

Output

4) nmcli command

nmcli – Network Manager command Line interface – is a command line tool used for creating, editing, displaying, deleting, activating and deactivating connections.

nmcli

Example

Output

nmcli device show

To get the IP address and even more detailed statistics, run

Output

5) ip route get 1.2.3.4 | awk ‘{print $7}’

This is yet another command that can be used to get an IP address without much statistics

Output

6) Network Settings in Graphical User Interface

If you are running Linux in a graphical environment, you can easily navigate to the Network settings and check out the IP address. In this example, we have demonstrated this using Ubuntu 18.04 GNOME interface.

  1. Click on the Network icon as shown.
    get an IP address
  2. On the pull-down menu that appears, be sure to locate the connected network interface. In this case, it’s the wired connection and we can see that the interface is up by   ‘Wired connected‘ status. Click on it.
    get an IP address
  3.  Next, click on the ‘Wired settings‘ option that appears below
    get an IP address
  4. This displayed a ‘Network Settings‘ window. Click on the gear icon next to the ON/OFF toggle and a pop-up Window will appear showing the IP details of the connected network interface.
    get an IP address

Display a Public IP address of your Linux System

If you wish to get the Public IP of your Linux System, the following commands come in handy

Do you know any other method to get the IP address? Please reply with your comments.

[ad_2]

Facebook Comments

Show More

Related Articles

Leave a Reply

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

Back to top button