The idea
Søren works at a university in Aarhus and is about to run his first Tor relay: a computer that passes other people's Tor traffic along. Before he does, he wants to know who decides whether anyone will use it, and why anyone should believe that decision.
In this lab, a small private Tor network runs with four relays and three machines that keep the official list of relays. You read how they build that list, how Søren's laptop checks it, and what happens when one of them stops.
Steps
-
The laptop trusts three built-in keys, not whoever hands it the list
Before Tor can hide anything, your laptop needs a list of relays. A relay is a volunteer's computer that passes Tor traffic along. Tor sends your traffic through three of them in a row, called a circuit: a guard, a middle and an exit.
To pick those three, the laptop needs every relay's name, address and keys. Asking any one relay for that list would be a trap: a dishonest relay could answer with only its friends, all run by one person. Every circuit built from that list would run through that one owner, who could then see both who you are and where you go.
So the laptop never trusts the relay that hands over the list: it trusts signatures on the list, from keys it already has. Think of a phone book that arrives with stamps on the back. You know what the real stamps look like, so it does not matter who delivered it.
The stamps come from the directory authorities: a few servers, run by people the Tor Project knows, that write and sign the official list. The live network had nine in 2025, and their keys ship inside the Tor program.
In this lab the three authorities are written into the laptop's settings file instead. Read it.
laptop:~# cat /etc/tor/torrc
-
Each authority tests every relay and writes its own vote
A signed list is only as good as what is in it, so the authorities never take a relay's word about itself. Any relay could claim to be fast and always on. Instead each authority checks every relay on its own, like judges at a competition who each score every skater.
Each authority asks every relay: do you answer, how long have you been up, how much traffic do you carry, and do you let traffic leave Tor for the wider internet? From the answers it writes a vote: its own list of every relay, each with flags. A flag is a label for a job the relay is fit for, such as
Guardfor a first hop orExitfor a last hop.A vote is one authority's opinion, so there are as many votes as authorities. The authorities swap their votes every round, and
auth1keeps all three, its own and the two it received, in one file. Print the lines that name each voter, each relay, and each relay's flags.auth1:~# grep -E "^(dir-source|r|s) " /var/lib/tor/v3-status-votes
-
A majority turns three votes into one signed consensus
Three votes leave the laptop with a puzzle: which one should it believe? Believing one authority would let that one authority lie. So the authorities merge the votes into a single list that every client uses, the consensus.
A relay gets a flag in the consensus only when more than half of the votes give it. The laptop uses the consensus only when more than half of the authorities have signed it. Every authority runs the same rule on the same votes, so all of them arrive at the same list, and each one signs it.
That majority is what keeps one bad authority harmless. If someone took over
auth3, its vote alone could not add or remove a flag, and its signature alone would not make a list the laptop accepts.The laptop downloaded the consensus when it started, and keeps a shorter form of it on disk, made for clients.
laptop:~# grep -E "^(valid-after|fresh-until|valid-until|dir-source|r|s|directory-signature) " /var/lib/tor/cached-microdesc-consensus
-
The laptop picks one relay with the Guard flag and keeps it for months
The guard, the first relay in a circuit, is the one relay that sees your real IP address. The guard does not see where you go: the middle and the exit handle that part. But if the person who runs your guard also runs your exit, they see both ends.
So the laptop is picky about its guard, in two ways:
- It picks only among relays with the
Guardflag, relays the authorities have watched stay up and fast for a while. - It picks once, then keeps that guard for every circuit, for months on the live network.
The second rule sounds backwards, since changing often feels safer. With a new first hop for every circuit, sooner or later you pick one an attacker runs. With one guard, you are either safe the whole time or unlucky from the start, and most people are safe.
Ask the laptop's Tor client which guard it chose. You talk to the client through its control port: a plain text conversation on port
9051, where each answer line starts with250when all went well.laptop:~# nc 127.0.0.1 9051
- It picks only among relays with the
-
Two of three authorities are enough to keep Tor running
Every client depends on a small group of authorities, which makes each authority a target. People have attacked them before, trying to knock them offline so that no new consensus comes out. A design that stopped when one authority went down would hand attackers an off switch.
The majority rule protects against that too. The network needs signatures from more than half of the authorities, not from all of them, so it survives losing a few. With nine authorities, five signatures are enough, so four can be down at once.
You are about to break this lab on purpose. Stop the
torprogram onauth3, then read the next consensus thatauth1publishes. Last, fetch the Aarhus library's page through Tor from the laptop, to see whether clients still work.auth3:~# pkill -x tor auth1:~# grep -E "^(valid-after|dir-source|directory-signature) " /var/lib/tor/cached-consensus laptop:~# curl --socks5-hostname 127.0.0.1:9050 http://10.0.1.20/
Run these steps on real machines