Ubuntu Linux view status of my network interfaces card

last updated in Categories Ubuntu Linux
Ubuntu Logo

Wondering how to view the status of your network interface under Ubuntu Linux and make sure network connectivity exists? Here are several ways to check the status of your network interfaces(NIC)/card.

ADVERTISEMENTS

We can verify network connectivity or status of your network Interfaces/card using standard Linux commands. Open your terminal and use the following commands. You need to use the ip command or [nicmd nake=”ifconfig”] command to view the status of network interfaces card and as well as to configure a network interface itself.

Task: View network interface card

Let type the following ip command:
$ ip l show
Sample outputs:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 0a:da:ad:83:da:95 brd ff:ff:ff:ff:ff:ff

From the above outputs, it is clear that I have two network interfaces named lo and eth0. The UP indicates that network interface is up and running. But, how do you see an IP address assigned to the network interface such as eth0? Try:
$ ip a show eth0
Ubuntu status of network Interfaces card found using the ip command
The above outputs indicates my eth0 has 172.26.4.84/20 as IP address. To find out your default route on Ubuntu, run:
route -n
Sample outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.26.0.1      0.0.0.0         UG    100    0        0 eth0
172.26.0.0      0.0.0.0         255.255.240.0   U     0      0        0 eth0
172.26.0.1      0.0.0.0         255.255.255.255 UH    100    0        0 eth0

Another option is to run the following command:
ip r
Sample outputs:

default via 172.26.0.1 dev eth0 proto dhcp src 172.26.4.84 metric 100 
172.26.0.0/20 dev eth0 proto kernel scope link src 172.26.4.84 
172.26.0.1 dev eth0 proto dhcp scope link src 172.26.4.84 metric 100

My default gateway or router IP is set to 172.26.0.1. We can use the grep command/egrep command to filter out information easily too:
ip r | grep default
ip l show | grep -A1 eth0
ip l show | egrep -A1 'eth0|lo'

Use the ifconfig on Ubuntu to get status of network iunterfaces

Older version of Ubuntu version users needs to use the ifconfig command.
$ sudo ifconfig
OR
$ sudo /sbin/ifconfig
Sample iutputs:

eth0      Link encap:Ethernet  HWaddr 00:0F:EA:91:04:07
      inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
      Interrupt:18 Base address:0xc000

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:14680 errors:0 dropped:0 overruns:0 frame:0
      TX packets:14680 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:7816123 (7.4 MiB)  TX bytes:7816123 (7.4 MiB)

ra0       Link encap:Ethernet  HWaddr 00:17:9A:0A:F6:44
      inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
      inet6 addr: fe80::217:9aff:fe0a:f644/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:41108 errors:0 dropped:0 overruns:0 frame:0
      TX packets:11462 errors:1 dropped:1 overruns:0 carrier:0
      collisions:285 txqueuelen:1000
      RX bytes:9787416 (9.3 MiB)  TX bytes:2871485 (2.7 MiB)
      Interrupt:17

According to the ifconfig command, I have total three network interface cards (NICs) on my Ubuntu server:

  • eth0 – An Ethernet network interface is a communication channel with device connected to network switch or hub. You can transfer files or use internet with eth0.
  • lo – A Lookback interface is communication channel with only one endpoint i.e. it can not be used to communicate with rest of the computer or cannot transfer files.
  • ar0 – This is my wireless communication network interface. You may see other names for your network devices, such as wlan0/ath0 etc for wireless cards.

Line that starts with “inet addr:” displays actual IP address of network interface.

Task: Verify connectivity

To verify the connectivity use the ping command which send ICMP ECHO_REQUEST to network hosts:
$ ping www.yahoo.com
$ ping www.google.com
$ ping myrouter
$ ping cyberciti.biz

Sample outputs:

PING cyberciti.biz (68.142.234.44) 56(84) bytes of data.
64 bytes from p5w1.geo.re2.yahoo.com (68.142.234.44): icmp_seq=0 ttl=51 time=66.5 ms
64 bytes from p5w1.geo.re2.yahoo.com (68.142.234.44): icmp_seq=1 ttl=51 time=66.8 ms
64 bytes from p5w1.geo.re2.yahoo.com (68.142.234.44): icmp_seq=2 ttl=51 time=67.3 ms
64 bytes from p5w1.geo.re2.yahoo.com (68.142.234.44): icmp_seq=3 ttl=51 time=66.5 ms
64 bytes from p5w1.geo.re2.yahoo.com (68.142.234.44): icmp_seq=4 ttl=51 time=66.7 ms

--- cyberciti.biz ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 66.535/66.810/67.349/0.299 ms, pipe 2

