Skip to content
LF Cert Trainer

Lesson 110 · Section 9: Networking

Lesson 110: Explore Environment: reading a cluster's network

A hands-on routine for an unfamiliar cluster: find each node's address, interface and MAC address, the bridge and routes on a node, the default gateway, and which component listens on which port, with ip, ss and kubectl. · 14 min read · 4 min video

1/10Explore Environment
0:00 / 3:38

Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.

What this lesson is about

The previous lesson listed what a cluster's network must look like. This one is practice: you sit in front of a cluster somebody else built, and you find out what its network actually looks like. That is the first step of every networking task in the exam, and of every real troubleshooting session.

Nothing here changes the cluster. Every command only reads. You will learn to answer questions such as:

  • What is the address of this node, and which interface holds it?
  • What is the MAC address of that interface, on this node and on another one?
  • Which bridge did the container runtime's network plugin create, and is it up?
  • Where does a packet for the internet go?
  • On which port does the scheduler listen? Which etcd port has the most connections?

The toolbox

Five questions, five commandsrunrunrunrunrunWhich address?and on which interfaceWhich MAC, state?bridges, veth pairsWhich way out?gateway, Pod routesWho is next to me?MAC of another nodeWho listens?ports and processesip addrip -br aip linkstate, MAC, typeip routeip route show defaultip neighthe ARP tabless -tlnpneeds root for -p
Five questions, five commands. Almost every question about a node's network is answered by one of these. The ip command covers addresses, links, routes and neighbours, and ss covers ports.

Parts:

  • Which address? (and on which interface)
  • Which MAC, state? (bridges, veth pairs)
  • Which way out? (gateway, Pod routes)
  • Who is next to me? (MAC of another node)
  • Who listens? (ports and processes)
  • ip addr (ip -br a)
  • ip link (state, MAC, type)
  • ip route (ip route show default)
  • ip neigh (the ARP table)
  • ss -tlnp (needs root for -p)

Connections:

  • Which address? to ip addr: run
  • Which MAC, state? to ip link: run
  • Which way out? to ip route: run
  • Who is next to me? to ip neigh: run
  • Who listens? to ss -tlnp: run
QuestionCommandOld equivalent
Addresses and the interfaces that hold themip addr (ip a)ifconfig
MAC address, state and type of an interfaceip linkifconfig
Routes and the default gatewayip route (ip r)route -n
MAC addresses of other machines on the networkip neigh (ip n)arp -n
Listening ports and their processesss -tlnpnetstat -tlnp
Open connectionsss -tnpnetstat -anp

Two options make ip much easier to read:

  • -br (brief) prints one line per interface: name, state, addresses.
  • -c adds colour. ip -br -c addr is a good habit.

The old tools (ifconfig, route, arp, netstat) come from the net-tools package, which many current distributions and most container images no longer install. Learn the ip and ss forms. They are always there.

The routine

The examples use a small kubeadm cluster: one control plane node, one worker, Flannel as the network plugin. Your cluster will have other names and numbers. The method is the same.

1. The nodes

kubectl get nodes -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
controlplane   Ready    control-plane   12d   v1.37.0   192.168.56.11   <none>        Ubuntu 24.04.3 LTS   6.8.0-88-generic   containerd://2.1.4
node01         Ready    <none>          12d   v1.37.0   192.168.56.21   <none>        Ubuntu 24.04.3 LTS   6.8.0-88-generic   containerd://2.1.4

INTERNAL-IP is the address the node registered with, the one the API server uses to reach its kubelet. The last column tells you the container runtime, which decides whether you will use crictl on the node.

2. The interface behind the node address

On the node (you are usually already on the control plane node; use ssh node01 for others):

ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0             UP             192.168.56.11/24 fe80::a00:27ff:fe3b:5ec1/64
flannel.1        UNKNOWN        10.244.0.0/32
cni0             UP             10.244.0.1/24
veth1a2b3c4d@if2 UP
veth9f8e7d6c@if2 UP

The node address 192.168.56.11 is on eth0. When the list is long, let grep find it:

ip -br addr | grep 192.168.56.11
The interfaces of a node, and what each is forcontrolplanedefaultsame LANvethwrappedflannel.1to other nodes' Podseth0192.168.56.11/24Default gateway192.168.56.1Pods10.244.0.xcni0 bridge10.244.0.1/24node01192.168.56.21
The interfaces of a node, and what each is for. One real interface carries the node's address. The rest is created by the CNI plugin: a bridge for the Pods of this node, a veth per Pod, and (with an overlay plugin) a tunnel interface towards the other nodes.

