In some situations, i need to know available Network Ethernet interface under Linux operating system. In this port we will try to cover some commands with which we can display/show Network interfaces available on Linux machines.

Setup

We have one Linux CentOS7 machine , which will used run those commands to show Network interfaces.

[root@mysql-pri ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@mysql-pri ~]# uname  -a
Linux mysql-pri 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

IP command

ip command used in Linux show/manipulate routing, devices, policy routing and tunnels. But we can also use it to show brief details of available interface like below.


[root@mysql-pri ~]# ip link show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:43:d0:c3 brd ff:ff:ff:ff:ff:ff

In above output, we could see that we have two interface used in machine, one is loopback and another is eth0.

We can also used to Systems Dynamic files to see available Interface.

[root@mysql-pri ~]# ls /sys/class/net
eth0  lo

[root@mysql-pri ~]# cat  /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
  eth0:  119906    1942    0    5    0     0          0         0    25373     180    0    0    0     0       0          0
    lo:    1656      24    0    0    0     0          0         0     1656      24    0    0    0     0       0          0

Netstat command

Netstat command used to see network interface.

[root@mysql-pri ~]# netstat -i
Kernel Interface table
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0      1500     3137      0      5 0           180      0      0      0 BMRU
lo       65536       24      0      0 0            24      0      0      0 LRU

ifconfig command

Mostly ifconfig is know to see Ip-Address, but in addition to this it also can show Network interfaces on machine.

[root@mysql-pri ~]# ifconfig 
eth0: flags=4163  mtu 1500
        inet 192.168.122.200  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe43:d0c3  prefixlen 64  scopeid 0x20
        ether 52:54:00:43:d0:c3  txqueuelen 1000  (Ethernet)
        RX packets 3235  bytes 197718 (193.0 KiB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 180  bytes 25373 (24.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        RX packets 24  bytes 1656 (1.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24  bytes 1656 (1.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0