Skip to content

Linux Foundations / Follow traffic and find the fault ยท Step 7 of 46

Lesson: Network LayerSwitch
โ† Linux Foundations

Network operations

Network Layer

How IP and routing tables move packets between networks, with ping and traceroute.

The network layer moves packets from one network to another. On the internet its protocol is IP, in version 4 or version 6.

What IP does

Each IP packet carries a source and destination address. IP does its best to deliver it but makes no promise: packets can be lost, duplicated or arrive out of order. Reliability, when needed, comes from higher layers such as TCP.

The routing table

Every host has a table that says where to send packets:

$ ip route
default via 192.168.1.1 dev enp1s0
192.168.1.0/24 dev enp1s0 proto kernel scope link src 192.168.1.20

The second line says that 192.168.1.0/24 is directly connected. The default route is for everything not matched by anything more specific, and sends it to the gateway.

When several routes match, the longest prefix wins. A /24 beats a /16, and both beat default. Ask the kernel what it would do:

$ ip route get 8.8.8.8
8.8.8.8 via 192.168.1.1 dev enp1s0 src 192.168.1.20

For IPv6 use ip -6 route.

Hop limits and ICMP

Each router lowers the packet's TTL (called Hop Limit in IPv6) by one. At zero, the packet is discarded, which stops routing loops from circulating it forever. The router normally reports this with an ICMP message.

ICMP carries errors and diagnostics. ping uses ICMP echo requests and replies.

traceroute sends packets with TTL 1, 2, 3 and so on, so that each router along the path reveals itself:

$ traceroute -n 8.8.8.8
 1  192.168.1.1   0.6 ms
 2  203.0.113.1   8.2 ms
 3  * * *

This output is shortened. You may need to install it. tracepath is a similar tool. A * means no reply was received, which does not by itself prove the path is broken.

Try it

Run ip route, then ip route get for your gateway and for a public address, and compare. If you add or delete routes with ip route, do it on a test system: a mistake can cut your remote session, and such changes normally do not survive a reboot. The broken default route lab is a safe place to troubleshoot one.

Check your understanding

Network Layer

All 4 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.