How do I find out ip number (IP Address) of my Linux server using command line options?
You can use any one of the following command to find out your IP address, routing table, devices, tunnels, and much more.
ip Command Example
To display ip address, enter:
$ ip addr show
Sample outputs:
1: lo: mtu 16436 qdisc noqueue state UNKNOWN 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 mq state DOWN qlen 1000 link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff 3: wlan0: mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:21:6a:bf:2d:64 brd ff:ff:ff:ff:ff:ff inet 192.168.1.100/24 brd 192.168.1.255 scope global wlan0 inet6 fe80::221:6aff:febf:2d64/64 scope link valid_lft forever preferred_lft forever 4: virbr0: mtu 1500 qdisc noqueue state UNKNOWN link/ether c2:86:1d:f6:17:a1 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 inet6 fe80::c086:1dff:fef6:17a1/64 scope link valid_lft forever preferred_lft forever 6: pan0: mtu 1500 qdisc noop state DOWN link/ether fe:84:69:82:05:fb brd ff:ff:ff:ff:ff:ff 8: ppp0: mtu 1496 qdisc pfifo_fast state UNKNOWN qlen 3 link/ppp inet 10.1.3.180 peer 10.0.31.18/32 scope global ppp0
To see eth0 or wlan0 interface ip info, enter:
$ ip addr show eth0
OR
$ ip addr show wlan0
To see current routing table, enter:
$ ip route show
Sample outputs:
10.0.31.18 dev ppp0 proto kernel scope link src 10.1.3.180 38.96.196.94 via 192.168.1.2 dev wlan0 src 192.168.1.100 192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.100 metric 2 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 169.254.0.0/16 dev wlan0 scope link metric 1000 10.0.0.0/8 dev ppp0 scope link default via 192.168.1.2 dev wlan0 proto static
To see your dns address, enter:
$ cat /etc/resolv.conf
Sample outputs:
domain nixcraft.net.in search nixcraft.net.in nameserver 127.0.0.1 nameserver 192.168.1.2 nameserver 10.1.2.30
To see network stats, enter:
$ netstat -i
Sample outputs:
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg eth0 1500 0 0 0 0 0 0 0 0 0 BMU lo 16436 0 34 0 0 0 34 0 0 0 LRU ppp0 1496 0 1734 0 0 0 2348 0 0 0 MOPRU virbr0 1500 0 0 0 0 0 6 0 0 0 BMRU wlan0 1500 0 2663556 0 0 0 2393688 0 0 0 BMRU
To see detailed stats, enter:
$ netstat -s
Ip: 2665087 total packets received 0 forwarded 0 incoming packets discarded 2664956 incoming packets delivered 2395808 requests sent out 5 dropped because of missing route 189 reassemblies required 91 packets reassembled ok Icmp: 84 ICMP messages received 28 input ICMP message failed. ICMP input histogram: destination unreachable: 22 timeout in transit: 60 echo replies: 2 375 ICMP messages sent 0 ICMP messages failed ICMP output histogram: destination unreachable: 371 echo request: 4 IcmpMsg: InType0: 2 InType3: 22 InType11: 60 OutType3: 371 OutType8: 4 Tcp: 20610 active connections openings 31585 passive connection openings 8024 failed connection attempts 1251 connection resets received 5 connections established 2581197 segments received 2297196 segments send out 63443 segments retransmited 14 bad segments received. 30535 resets sent Udp: 80731 packets received 351 packets to unknown port received. 1 packet receive errors 31985 packets sent UdpLite: TcpExt: 15213 invalid SYN cookies received 159 resets received for embryonic SYN_RECV sockets 622 packets pruned from receive queue because of socket buffer overrun 7 packets dropped from out-of-order queue because of socket buffer overrun 10 ICMP packets dropped because they were out-of-window 15991 TCP sockets finished time wait in fast timer 69 packets rejects in established connections because of timestamp 31774 delayed acks sent 7 delayed acks further delayed because of locked socket Quick ack mode was activated 55974 times 3 packets directly queued to recvmsg prequeue. 3 bytes directly received in process context from prequeue 1172856 packet headers predicted 152280 acknowledgments not containing data payload received 19065 predicted acknowledgments 847 times recovered from packet loss by selective acknowledgements Detected reordering 2 times using SACK Detected reordering 2 times using time stamp 1 congestion windows fully recovered without slow start 3 congestion windows partially recovered using Hoe heuristic 420 congestion windows recovered without slow start by DSACK 3090 congestion windows recovered without slow start after partial ack 1097 TCP data loss events TCPLostRetransmit: 54 1 timeouts after reno fast retransmit 1302 timeouts after SACK recovery 416 timeouts in loss state 1264 fast retransmits 28 forward retransmits 2097 retransmits in slow start 29729 other TCP timeouts 217 SACK retransmits failed 7416 packets collapsed in receive queue due to low socket buffer 85705 DSACKs sent for old packets 8290 DSACKs sent for out of order packets 2556 DSACKs received 17 DSACKs for out of order packets received 9960 connections reset due to unexpected data 328 connections reset due to early user close 8346 connections aborted due to timeout TCPDSACKIgnoredOld: 1498 TCPDSACKIgnoredNoUndo: 412 TCPSpuriousRTOs: 27 TCPSackShiftFallback: 5906 IpExt: InNoRoutes: 1 InOctets: 1851631423 OutOctets: 225338929
To see TCP / UDP network and socket information, use the ss command as follows:
# ss -s
# ss -l
# ss -t -a
# ss -u -a
ifconfig Command Example
Simply type the following command:
# ifconfig
OR
# ifconfig eth0
# ifconfig wlan0
Sample outputs:
wlan0 Link encap:Ethernet HWaddr 00:21:6a:bf:2d:64 inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::221:6aff:febf:2d64/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2664664 errors:0 dropped:0 overruns:0 frame:0 TX packets:2394780 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1888550078 (1.8 GB) TX bytes:301911646 (301.9 MB)
🐧 1 comment so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thank you.