If you want stop after sending 3 ECHO_REQUEST packets use the -c option (useful to write a simple monitoring shell script):
$ ping -c 3 www.cyberciti.biz

Task: Verify that network interface device is up and running

As I said eariler use the ip command and look for a flag named UP:
ip l show eth0 | grep --color -w UP
ip l show lo | grep --color -w DOWN
ip l show | grep --color -i -w DOWN

Ubuntu Linux view the status of my network Interfaces card commands
Type the following command which displays the list of device is up and running
$ sudo ifconfig -s
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     16383      0      0      0    16383      0      0      0 LRU
ra0    1500 0     75498      0      0      0    13594      1      1      0 BMRU

If interface is down or not working it will not display much of above information.

How to print the route packets trace to network host

Use the traceroute command which tracks the route packets taken from an IP network on their way to a given host. It utilizes the IP protocol’s time to live (TTL) field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to the host. The syntax is:
traceroute www.cyberciti.biz
traceroute {ip4-address-here}
traceroute 104.22.10.214
traceroute6 www.cyberciti.biz
traceroute6 {ipv6-address-here}
traceroute6 2606:4700:10::6816:bd6

Sample outputs:

traceroute to www.cyberciti.biz (104.22.10.214), 30 hops max, 60 byte packets
 1  216.182.229.110 (216.182.229.110)  8.783 ms 216.182.224.52 (216.182.224.52)  8.608 ms 216.182.226.16 (216.182.226.16)  16.427 ms
 2  * 100.66.8.110 (100.66.8.110)  19.649 ms 100.66.8.114 (100.66.8.114)  16.416 ms
 3  100.66.15.66 (100.66.15.66)  21.954 ms 100.66.38.178 (100.66.38.178)  14.668 ms 100.66.38.20 (100.66.38.20)  22.047 ms
 4  100.66.6.255 (100.66.6.255)  13.820 ms 100.66.7.113 (100.66.7.113)  14.816 ms 100.66.6.225 (100.66.6.225)  13.780 ms
 5  100.66.6.29 (100.66.6.29)  11.944 ms 100.66.5.33 (100.66.5.33)  14.482 ms 100.66.7.139 (100.66.7.139)  12.290 ms
 6  100.65.14.161 (100.65.14.161)  0.661 ms 100.66.5.207 (100.66.5.207)  12.948 ms 100.65.13.49 (100.65.13.49)  0.524 ms
 7  100.65.15.113 (100.65.15.113)  0.300 ms 52.93.28.89 (52.93.28.89)  0.558 ms 100.65.14.97 (100.65.14.97)  0.396 ms
 8  100.100.2.46 (100.100.2.46)  5.622 ms  5.652 ms 100.100.2.40 (100.100.2.40)  0.328 ms
 9  99.82.178.129 (99.82.178.129)  4.885 ms 99.82.178.127 (99.82.178.127)  11.608 ms 99.82.178.129 (99.82.178.129)  4.839 ms
10  104.22.10.214 (104.22.10.214)  0.589 ms  0.572 ms  0.684 ms

Say hello to the mtr

The mtr tool combines the functionality of the traceroute and ping programs in a single network diagnostic tool. Use the apt command/apt-get command to install mtr as follows on Ubuntu box:
sudo apt install mtr
## OR ##
sudo apt-get install mtr
Run it as follows:
mtr {IP-address}
mtr {domain-name}
mtr google.com
mtr www.cyberciti.biz

mtr

Conclusion

You learned various commands to find the status of network interfaces (NIC) and network connectivity on Ubuntu Linux.

ADVERTISEMENTS

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

6 comment

  1. Another good command (after you have run all the other ones) is “route -n”. It shows how the interfaces would route your packets, depending on the destination address. Good for finding default routes and special routing scenarios in your networking that you didn’t know about, which may explain why certain sites and domains cannot be seen.

  2. i am using i3, which has win7 and ubuntu , the problem is i am able to use wired network on win7 but in ubuntu i am not able to connect in the network connection tab i am not able to see any wired connection , i am new to ubuntu kindly suggest me in learning this kind of issue.

    regards

  3. There are times during troubleshooting that you want to see if you have electrical connectivity on your Ethernet interface, i. e. is the thing actually physically plugged in or not. For that, run “sudo ethtool” and look at the last line. If you’re plugged in, it’s “yes”. If not, it’s “no”.

  4. Hello I just installed ubuntu 16.04.1 and now my wifi driver isn’t being detected it won’t even let me try to enable wifi any suggestions on how to fix it

    Have a question? Post it on our forum!