≡ Menu

Redhat Linux: Find Out My IP Address

How do I to find out ip address on a CentOS or Fedora or Redhat Enterprise Linux server or desktop system using bash shell or command line options?

You can use any one of the following command to view ip address information for each interface under RHEL / CentOS / Fedora Linux:

[a] ip command: Display or manipulate IP address, routing, devices, policy routing and tunnels.

[b] ifconfig command: It is used to configure the kernel-resident network interfaces as well as display information about it.

ip command example

To see current ip address information for eth0, enter:
# ip addr show eth0
Sample outputs:

2: eth0:  mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
    inet6 fe80::baac:6fff:fe65:31e5/64 scope link 
       valid_lft forever preferred_lft forever

To see routing information, enter:
# ip route show
Sample outputs:

10.0.xx.yy dev ppp0  proto kernel  scope link  src 
38.xx.yy.zz via dev eth0  src dev eth0  proto kernel  scope link  src  metric 1 dev ppp0  scope link 
default via dev eth0  proto static 

ifconfig command example

Simply type the ifconfig command as follows to display eth0 IP information:
# ifconfig eth0
Sample outputs:

eth0      Link encap:Ethernet  HWaddr b8:ac:6f:65:31:e5  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::baac:6fff:fe65:31e5/64 Scope:Link
          RX packets:308560 errors:0 dropped:0 overruns:0 frame:0
          TX packets:217836 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:431112624 (431.1 MB)  TX bytes:20994801 (20.9 MB)

You can simply type the following command to just display an IP and its netmask:
# ifconfig eth0 | grep 'inet addr:'
Sample outputs:

 inet addr:  Bcast:  Mask:
Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 6 comments… add one }
  • Leonidas August 18, 2011, 6:58 am

    using command

  • moke September 8, 2012, 2:27 am

    hmm .. thanks !

  • _ck_ June 28, 2014, 1:59 am

    hostname -i

    • Velathora July 25, 2014, 2:01 pm

      So much easier considering it answers the question EXACTLY

    • brett February 23, 2015, 3:40 pm

      hostname -i|awk ‘{print $2}’

  • Leandroqara October 6, 2016, 11:22 am

    hostname -i Rules!

    I was looking for this answer for long time!

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , , , , ,