Languages
[Edit]
EN

Linux - find machine ip address from command line

8 points
Created by:
JustMike
3593

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

Quick solution (run in terminal):

ip addr

More detailed description 

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

Explaination:

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

Screenshot:

List of network interfaces and ip addresses of current machine listed with ip command in Lunux.
List of network interfaces and ip addresses of current machine listed with ip command in Lunux.
Hey 👋
Would you like to know what we do?
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.