How to Check IP Address on Linux using Command Line

An IP address is a unique public-facing codename given to every device that can access the internet. The IP system works as an address system for computers so they know what to connect to.

 

In this tutorial, we will learn how to check the IP address of your machine using Linux from the command line.

 

Get All IP Addresses

The simplest way to get a list of all the IP address on your system with Linux is to use the hostname command followed by the -I flag.

 

hostname -I
68.184.234.117 10.10.0.5

 

Show Network Adapter Status & IP

To display IP address information and status of each network adapter on your system use the ip addr command like this:

 

ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
 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 pfifo_fast state UP group default qlen 1000
 link/ether 3e:dd:eb:4e:65:e9 brd ff:ff:ff:ff:ff:ff
 inet 68.183.134.217/20 brd 68.183.143.255 scope global eth0
   valid_lft forever preferred_lft forever
 inet 10.10.0.5/16 brd 10.10.255.255 scope global eth0
   valid_lft forever preferred_lft forever
 inet6 fe80::3cdd:ebff:fe4e:65e9/64 scope link
   valid_lft forever preferred_lft forever

 

Get Adapter info and IP Addresses with ifconfig

Another way to get network adapter information and IP addresses is to use the ifconfig command. Some Linux systems may have restricted access to this feature.

 

ifconfig
eth0   Link encap:Ethernet HWaddr 3e:dd:eb:4e:65:e9  
    inet addr:68.183.134.217 Bcast:68.183.143.255 Mask:255.255.240.0
    inet6 addr: fe80::3cdd:ebff:fe4e:65e9/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:188338287 errors:0 dropped:0 overruns:0 frame:0
    TX packets:221519760 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:34088530747 (34.0 GB) TX bytes:917129610028 (917.1 GB)

lo    Link encap:Local Loopback  
    inet addr:127.0.0.1 Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:65536 Metric:1
    RX packets:96977865 errors:0 dropped:0 overruns:0 frame:0
    TX packets:96977865 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1
    RX bytes:615855016955 (615.8 GB) TX bytes:615855016955 (615.8 GB)

 

Get the Localhost IP Address

If you need to know the localhost IP address of your Linux system, use the hostname command with the -i flag.

 

hostname -i
127.0.1.1

 

In most cases, this is going to be 127.0.1.1.

network ip address