Day 1: Is the link there?
Goal: From a single line you can tell whether an interface itself is switched off, whether the other end is missing or whether packets are dropped along the way, and you prove every fix with the same command · Duration: approx. 60 min · Prerequisite: the training ground from Day 0 is running (Day 0 checkpoint green)
Briefing
- The lowest stage of the method is the link: is the cable plugged in,
is the interface up, does it see the other side? Without a link,
address, route and firewall don’t matter. Still, this stage is the one
skipped most often, because
pingonly says “100% packet loss” and not why. - In production the interface is called
ens19,bond0oreth1, in the training groundeth0,stor0orb-db. The commands are the same. A veth pair from Day 0 behaves like a cable with two plugs: if you pull one plug, the other side notices. - Today three failure patterns: an interface that is switched off, a missing counterpart and packets that are silently dropped because of a wrong MTU. Plus a fourth in the challenge, where all the lights are green.
Drill 1: Reading the short form
# on netz
# State and addresses of all interfaces in the namespace db, one line per interface
# -n db run the command in the network namespace db (short form of ip netns exec db ip …)
# -br short table form
# addr object addresses (spelled out: address)
sudo ip -n db -br addr
# The same for the link layer: MAC address and flags instead of IP addresses
# link object interfaces
sudo ip -n db -br linkExpected:
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if32 UP 10.2.0.20/24 fe80::344b:cbff:fe79:ef3a/64
stor0@if34 UP 10.10.0.20/24 fe80::444e:6eff:fe8b:6afb/64
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0@if32 UP 36:4b:cb:79:ef:3a <BROADCAST,MULTICAST,UP,LOWER_UP>
stor0@if34 UP 46:4e:6e:8b:6a:fb <BROADCAST,MULTICAST,UP,LOWER_UP>
The index numbers (@if32), MAC and IPv6 addresses look
different on your system. The three columns of the second output are
your tool for the whole day:
| Column | Meaning | Values |
|---|---|---|
| second (operstate) | state from the kernel’s point of view | UP, DOWN, LOWERLAYERDOWN,
UNKNOWN (loopback, some virtual interfaces) |
flag UP |
interface is switched on (you or a service ran
ip link set … up) |
missing = switched off by hand |
flag LOWER_UP |
carrier present: cable plugged in, other side responds | missing, with NO-CARRIER instead = other side
missing |
@if32 after the name means: the other end of this veth
pair has index 32, in another namespace. The root namespace shows which
interface that is:
# on netz
# All interfaces in the root namespace, one line per interface, only the first two fields
# -o one line per interface (good for grep)
# grep '^3[0-5]:' only the lines with index 30 to 35
# cut -d' ' -f1-2 split at spaces, keep fields 1 and 2 (index and name)
ip -o link show | grep '^3[0-5]:' | cut -d' ' -f1-2Expected (numbers may differ):
30: b-router@if3:
31: b-web@if2:
32: b-db@if2:
33: s-web@if3:
34: s-db@if3:
35: up0@if4:
Index 32 is b-db, the bridge end of db’s
eth0, and 34 is s-db, the end of
stor0. You will need this mapping shortly, when something
breaks.
Save your progress? Sign up for free
Drill 2: Who is attached to which bridge?
A bridge is a switch in the kernel. An interface attached to it is
called a port and has the entry
master <bridge>.
# on netz
# Only the interfaces whose master is br-s, in long form
# master br-s filter: ports of this bridge
ip link show master br-s
# All bridge ports with their port state
# bridge link show part of iproute2, shows the ports of all bridges
bridge link showExpected (shortened):
33: s-web@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-s state UP mode DEFAULT group default qlen 1000
link/ether 4a:c6:31:1f:7e:d3 brd ff:ff:ff:ff:ff:ff link-netns web
34: s-db@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-s state UP mode DEFAULT group default qlen 1000
link/ether 82:c2:08:e0:b0:95 brd ff:ff:ff:ff:ff:ff link-netns db
28: a-client@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br-a state forwarding priority 32 cost 2
…
32: b-db@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br-b state forwarding priority 32 cost 2
33: s-web@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br-s state forwarding priority 32 cost 2
34: s-db@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br-s state forwarding priority 32 cost 2
In the long form, next to the flags you find the mtu
(largest packet in bytes), master br-s and
link-netns db (the other end lives in the namespace db).
With bridge link, state forwarding is the
state in which a port forwards packets. disabled means: the
port is there but forwards nothing.
If you want to see all the details of an interface, use
-d:
# on netz
# Details on s-db: type of the interface and bridge port settings
# -d details: additionally shows the type (veth, bridge, vlan …) and driver parameters
# head -3 only the first three lines
ip -d link show s-db | head -3Expected (the third line is the type):
34: s-db@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-s state UP mode DEFAULT group default qlen 1000
link/ether 82:c2:08:e0:b0:95 brd ff:ff:ff:ff:ff:ff link-netns db promiscuity 1 allmulti 1 minmtu 68 maxmtu 65535
veth
Save your progress? Sign up for free
Drill 3: Link gone: who sees what?
A typical case from storage clusters, recreated in the training
ground: on a storage node the replication network fails – on real
servers usually a second card such as ens19, here it is
stor0 in db.
# on netz
# Introduce the fault: switch off stor0 in db
# link set stor0 down switch off interface stor0 (flag UP gone)
sudo ip -n db link set stor0 downNow you look at the same problem from three places. First from the neighbor web, like a colleague who only reports “replication hangs”:
# on netz
# Which route would web take for 10.10.0.20?
# route get 10.10.0.20 ask the kernel without sending a packet
sudo ip -n web route get 10.10.0.20
# Does anything arrive?
# -c2 send two packets
# -W1 wait at most 1 second for each reply
# -q quiet: summary only
# tail -2 only the last two lines
sudo ip netns exec web ping -c2 -W1 -q 10.10.0.20 | tail -2Expected:
10.10.0.20 dev stor0 src 10.10.0.10 uid 0
cache
2 packets transmitted, 0 received, 100% packet loss, time 1000ms
The route is there, the packets go out, nothing comes back. From web this looks like a firewall or a crashed service. Only a look at the affected machine shows the reason:
# on netz
# State of stor0 in db
# show stor0 only this interface
sudo ip -n db -br addr show stor0
# Routing table of db
sudo ip -n db routeExpected:
stor0@if34 DOWN 10.10.0.20/24
default via 10.2.0.1 dev eth0
10.2.0.0/24 dev eth0 proto kernel scope link src 10.2.0.20
Three pieces of evidence: state DOWN, the IPv6 address
fe80::… has disappeared, and the route into the network
10.10.0.0/24 is missing from the table. The IPv4 address
stays configured, it just has no effect. That is why a look at
ip addr alone is not enough; the state column is what
matters.
The third place is the other end of the cable, the bridge port in the root namespace:
# on netz
# The other end of stor0 (index 34, see Drill 1)
ip -br link show s-db
# Port state at the bridge
# dev s-db only this port
bridge link show dev s-dbExpected:
s-db@if3 DOWN 82:c2:08:e0:b0:95 <NO-CARRIER,BROADCAST,MULTICAST,UP>
34: s-db@if3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br-s state disabled priority 32 cost 2
s-db itself is switched on (flag UP) but
has no carrier (NO-CARRIER), because the other end is off.
The bridge has therefore set the port to disabled. This is
exactly what a switch port looks like when the server has switched off
its network card.
Fix and proof with the same commands as for the measurement:
# on netz
# Switch the interface back on
sudo ip -n db link set stor0 up
# Proof 1: state
sudo ip -n db -br addr show stor0
# Proof 2: packets arrive
sudo ip netns exec web ping -c2 -W1 -q 10.10.0.20 | tail -2Expected:
stor0@if34 UP 10.10.0.20/24 fe80::444e:6eff:fe8b:6afb/64
2 packets transmitted, 2 received, 0% packet loss, time 1011ms
rtt min/avg/max/mdev = 0.105/0.146/0.188/0.041 ms
With a veth pair the link is back immediately. A real network card
often needs two to five seconds after up to negotiate with
the switch. That is why on real hardware a sleep 3 belongs
before the check: if you check right away, you still see
DOWN and hunt for a fault that doesn’t exist.
Save your progress? Sign up for free
Drill 4: Reading counters: packets that silently vanish
A link can be UP and LOWER_UP and still
lose packets. The counters show where.
# on netz
# Statistics of the bridge end b-db
# -s statistics: byte, packet, error and drop counters
ip -s link show b-dbExpected (your numbers are different; what matters
are errors and dropped):
32: b-db@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b state UP mode DEFAULT group default qlen 1000
link/ether 96:73:8e:6a:52:85 brd ff:ff:ff:ff:ff:ff link-netns db
RX: bytes packets errors dropped missed mcast
1286 17 0 0 0 0
TX: bytes packets errors dropped carrier collsns
4754 63 0 0 0 0
RX are received packets, TX sent packets.
errors counts broken packets (with real cards often cable
or connector), dropped counts packets the kernel
deliberately discarded: full buffer, wrong MTU, unknown protocol.
Now the fault: someone set a smaller MTU in db, for example because a VPN vendor’s instructions say so. The rest of the network keeps sending packets of up to 1500 bytes.
# on netz
# Introduce the fault: MTU of eth0 in db to 1400 bytes
# mtu 1400 largest packet this interface accepts
sudo ip -n db link set eth0 mtu 1400
# Small packets: all fine
sudo ip netns exec web ping -c3 -W1 -q 10.2.0.20 | tail -2
# Large packets: 1450 bytes payload + 28 bytes header = 1478 bytes, larger than 1400
# -s 1450 payload size in bytes (default 56)
sudo ip netns exec web ping -c3 -W1 -q -s 1450 10.2.0.20 | tail -2Expected:
3 packets transmitted, 3 received, 0% packet loss, time 2073ms
rtt min/avg/max/mdev = 0.107/0.146/0.206/0.042 ms
3 packets transmitted, 0 received, 100% packet loss, time 2080ms
This is the typical MTU failure pattern: ping works, SSH
login works, but large responses (a web page, a git clone,
a database dump) hang. The counters show where the packets end up:
# on netz
ip -s link show b-db
sudo ip -n db -s link show eth0Expected (excerpt):
TX: bytes packets errors dropped carrier collsns
5132 68 0 3 0 0
…
2: eth0@if32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue state UP mode DEFAULT group default qlen 1000
RX: bytes packets errors dropped missed mcast
5132 68 0 3 0 0
Exactly 3 dropped packets, the three large pings. Both ends count
them: b-db as TX dropped, db’s
eth0 as RX dropped. And the header line shows
the cause: mtu 1400.
If you need more details, double the -s:
# on netz
# Error counters broken down by type
# -s -s twice: additionally RX errors (length, crc, frame, fifo, overrun) and TX errors
ip -s -s link show b-dbWith real cards, crc or frame point to
cable and connector, fifo and overrun to an
overloaded card. With veth they stay 0.
Fix and proof:
# on netz
# MTU back to 1500
sudo ip -n db link set eth0 mtu 1500
# Proof: large packets arrive
sudo ip netns exec web ping -c2 -W1 -q -s 1450 10.2.0.20 | tail -2Expected:
2 packets transmitted, 2 received, 0% packet loss, time 1054ms
rtt min/avg/max/mdev = 0.094/0.107/0.121/0.013 ms
The counters don’t go back down. Note the value before the test and compare afterwards. A counter that has been at 3 for months is not a current fault.
Save your progress? Sign up for free
Drill 5: ethtool: what the driver knows
ip shows what the kernel knows about an interface;
ethtool asks the driver: speed, duplex, driver name and
driver-specific counters.
# on netz
# Driver of the interface
# -i driver information: driver, version, firmware, bus
ethtool -i b-db | head -2
# Speed, duplex and link from the driver's point of view
# grep -E several patterns with | (extended regular expressions)
sudo ethtool b-db | grep -E 'Speed|Duplex|Link detected'
# Driver-specific statistics, here only the number of the other end
# -S driver statistics (different counters per driver)
ethtool -S b-db | grep peer_ifindexExpected:
driver: veth
version: 1.0
Speed: 10000Mb/s
Duplex: Full
Link detected: yes
peer_ifindex: 2
Without sudo, ethtool b-db additionally
reports netlink error: Operation not permitted, because
some queries need root. peer_ifindex: 2 is the index of the
other end in its namespace; in db that is eth0 (index 2).
This is the reverse path to @if32 from Drill 1.
The VM itself has a virtual network card from Proxmox:
# on netz
sudo ethtool eth0 | grep -E 'Speed|Duplex|Link detected'
ethtool -i eth0 | head -1Expected:
Speed: Unknown!
Duplex: Unknown! (255)
Link detected: yes
driver: virtio_net
Unknown! is normal with virtio_net; the
virtual card has no real speed. On bare metal you see
Speed: 10000Mb/s here, or 1000Mb/s even though
the card can do 10 G. That is a classic finding: the switch port or the
cable negotiated only 1 G, and replication is ten times slower than
planned.
Save your progress? Sign up for free
Exercise
A colleague changed something on the training ground “just quickly”. Since then the client no longer gets a reply from the web server. Introduce the fault without looking at the command you are about to search for; it is in the solution:
# on netz
# Introduce the fault (read this line carefully only after the exercise)
sudo ip link set b-web downFind the cause from web, that is, only with commands that look into the namespace web, and then follow the index number into the root network. Write down the four steps of the method.
Solution
# on netz
# Symptom: curl waits 3 seconds and gives up
# -s silent, no progress bar
# -m3 at most 3 seconds in total (max-time)
# -o /dev/null throw away the response body
# -w '%{http_code}\n' print only the HTTP status (000 = no response)
sudo ip netns exec client curl -s -m3 -o /dev/null -w '%{http_code}\n' http://10.2.0.10/
# Hypothesis: web's link is gone. Measurement in the namespace web:
sudo ip -n web -br linkExpected:
000
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0@if31 DOWN 4a:86:c1:de:45:34 <NO-CARRIER,BROADCAST,MULTICAST,UP>
stor0@if33 UP e2:ae:31:d9:99:b1 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth0 is switched on (UP in the flags) but
has NO-CARRIER: web is not to blame, the other end is. That
one has index 31:
# on netz
# Cause: who is index 31, and what state is it in?
ip -o link show | grep '^31:' | cut -d' ' -f2
ip -br link show b-webExpected:
b-web@if2:
b-web@if2 DOWN a6:9c:c1:4b:e4:6d <BROADCAST,MULTICAST>
b-web lacks the flag UP: it was switched
off by hand. This is the difference you should remember:
| Flags | Meaning | Where to look |
|---|---|---|
<BROADCAST,MULTICAST> (without
UP) |
this interface is switched off | here: ip link set … up |
<NO-CARRIER,…,UP> |
switched on, but the other side is missing | at the other end: switch port, cable, partner |
Proof of the fix:
# on netz
sudo ip link set b-web up
sudo ip -n web -br link show eth0
sudo ip netns exec client curl -s -m3 http://10.2.0.10/Expected:
eth0@if31 UP 4a:86:c1:de:45:34 <BROADCAST,MULTICAST,UP,LOWER_UP>
hallo von web
By the way: as long as the carrier was missing, web’s routes were
still in the table, but with the addition linkdown
(sudo ip -n web route shows
default via 10.2.0.1 dev eth0 linkdown). If you only look
for missing routes, you easily overlook this word.
Save your progress? Sign up for free
Challenge
Introduce this fault:
# on netz
# Introduce the fault
# nomaster detach the interface from its bridge (opposite of master br-b)
sudo ip link set b-db nomasterweb no longer reaches db (ping 10.2.0.20 100% loss).
Show that all interfaces involved are UP
and LOWER_UP, and still find what is missing with a single
command. Fix it and prove the fix.
Solution
# on netz
# All lights green
sudo ip -n db -br link show eth0
ip -br link show b-db
# Which ports does br-b have?
ip -br link show master br-bExpected:
eth0@if32 UP 36:4b:cb:79:ef:3a <BROADCAST,MULTICAST,UP,LOWER_UP>
b-db@if2 UP 96:73:8e:6a:52:85 <BROADCAST,MULTICAST,UP,LOWER_UP>
b-router@if3 UP 5e:b4:38:ce:3a:91 <BROADCAST,MULTICAST,UP,LOWER_UP>
b-web@if2 UP a6:9c:c1:4b:e4:6d <BROADCAST,MULTICAST,UP,LOWER_UP>
b-db is missing from the list of ports. The cable is
plugged into both devices, but not into the switch: the interface is on,
has carrier, it just leads nowhere. In the data center this corresponds
to a switch port in the wrong VLAN.
# on netz
# Fix: attach b-db to br-b again
# master br-b make the interface a port of the bridge br-b
sudo ip link set b-db master br-b
# Proof 1: b-db is a port again
ip -br link show master br-b
# Proof 2: packets arrive (the port needs a moment, hence three packets)
sudo ip netns exec web ping -c3 -W1 -q 10.2.0.20 | tail -2Expected:
b-router@if3 UP 5e:b4:38:ce:3a:91 <BROADCAST,MULTICAST,UP,LOWER_UP>
b-web@if2 UP a6:9c:c1:4b:e4:6d <BROADCAST,MULTICAST,UP,LOWER_UP>
b-db@if2 UP 96:73:8e:6a:52:85 <BROADCAST,MULTICAST,UP,LOWER_UP>
3 packets transmitted, 3 received, 0% packet loss, time 2080ms
rtt min/avg/max/mdev = 0.153/0.210/0.308/0.069 ms
Right after attaching, the first packet may still get lost
(+1 errors), because db first has to be found again via
ARP. That is Day 3.
Save your progress? Sign up for free
Checkpoint
# on netz
# all interfaces of all four namespaces with carrier
for ns in client router web db; do sudo ip -n $ns -br link | grep -vc LOWER_UP; done
# all seven bridge ports forward
bridge link show | grep -c 'state forwarding'
# no deviating MTU in the training ground
ip -o link show | grep -c 'mtu 1500'
# storage network and web server reachable
sudo ip netns exec web ping -c1 -W1 -q 10.10.0.20 >/dev/null && echo "stor ok"
sudo ip netns exec client curl -s -m3 http://10.2.0.10/for ns in …; do …; done runs the command once per
namespace. grep -v inverts the filter, -c
counts: so the loop prints, per namespace, the number of interfaces
without carrier.
Expected:
0
0
0
0
7
12
stor ok
hallo von web
Interview note
“A server is unreachable in the storage network. How do you proceed?”
First, on the affected machine, ip -br link: if
UP is missing, the interface is off; if
LOWER_UP is missing with NO-CARRIER, the
problem is at the other end. Then ip -s link before/after
for drops, ethtool for speed and duplex. If you can explain
linkdown in ip route and know that a bridge
port membership can be missing while all the lights are green, you show
that you don’t just know layer 2 by heart.
Enterprise note
In data centers a link fault is rarely a pulled cable; it is a port
in the wrong VLAN, a bond with a dead member or a card that negotiated
only 1 G. So don’t just monitor “interface up”, but also the drop and
error counters as a rate and the negotiated speed (node_exporter
provides node_network_receive_drop_total and
node_network_speed_bytes). An alert on “speed lower than
expected” finds the 1 G trap before replication falls behind.