Parts:

  • flannel.1 (to other nodes' Pods), in controlplane
  • eth0 (192.168.56.11/24), in controlplane
  • Default gateway (192.168.56.1)
  • Pods (10.244.0.x), in controlplane
  • cni0 bridge (10.244.0.1/24), in controlplane
  • node01 (192.168.56.21)

Connections:

  • eth0 to Default gateway: default
  • eth0 to node01: same LAN
  • cni0 bridge to Pods: veth
  • flannel.1 to eth0: wrapped
InterfaceWhat it is
loLoopback
eth0 (or ens3, enp0s8, ...)The real interface on the node network
cni0A bridge created by the CNI plugin. Every Pod on this node is attached to it. Its address is the Pods' gateway
veth...@if2The host end of a veth pair. One per Pod on this node
flannel.1A tunnel interface (VXLAN) towards the Pod networks of the other nodes. Other plugins create tunl0, vxlan.calico, cilium_vxlan or weave

Interface names differ between plugins, and some plugins use no bridge at all (Calico routes to each cali... interface directly). The names are a strong hint about which plugin the cluster runs.

3. MAC addresses

ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:3b:5e:c1 brd ff:ff:ff:ff:ff:ff

The MAC address follows link/ether. The first line carries the state (state UP) and the MTU.

For the MAC address of another node there are two ways:

ssh node01 ip -br link show eth0          # ask the node itself
ip neigh show 192.168.56.21               # or read this node's neighbour (ARP) table
eth0             UP             08:00:27:9a:44:10 <BROADCAST,MULTICAST,UP,LOWER_UP>
192.168.56.21 dev eth0 lladdr 08:00:27:9a:44:10 REACHABLE

The neighbour table only has an entry after the two machines exchanged packets. If it is empty, ping -c 1 192.168.56.21 fills it.

4. The bridge and its Pods

ip -br link show type bridge
ip -br link show master cni0
cni0             UP             5a:1c:e3:70:b2:0f <BROADCAST,MULTICAST,UP,LOWER_UP>
veth1a2b3c4d@if2 UP             8e:41:d0:15:a7:3c <BROADCAST,MULTICAST,UP,LOWER_UP>
veth9f8e7d6c@if2 UP             de:6b:02:c9:f4:71 <BROADCAST,MULTICAST,UP,LOWER_UP>

type bridge filters by interface type, and master cni0 lists the interfaces plugged into that bridge. Two veth interfaces means two Pods with their own network namespace on this node. (Pods that use the host's network, such as kube-proxy and the control plane's static Pods, have none.)

5. Routes and the default gateway

ip route
default via 192.168.56.1 dev eth0 proto dhcp src 192.168.56.11 metric 100
10.244.0.0/24 dev cni0 proto kernel scope link src 10.244.0.1
10.244.1.0/24 via 10.244.1.0 dev flannel.1 onlink
192.168.56.0/24 dev eth0 proto kernel scope link src 192.168.56.11

Read it line by line:

RouteMeaning
default via 192.168.56.1 dev eth0Everything not listed below goes to the gateway 192.168.56.1
10.244.0.0/24 dev cni0Pods of this node are directly on the bridge
10.244.1.0/24 via ... dev flannel.1Pods of node01 are reached through the tunnel
192.168.56.0/24 dev eth0Other nodes are directly on the node network

To ask only for the default route, or for the route the kernel would pick for one destination:

ip route show default
ip route get 10.244.1.7
default via 192.168.56.1 dev eth0 proto dhcp src 192.168.56.11 metric 100
10.244.1.7 via 10.244.1.0 dev flannel.1 src 10.244.0.0 uid 0

ip route get is the fastest way to answer "which interface would a packet to this Pod leave through?".

6. Ports and processes

sudo ss -tlnp | grep -E 'kube|etcd'
LISTEN 0  4096  192.168.56.11:2379   0.0.0.0:*  users:(("etcd",pid=1432,fd=9))
LISTEN 0  4096      127.0.0.1:2379   0.0.0.0:*  users:(("etcd",pid=1432,fd=10))
LISTEN 0  4096  192.168.56.11:2380   0.0.0.0:*  users:(("etcd",pid=1432,fd=8))
LISTEN 0  4096      127.0.0.1:2381   0.0.0.0:*  users:(("etcd",pid=1432,fd=14))
LISTEN 0  4096      127.0.0.1:10248  0.0.0.0:*  users:(("kubelet",pid=873,fd=17))
LISTEN 0  4096      127.0.0.1:10249  0.0.0.0:*  users:(("kube-proxy",pid=2110,fd=11))
LISTEN 0  4096      127.0.0.1:10257  0.0.0.0:*  users:(("kube-controller",pid=1411,fd=3))
LISTEN 0  4096      127.0.0.1:10259  0.0.0.0:*  users:(("kube-scheduler",pid=1398,fd=3))
LISTEN 0  4096              *:6443         *:*  users:(("kube-apiserver",pid=1467,fd=3))
LISTEN 0  4096              *:10250        *:*  users:(("kubelet",pid=873,fd=12))
LISTEN 0  4096              *:10256        *:*  users:(("kube-proxy",pid=2110,fd=10))
OptionMeaning
-tTCP sockets (-u for UDP)
-lListening sockets only
-nNumbers, not service names
-pThe process that owns the socket. Needs root to see other users' processes
-aAll sockets: listening and connected

The fourth column is address:port. *:6443 means every address of the node, 127.0.0.1:10259 means this machine only. The process name is cut to 15 characters, which is why the controller manager shows up as kube-controller.

Why etcd shows several ports

The ports of etcd, by who uses themetcdclientspeersprobeskube-apiservermany connectionsOther etcd membersnone on one nodekubelet probeshealth checks:2379client port:2380peer port:2381localhost only
The ports of etcd, by who uses them. Port 2379 serves clients, and the API server keeps many connections open to it. Port 2380 is for other etcd members, so on a single control plane node it has no connections at all.

Parts:

  • kube-apiserver (many connections)
  • Other etcd members (none on one node)
  • kubelet probes (health checks)
  • :2379 (client port), in etcd
  • :2380 (peer port), in etcd
  • :2381 (localhost only), in etcd

Connections:

  • kube-apiserver to :2379: clients
  • Other etcd members to :2380: peers
  • kubelet probes to :2381: probes
  • 2379 is the client port. The API server is the only client, but it opens many connections, roughly one per resource type it watches.
  • 2380 is the peer port. With one etcd member, nobody connects to it.
  • 2381 serves /health and metrics over plain HTTP on localhost for the kubelet's probes.

So to the question "which etcd port has more client connections?", the answer is 2379, and you can count:

sudo ss -tn state established '( sport = :2379 )' | tail -n +2 | wc -l
sudo ss -tn state established '( sport = :2380 )' | tail -n +2 | wc -l
96
0

7. The cluster's own network components

Finish back in kubectl:

kubectl get pods -n kube-system -o wide
ls /etc/cni/net.d/
NAME                                   READY   STATUS    RESTARTS   AGE   IP              NODE
coredns-7d764666f9-4xk2p               1/1     Running   0          12d   10.244.0.2      controlplane
coredns-7d764666f9-v9qhm               1/1     Running   0          12d   10.244.0.3      controlplane
etcd-controlplane                      1/1     Running   0          12d   192.168.56.11   controlplane
kube-apiserver-controlplane            1/1     Running   0          12d   192.168.56.11   controlplane
kube-controller-manager-controlplane   1/1     Running   0          12d   192.168.56.11   controlplane
kube-proxy-7m2ld                       1/1     Running   0          12d   192.168.56.11   controlplane
kube-proxy-tq8zc                       1/1     Running   0          12d   192.168.56.21   node01
kube-scheduler-controlplane            1/1     Running   0          12d   192.168.56.11   controlplane

10-flannel.conflist

The IP column separates two kinds of Pods at a glance. Pods with a node address use the host's network (hostNetwork: true). Pods with an address from the Pod range have their own namespace, and those are the two veth interfaces counted in step 4. The file in /etc/cni/net.d names the plugin. Flannel's own Pods run in the kube-flannel namespace; kubectl get pods -A | grep -iE 'flannel|calico|cilium|weave' finds any plugin.

Under the hood · Looking inside a Pod's network namespace from the node

Sometimes you must see the network as a Pod sees it, and the image has no tools. From the node, find the Pod's process and enter only its network namespace:

POD_ID=$(sudo crictl pods --name web -q)
PID=$(sudo crictl inspectp -o go-template --template '{{.info.pid}}' "$POD_ID")
sudo nsenter -t "$PID" -n ip -br addr
sudo nsenter -t "$PID" -n ip route
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0@if7         UP             10.244.0.5/24

default via 10.244.0.1 dev eth0
10.244.0.0/24 dev eth0 proto kernel scope link src 10.244.0.5
10.244.0.0/16 via 10.244.0.1 dev eth0

On most nodes the namespaces are also registered under /run/netns, so sudo ip netns list shows them with names such as cni-3f6a..., and sudo ip netns exec <name> ip -br addr works too.

eth0@if7 says the peer is interface 7 on the host: ip -o link | grep '^7:' shows the matching veth.

Using it

Example · Answer a batch of exploration questions in two minutes

A lab asks: the internal IP of controlplane, its interface, that interface's MAC address, the MAC address of node01, and the default gateway.

kubectl get node controlplane -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}{"\n"}'
ip -br addr | grep 192.168.56.11
ip -br link show eth0
ssh node01 ip -br link show eth0
ip route show default
192.168.56.11
eth0             UP             192.168.56.11/24 fe80::a00:27ff:fe3b:5ec1/64
eth0             UP             08:00:27:3b:5e:c1 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth0             UP             08:00:27:9a:44:10 <BROADCAST,MULTICAST,UP,LOWER_UP>
default via 192.168.56.1 dev eth0 proto dhcp src 192.168.56.11 metric 100

Five commands, five answers. Each answer feeds the next command: the address finds the interface, the interface finds the MAC address.

Example · Find the bridge the plugin created and its state

ip -br link show type bridge
ip -d link show cni0 | head -n 3
cni0             UP             5a:1c:e3:70:b2:0f <BROADCAST,MULTICAST,UP,LOWER_UP>
5: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 5a:1c:e3:70:b2:0f brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
    bridge forward_delay 1500 hello_time 200 max_age 2000 ...

The bridge is cni0 and its state is UP. -d (details) confirms the type. Note mtu 1450: 50 bytes less than eth0, because this plugin wraps Pod packets in VXLAN and the wrapper needs room.

Example · From a port number to the component, and back

"What is listening on port 10256?"

sudo ss -tlnp | grep ':10256'
LISTEN 0  4096  *:10256  *:*  users:(("kube-proxy",pid=2110,fd=10))

"Which ports does the kubelet have open, and which can other machines reach?"

sudo ss -tlnp | grep '"kubelet"' | awk '{print $4}'
127.0.0.1:10248
*:10250

10248 is the local health port. Only 10250 is reachable from outside, and that is the one the API server uses.

Example · Find a Pod's node, address and route in one pass

kubectl get pod web -o wide
ip route get 10.244.1.7
NAME   READY   STATUS    RESTARTS   AGE   IP           NODE     NOMINATED NODE   READINESS GATES
web    1/1     Running   0          3m    10.244.1.7   node01   <none>           <none>

