Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Commands»How to Check IP Address on Linux using Command Line

    How to Check IP Address on Linux using Command Line

    RahulBy RahulFebruary 4, 20173 Mins ReadUpdated: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}'
    
    ifconfig ip ip address local ip
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Ruby on CentOS/RHEL 7/6
    Next Article How To Install IIS on Windows 10

    Related Posts

    Configuring the Static IPv4 Address on Ubuntu using Netplan

    3 Mins Read

    How to Check IPv4 Address on Ubuntu 22.04

    2 Mins Read

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    Tee Command in Linux with Examples

    4 Mins Read

    How to Scan Open Ports with Nmap

    5 Mins Read

    4 Comments

    1. dani on July 25, 2020 9:15 am

      Hi Rahul

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

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

        Use “ip addr show” command

        Reply
    2. Igor on December 12, 2019 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.

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

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

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.