• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Check IP Address on Linux using Command Line

Written by Rahul, Updated on December 13, 2019

How to check IP address on Linux machine using the command line interface? Mostly all of the Linux and Unix operating systems provides ifconfig and ip binary files. You can simply use these commands to find the local system IP address.

What is an IP Address?

A Internet Protocol address (IP address) is the numerical label assigned to each hardware devices connected to a computer network that uses the Internet Protocol to identify the devices. In general terms, it is an identity of any device. An IP address allows a device to communicate with other devices over an IP-based network like the LAN or Internet.

  • Read: 5 Commands to Get Public IP using Linux Terminal

Method 1 – Using ifconfig Command

ifconfig command is generally available under /sbin directory. So you will need root or sudo access to run this on many of operating systems.

ifconfig

Sample output: [Some output hidden]

eth0      Link encap:Ethernet  HWaddr 00:0C:22:83:79:A3
          inet addr:192.168.10.199  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe89:79b3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3931508 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1333146 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:706273621 (673.5 MiB)  TX bytes:857722605 (817.9 MiB)
          Base address:0x2000 Memory:fd5c0000-fd5e0000

As per above output, this system has IP address 192.168.10.199 on Ethernet interface eth0.

You can also view the specific interface details by specifying the interface name on the command line as below.

ifconfig eth0
  • Read: bash ifconfig: command not found on CentOS/RHEL 7

Method 2 – Using ip Command

ip command generally available under /bin directory but some Linux os keep is under /sbin directory. Use the following command to get ip address using ip command.

ip addr show

Sample output: [Some output hidden]

1: lo:  mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0C:22:83:79:A3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.199/24 brd 192.168.1.255 scope global eth0 
    inet6 fe80::20c:29ff:fe89:79b3/64 scope link
       valid_lft forever preferred_lft forever

As per the above output, this system has IP address 192.168.10.199 on Ethernet interface eth0. The interface eth1 doesn’t configure with an IP address.

You can also view the specific itnerface details using below command

ip addr show eth0

Find more commands to check local ip address of any Linux system.

ip route get 1 | awk '{print $NF;exit}'
ip route get 8.8.4.4 | head -1 | cut -d' ' -f8
ip route get 8.8.4.4 | head -1 | awk '{print $7}'

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

4 Comments

  1. Avatar dani Reply
    July 25, 2020 at 9:15 am

    Hi Rahul

    How I can know the IP address to test APACHE server after installing it ?

    • Rahul Rahul Reply
      July 25, 2020 at 1:07 pm

      Use “ip addr show” command

  2. Avatar Igor Reply
    December 12, 2019 at 1:26 pm

    Hello,
    Could You explain how to add an additional virtual ip address to the interface using ip command?
    Thank you very much in advance.

  3. Avatar Shivam Srivastava Reply
    February 18, 2019 at 12:16 pm

    Thank you sir, Good see your hardwork. finally got your website first in search from Qatar.

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy