Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 04 · Networking · The whole trip · about 15 min to read

Play it as a journeyTutor comes with a plan

The wall that remembers: nftables and conntrack

Inside Your Building
Inside Your Building · Open board

The doorman’s book that rewrites addresses at the edge of a building. This lesson shows the same book kept inside the Linux kernel, and the wall that reads it.

On 4 January 2001 Linus Torvalds released Linux 2.4.0. It carried a new packet-filtering framework called netfilter, and its authors wrote down what changed. Under the old tool, ipchains, a forwarded packet “used to traverse three chains”, and the paper calls fixing that “one big change”. The new tool, iptables, was described as small and fast. Harald Welte’s paper on it adds that connection tracking lets the filter use “‘stateful firewalling’”.

That is the whole idea. Before it, a Linux wall judged every packet alone, like a guard who has never seen the visitor before. Afterwards the wall kept a list of the conversations it had let start, and judged each packet against the list.

By the end of this lesson you will be able to read a small nftables ruleset, say what each line does to a packet, and explain why a home router can let your reply in while it refuses a stranger.

Before you start. Inside your building (your router's life) gave you the doorman’s book, which rewrites a flat’s private address and port into the building’s public ones, and the four-part identity of a connection (source address, source port, destination address, destination port). Security Groups vs Network ACLs showed that a wall which judges each packet alone must leave a huge range of doors open for replies, while a wall with memory does not. It won't load: the ladder (network debugging) showed that a firewall can reject a knock or silently drop it, and that you can tell the two apart by the wait.

Lesson 38 of 44 in Networking

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • The shoe counter: why a wall needs a memory
  • The conntrack table: the list of conversations
  • Connection state: new, established, and the rest
  • nftables: the rules that read the state
  • Masquerade: one public name on every token
  • When the counter runs out of tokens
  • Hooks and priorities: where conntrack sits in the path
  • The states, precisely
  • The model, in full
  • Trade-offs and real systems

Terms it explains: conntrack table, new, established, connection state, nftables, chain, masquerade, hooks.

Review Networking