10.244.1.7 via 10.244.1.0 dev flannel.1 src 10.244.0.0 uid 0

The Pod runs on node01 with an address from that node's slice, and from the control plane node a packet to it leaves through the tunnel interface. If ip route get answered dev eth0 via the default gateway instead, this node would have no route to that Pod range, and you would look at the network plugin on this node next.

Tricks

Common mistakes

  • Running commands on the wrong node. ip and ss describe the machine you are on. Check the prompt or run hostname first.
  • Reading the wrong interface. The node address is not always on eth0. Find the interface by address, not by habit.
  • Forgetting sudo with ss -p. Without root the process column is empty for other users' sockets, and grep kube-scheduler finds nothing.
  • Mixing up -l and -a. ss -tlnp shows what listens. To count connections you need established sockets (ss -tn state established or -a).
  • Looking for docker0 on a Kubernetes node. With containerd the bridge belongs to the CNI plugin (cni0 and similar), and some plugins have none.
  • Treating an empty neighbour table as a network fault. Entries appear after traffic. Ping once, then look again.
  • Confusing host-network Pods with ordinary Pods. Static control plane Pods and kube-proxy show the node's address and have no veth interface.

Recap

  • Start with kubectl get nodes -o wide: node names, internal addresses, runtime.
  • ip -br addr shows which interface holds an address. ip link shows MAC address, state and type.
  • ip route shows the default gateway and how Pod ranges of this and other nodes are reached. ip route get answers for one destination.
  • ip neigh gives the MAC addresses of other nodes on the same network.
  • sudo ss -tlnp maps ports to processes. Read the bind address: * or a node address is reachable, 127.0.0.1 is local only.
  • etcd: 2379 for clients (many connections from the API server), 2380 for peers, 2381 for local health checks.

Official docs

Quiz: check what you learned

5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.

Sign in to take the quiz and keep your score.

Practise: try it on a real cluster

A hands-on lab for this lesson. You get goals, not steps: any solution that reaches them passes.

  • Walk through the network of a cluster you have never seen: which interface carries a node's address, where its traffic leaves, which ports the control plane listens on, and which range each node hands to its pods.

    Investigate · Level 1 · warm-up · target 15 min

Discussion

Learners ask and answer questions here. Sign in to read and join the discussion.