How to Check IP Address on Linux Command Line

How to Check IP Address on Linux Command Line. 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.

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
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  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:16436  Metric:1           RX packets:654 errors:0 dropped:0 overruns:0 frame:0           TX packets:654 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0           RX bytes:90459 (88.3 KiB)  TX bytes:90459 (88.3 KiB) 
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 using below command
$ ifconfig eth0 
Also you can specifiy full command path in case of command is not available under PATH environment.
$ /sbin/ifconfig eth0 

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:
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 3: eth1:  mtu 1500 qdisc pfifo_fast qlen 1000     link/ether 00:0c:29:89:79:bd brd ff:ff:ff:ff:ff:ff 4: sit0:  mtu 1480 qdisc noop     link/sit 0.0.0.0 brd 0.0.0.0 
As per above output, this system has IP address 192.168.10.199 on ethernet interface eth0. The interface eth1 doesn’t configure with any IP address.
You can also view the specific itnerface details using below command
# ip addr show eth0 

Thanks for Visit Here

Comments