Do You Know the New Linux Networking Commands?

Back in April, I explained the new network interface names. Instead of eth0 it’s something like enp0s4 or p7p1.

Let’s see how to check the settings. Run these commands on your system and play along!

Physical Devices

First, what are the network class devices? This system has two Ethernet interfaces:

$ ls -l /sys/class/net
total 0
lrwxrwxrwx. 1 root root 0 Mar  8 10:19 enp0s18 -> ../../devices/pci0000:00/0000:00:12.0/net/enp0s18
lrwxrwxrwx. 1 root root 0 Mar  8 10:19 enp0s20 -> ../../devices/pci0000:00/0000:00:14.0/net/enp0s20
lrwxrwxrwx. 1 root root 0 Mar  8 10:19 ls -> ../../devices/virtual/net/lo

Link Layer

Here is the Ethernet or link-layer information:

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether b8:27:eb:20:9c:a4 brd ff:ff:ff:ff:ff:ff
3: enp0s20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether b8:27:eb:20:9c:9a brd ff:ff:ff:ff:ff:ff

Both are plugged into live networks. The interfaces are enabled (the first “UP”), and both hear Ethernet link beat signals (the second “UP”).

Now we ask for statistics:

$ ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    56880      689      0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    56880      689      0       0       0       0
2: enp0s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether b8:27:eb:20:9c:a4 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    7766356    64823    0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    434232     2557     0       0       0       0
3: enp0s20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether b8:27:eb:20:9c:9a brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    86377095   1177553  0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    29380884244 19335457 0       0       0       0

Most of the traffic is over the enp0s20 interface. This server has transmitted a little over 27 GB of data.

Good news: no collisions (which can happen if negotiation with the switch stumbles) and no other errors or drops or carrier problems (which probably mean bad cables, maybe bad Ethernet cards).

Rack of Ethernet switches

IP addresses

Let’s ask for IPv4 and IPv6 individually. We get the link state, the IP information. The enp0s20 device has 3 IPv4 addresses. For IPv6, it has the usual automatically configured link-local fe80::/10 IPv6 address, plus a globally routable 2001:1800:1234:90::/64 address.

$ ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp0s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 172.16.0.200/16 brd 172.16.255.255 scope global enp0s18
       valid_lft forever preferred_lft forever
3: enp0s20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 10.1.1.200/24 brd 10.1.1.255 scope global enp0s20
       valid_lft forever preferred_lft forever
    inet 10.1.1.201/24 brd 10.1.1.255 scope global secondary enp0s20
       valid_lft forever preferred_lft forever
    inet 10.1.1.203/24 brd 10.1.1.255 scope global secondary enp0s20
       valid_lft forever preferred_lft forever

The 169.254/16 routes are for link-local autoconfiguration addresses, like Apple’s Bonjour service-discovery protocol.

$ ip -6 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 fe80::20c:29ff:fe20:9ca4/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 2001:1800:1234:90::c8/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe20:9c9a/64 scope link
       valid_lft forever preferred_lft forever

LAN Connectivity

These are the ARP and NDP caches. There’s lots of output on this server, with clients, printers, routers, and managed switches chattering away. “REACHABLE” means it’s in use more or less right now, “STALE” means it’s been used recently but is due for refreshing.

$ ip neigh
fe80::201:5cff:fe79:1446 dev enp0s20 lladdr 02:42:b6:73:57:28 REACHABLE
fe80::20c:29ff:fe20:7604 dev enp0s18 lladdr b8:27:eb:20:76:04 STALE
fe80::20c:29ff:fe5d:2709 dev enp0s18 lladdr b8:27:eb:5d:27:09 STALE
2001:1800:1234:90:e871:5fb3:1a98:3a7a dev enp0s20 lladdr 2c:27:d7:c5:d3:7b REACHABLE
fe80::20c:29ff:fe34:c50d dev enp0s18 lladdr b8:27:eb:34:c5:0d STALE
2001:1800:1234:90:cb5:c013:429f:7c50 dev enp0s20 lladdr 2c:27:d7:c5:d3:7b REACHABLE
[... much deleted ...]
10.1.1.254 dev enp0s20 lladdr b8:27:eb:8d:69:01 REACHABLE
10.1.1.1 dev enp0s20 lladdr b8:27:eb:8d:69:01 REACHABLE
10.1.1.16 dev enp0s20 lladdr b8:27:eb:45:e3:10 STALE
10.1.1.15 dev enp0s20 lladdr b8:27:eb:59:66:0f REACHABLE
10.1.1.11 dev enp0s20 lladdr b8:27:eb:43:ec:0b REACHABLE
10.1.1.19 dev enp0s20 lladdr b8:27:eb:c2:f2:13 REACHABLE
[... much deleted ...]

IP routing

How do we reach other IP hosts, possibly several router hops away?

$ ip route
default via 10.1.1.254 dev enp0s20 metric 5
10.1.1.0/24 dev enp0s20 proto kernel scope link src 10.1.1.200
169.254.0.0/16 dev enp0s18 scope link metric 1002
169.254.0.0/16 dev enp0s20 scope link metric 1003
172.16.0.0/16 dev enp0s18 proto kernel scope link src 172.16.0.200

$ ip -6 route
unreachable ::/96 dev lo metric 1024 error -101
unreachable ::ffff:0.0.0.0/96 dev lo metric 1024 error -101
2001:1800:1234:90::/64 dev enp0s20 proto kernel metric 256
unreachable 2002:a00::/24 dev lo metric 1024 error -101
unreachable 2002:7f00::/24 dev lo metric 1024 error -101
unreachable 2002:a9fe::/32 dev lo metric 1024 error -101
unreachable 2002:ac10::/28 dev lo metric 1024 error -101
unreachable 2002:c0a8::/32 dev lo metric 1024 error -101
unreachable 2002:e000::/19 dev lo metric 1024 error -101
unreachable 3ffe:ffff::/32 dev lo metric 1024 error -101
fe80::/64 dev enp0s18 proto kernel metric 256
fe80::/64 dev enp0s20 proto kernel metric 256
default via fe80::201:5cff:fe79:1446 dev enp0s20 proto ra metric 1024 expires 1797sec pref medium

Don’t worry about the unreachable IPv6 routes! Those are “black-holed” routes to address blocks for retired experimental projects, for mapping IPv6 to special use and private IPv4 address blocks and other reserved blocks.

This is just a start

The hands-on exercises in Learning Tree’s Linux server administration course fill in the details. Check it out if you want to learn more about Linux networking.

image sources

  • network-cables-dscf0339: Bob Cromwell

Type to search blog.learningtree.com

Do you mean "" ?

Sorry, no results were found for your query.

Please check your spelling and try your search again.