Interpret the network connection information displayed by Linux ip command

  • 2020-11-03 22:40:22
  • OfStack

preface

The ip command can tell you a lot about the configuration and status of your network connections, but what do all these words and Numbers mean? Let's take a closer look at 1 and see what all the displayed values are trying to tell you.

When you use the ip a (or ip addr) command to get information about all the network interfaces on the system, you will see something like this:


$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
 valid_lft forever preferred_lft forever
 inet6 ::1/128 scope host
 valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
 link/ether 00:1e:4f:c8:43:fc brd ff:ff:ff:ff:ff:ff
 inet 192.168.0.24/24 brd 192.168.0.255 scope global dynamic enp0s25
 valid_lft 57295sec preferred_lft 57295sec
 inet6 fe80::2c8e:1de0:a862:14fd/64 scope link
 valid_lft forever preferred_lft forever

The two interfaces on the system - loop (lo) and network (enp0s25) - show a lot of statistics. The lo interface is clearly the loopback address loolback. We can see in the list the loopback IPv4 address (127.0.0.1) and the loopback IPv6 (::1). Normal network interfaces are more interesting.

Why enp0s25 and not eth0

If you want to know why it's called enp0s25 on this system, rather than the more familiar eth0, we can explain a little.

The new naming scheme is called "Predictable network interface Predictable Network Interface". It has been in use for some time on Linux based systems. The interface name depends on the physical location of the hardware. en simply means "ethernet", just as "eth" corresponds to eth0, 1. p is the bus number for the Ethernet card, and s is the slot number. So enp0s25 tells us a lot about the hardware we're using.

<BROADCAST,MULTICAST,UP,LOWER_UP> This configuration string tells us:

[

The BROADCAST interface supports broadcasting
The MULTICAST interface supports multicasting
The UP network interface is enabled
The LOWER_UP network cable has been inserted and the device has been connected to the network

]

The other values listed also tell us a lot about interfaces, but we need to know what the words brd and qlen mean. So, what is shown here is a translation of the rest of the ip information shown above.

[

mtu 1500 has a maximum transmission unit (packet size) of 1,500 bytes
qdisc pfifo_fast is used for packet queuing
The state UP network interface is enabled
group default interface group
qlen 1000 transmission queue length
link/ether 00:1 e: 4 f: c8:43: fc interface MAC (hardware) address
brd ff: ff: ff: ff: ff: ff broadcast address
inet 192.168.0.24/24 IPv4 address
brd 192.168.0.255 broadcast address
scope global is globally valid
dynamic enp0s25 addresses are dynamically allocated
valid_lft 80866sec IPv4 address
Preferred lifetime of preferred_lft 80866sec IPv4 address
c8e inet6 fe80: : 2:1 de0: a862:14 fd / 64 IPv6 address
scope link is only available on this device
valid_lft forever IPv6 address expiry date
Preferred lifetime of preferred_lft forever IPv6 address

]

You may have noticed that some of the information provided by the ifconfig command is not included in the output of the ip a command -- for example, statistics for transmission packets. If you want to see a list of the number of packets sent and received, as well as the number of collisions, use the ip command:


$ ip -s link show enp0s25
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
 link/ether 00:1e:4f:c8:43:fc brd ff:ff:ff:ff:ff:ff
 RX: bytes packets errors dropped overrun mcast
 224258568 418718 0 0 0 84376
 TX: bytes packets errors dropped carrier collsns
 6131373 78152 0 0 0 0

Another ip command provides information about the system routing tables.


$ ip route show
default via 192.168.0.1 dev enp0s25 proto static metric 100
169.254.0.0/16 dev enp0s25 scope link metric 1000
192.168.0.0/24 dev enp0s25 proto kernel scope link src 192.168.0.24 metric 100

The ip command is very generic. You can get a useful cheat sheet from the ip command and its options from Red Hat.

conclusion


Related articles: