Languages
[Edit]
EN

Linux - find machine ip address from command line

8 points
Created by:
Pearl-Hurley
559

In this short article, we would like to show how under Linux find the IP address of current machine using the command line.

Quick solution (run in terminal):

ip addr

 

More detailed description 

Modern Linux should have installed ip program - this article shows how to use it.

Hint: using an external tool is not a good solution as our computer may be on a local network - for example, we don't have our own public IP address or we are connected to a local WiFi or router.

Use the following command:

ip addr

Output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:0d:77:06 brd ff:ff:ff:ff:ff:ff
    inet 192.168.153.186/20 brd 192.168.159.255 scope global dynamic noprefixroute eth0
       valid_lft 73676sec preferred_lft 73676sec
    inet6 fe80::4810:db19:e572:7a6a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Explanation:

eth0 network interface (ethernet connection) has 192.168.153.186 IP address.

Screenshot:

List of network interfaces and IP addresses of the current machine listed with ip command under Linux.
List of network interfaces and IP addresses of the current machine listed with ip command under Linux.

Alternative titles

  1. Bash - find computer ip address
  2. Bash - find local ip address
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Linux

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join