Teaching with Marionnet
Translated from the French version, which is authoritative.
This guide follows one lab from start to finish, from its statement to the mark of each copy, and shows how to hand the repetitive part of the work to a script, or to an AI: building the network, checking that it matches the statement, then marking the copies. Technical details, which only matter in particular cases, are folded into boxes that open with a click.
Preparing a lab with Marionnet means building a project, that is, a .mar file which holds the
network of the session: its machines, its cables, its addresses, and even the disk of each machine.
The mouse is enough for this (see Getting started). However, rebuilding the
same network by hand every year, then opening thirty copies one by one to mark them, is repetitive
work, and Marionnet now lets you hand it to a script. This guide is therefore for the teacher who is
willing to write a few lines of shell, or to have an AI write them.
The guide follows a real lab throughout: session 7 (routing, filtering
and source NAT). All its files are installed with Marionnet and work as they are. The commands of
this guide are run from the directory that holds it, that is, <prefix>/share/doc/marionnet/ on a
machine where Marionnet is installed (for instance /usr/share/doc/marionnet/ after a package
installation), or doc-src/ in the sources.
Besides Marionnet, you need the tools installed along with it (mrnctl, which sends commands to
Marionnet, and mrn-verify, which checks a lab), as well as the programs socat and jq, which
these tools use. If you have never driven Marionnet from a script, first read § 1 and 2 of the
scripting guide; they take a few minutes.
1. The path of a lab, from statement to mark
| Step | What you write | What you get |
|---|---|---|
| design | the statement, and the correction key, that is, the list of what must be true in a successful copy | — |
| build | a command file, which describes the network, and a small shell script for each machine to be configured at startup | the project to hand out, a .mar file |
| check | nothing new: you install the solution in a copy of the project | the verdict of the key on a successful lab |
| session | — | each student’s copy, that is, their .mar file, with up to four documents per machine in exam mode |
| marking | nothing new: the key is already written | a verdict for each line of the key, with its reason |
Two properties of this chain are worth noting from the start. First, what you hand out is the .mar
file. A lab built by a script is therefore checked after it has been saved, closed and reopened (the
command marionnet -r lab.mar reopens a project and starts its components at once). Second, a
script can only do what the graphical interface allows. For instance, in exam mode a component that
has already run cannot be deleted by a script, any more than with the mouse. When a command is
rejected, mrnctl can <component> lists what is allowed at that moment.
2. Building the lab
The network of session 7 links a machine m1, on the LAN side, to a machine intruder, on the “outside”, through a machine r1, which the student has to configure:

The statement asks the student to configure r1 so that (a) the LAN can reach the outside, (b) nothing else crosses r1, and (c) the LAN goes out under r1’s outside address (source NAT). This configuration must also survive a restart of r1.
The network is described in a command file, lab.mrn, one command per
line, using the same commands as mrnctl: a new project, two hubs, three machines, four cables,
then the addresses of m1, of intruder and of the two cabled interfaces of r1. Start Marionnet in
driven mode (its window opens as usual, and you will watch the network being built in it), have the
file checked by mrn-check, which does not send it to Marionnet, then run it in one go:
# Start Marionnet in driven mode:
marionnet --control-socket /tmp/lab.sock &
export MARIONNET_CONTROL_SOCKET=/tmp/lab.sock
# Check the command file, then run it:
mrn-check labs/session-7/lab.mrn
mrnctl -f labs/session-7/lab.mrn
The two end hosts then receive their startup configuration, a script that the machine runs at the
end of its boot. Here, m1-scenario.sh and
intruder-scenario.sh set their machine’s default route,
then write a marker file, /mnt/hostfs/marionnet-guest-ready, saying that it is ready. This file,
and nothing else, is what mrnctl wait … --ready waits for, and Marionnet never writes it itself
(see § 4 of the scripting guide). The path given to --from must be
absolute, hence the $PWD:
# Give m1 and intruder their configuration:
mrnctl rc-set m1 \
--from=$PWD/labs/session-7/m1-scenario.sh --enable
mrnctl rc-set intruder \
--from=$PWD/labs/session-7/intruder-scenario.sh --enable
# Save the project to hand out:
mrnctl save-as /tmp/session-7.mar
The machine r1, on the other hand, gets no configuration, since configuring it is precisely the
student’s task. The file /tmp/session-7.mar is therefore the lab itself, and it is the only file
you will hand out. The script build.sh runs these commands in sequence.
Why r1 is a machine, and not a router
Marionnet’s palette offers a router component, but the image shipped for it runs Quagga (the RIP,
OSPF, BGP… routing daemons) and does not contain iptables. Session 7, however, is about netfilter,
the filtering and address translation of the Linux kernel. So r1 is an ordinary machine with three
interfaces, of which only eth0 and eth2 are cabled. In other words, the choice of component
follows from what the statement asks of the student.
3. Writing the correction key
The key of session 7, key.mrv, is the list of what must be true in a
successful copy, one assertion per line. The command mrn-verify checks it against the project open
in Marionnet and gives each line one of three verdicts: PASS if the assertion is true, FAIL if
it is false, and SKIP when Marionnet has no way of knowing (see § 9 of the scripting
guide, which also lists the forms an assertion can take).
The assertions of a key differ in what each of them relies on, and those of session 7 are of four kinds:
| Kind | Example from the key | What it proves |
|---|---|---|
| the model, that is, the network as Marionnet knows it | cable c2 r1:eth0 h1:port2 |
that the topology of the statement is intact, since a student may have moved a cable |
| the trace of the startup configuration | journal r1 rc_config ok |
that this configuration ran without error, but not that the machine is in the intended state |
| the state of the machine, read in the report it writes about itself | report r1 says ~ ip_forward *= *1 |
what the machine says about itself when asked (here, that IPv4 forwarding is on) |
| the experiment | reaches m1 intruder |
that a packet really gets through, in this case a ping from m1 to intruder: it is the only proof of connectivity |
These kinds do not carry equal weight, as the next section shows: a key made only of traces would give a good mark to a machine that no longer works. Note also that the trace concerns the startup configuration that Marionnet gives to r1, which in session 7 is the solution you install to check the lab. The student, for their part, configures r1 inside its system, that is, in its configuration files or in a service read at boot, as the statement requires. This assertion therefore checks your own lab; it does not mark a copy.
What the solution avoids writing, and why
The solution, r1-solution.sh, is written so that the key can
judge it. Two of its choices follow from this, and both were established through testing.
-
It turns forwarding on with the first of the two lines below, not with the second:
sysctl -w net.ipv4.ip_forward=1 echo 1 > /proc/sys/net/ipv4/ip_forwardThe trace of a startup configuration does not record redirections: the second form leaves only the words
echo 1in it, so an assertion looking forip_forwardin the trace would fail on a correctly configured machine. This is also why the key reads the state in the report, and not in the trace. -
It contains no
|| true. A failure absorbed on the left of||never reaches the trace, so a configuration that did nothing would pass the trace assertion of the key.
4. Trying the lab out before handing it out
Before handing the lab out, it is wise to try it out at least once, as a student who succeeded would. To do so, continue working in a copy of the project file, so that the file you hand out does not contain the solution. Then install the solution as r1’s startup configuration, start the three machines, wait until they are ready, and run the key, which must pass entirely:
# Continue in a copy of the project:
mrnctl save-as /tmp/session-7-solved.mar
# The solution, given to r1:
mrnctl rc-set r1 \
--from=$PWD/labs/session-7/r1-solution.sh --enable
# Start, then wait until each machine is ready:
mrnctl start-all
for c in m1 r1 intruder; do
mrnctl wait $c --ready --timeout=300
done
# Run the key:
mrn-verify labs/session-7/key.mrv
# 14 passed, 0 failed, 0 skipped.
Then switch r1’s forwarding off while the machine is running, and run the same key again:
mrnctl exec r1 -- sysctl -w net.ipv4.ip_forward=0
mrn-verify labs/session-7/key.mrv
# 12 passed, 2 failed, 0 skipped.
Only two assertions change their verdict, the one about r1’s state and the one about the experiment:
report r1 says ~ ip_forward *= *1
reaches m1 intruder
The trace still passes, and rightly so, since the configuration did run when r1 started. You thus
check, in one go, that the lab works and that the key tells a correct copy from one that no
longer works. The script play.sh runs these two passes on its own copy
of the project, which it builds with build.sh.
5. The session
The session itself needs no script. Each student opens their own copy of the project in Marionnet,
works in it, then hands you their .mar file. If the session is graded, the student starts
Marionnet with the --exam option: Marionnet then records what the student does on their machines
and archives it in the project, which thereby becomes their copy. The exam mode
guide describes how such an exam goes; it is run entirely from the graphical
interface.
Two points of that guide matter for marking. First, archiving happens when each machine shuts down properly, which Marionnet does when the student quits it. Second, only Debian 13 (trixie) machines write a report when they shut down; routers, and machines installed from an older image, archive their history, their console and their terminal, but no report (see § 5 of the exam mode guide). So, before the session, check that the machines of the project run Debian 13, in the Distribution field of each machine’s Modify window.
6. Marking the copies
To mark, open each copy in a Marionnet started in driven mode, but without the --exam option,
since this time you are the marker, then run the key. The script
grade.sh does this copy by copy, in two ways that answer different
questions:
# Start Marionnet in driven mode, without --exam:
marionnet --control-socket /tmp/mark.sock &
export MARIONNET_CONTROL_SOCKET=/tmp/mark.sock
# Mark what the session archived, starting nothing:
labs/session-7/grade.sh /srv/exams/dupont.mar recorded
# Restart the copy, then mark what it does:
labs/session-7/grade.sh /srv/exams/dupont.mar replay
recordedruns the keykey-recorded.mrvwith the--refresh=neveroption ofmrn-verify. No machine is started or queried, and the mark rests on the archived documents and on the last report each machine wrote. This mode is fast, so thirty or so copies can be marked in an evening; however, it can say nothing about connectivity, which only an experiment can prove.replay, the default mode, starts the machines of the copy, waits until each of them answers, then runs the full key,reachesincluded. It is slower, but it alone tells whether what the student configured actually works. Note that it judges the configuration that survives a restart, hence the last instruction of the statement: a rule typed in r1’s terminal, and never written to its disk, is gone when the copy restarts.
As the exam mode guide explains, the report and the history are written by the machine itself, in a
directory the student is allowed to write to, whereas the console and the terminal are written by
Marionnet, on the host, out of the student’s reach. A FAIL that rests only on the report is
therefore a result to cross-check, for instance against the terminal recording, rather than a
penalty. This is why key-recorded.mrv first checks that each machine’s terminal was archived.
Finally, the marking scheme is yours: mrn-verify only gives verdicts, line by line, and turning
them into a mark is up to you.
A copy without documents
A copy whose machines were not shut down properly, for instance because the student’s computer was
switched off abruptly, archives nothing, since archiving is part of the shutdown. This is why
grade.sh starts by listing the documents of the copy: an empty list means that no archiving took
place, and only marking in replay mode is then possible.
Document titles are translated
Archived documents get a title in the language of the student’s interface: a Marionnet running in
French files a report under the title Rapport sur r1, where one running in English writes Report
on r1. A key that looks for only one of the two titles will therefore find nothing in the copy of a
student who works in the other language. Write both variants, as key-recorded.mrv
does for each document it looks for:
documents r1 has ~ (Report on|Rapport sur)
The answers of mrnctl, on the other hand, are never translated.
Your own commands as a marker stay out of the copy
The commands you run in a machine with mrnctl exec while marking are recorded in a separate
journal, which is not archived in the project: they never show up in the student’s history.
7. Getting help from an AI
Everything above is written and run as commands, so it is work that an AI agent, that is, an AI able
to run commands (a command-line coding assistant, for instance), can do for you. For this, Marionnet
provides a skill, marionnet-driving-skill.md: a procedure written
for the agent, which teaches it to drive Marionnet, that is, to build a network, start it, write a
key, run it, and mark copies. Pointing the agent to it is enough, for instance:
Read
marionnet-driving-skill.mdand follow it. Then: (your lab, in your own words).
For the agent to do useful work, give it what it cannot guess:
- the network and the statement of the lab, or at least what the student has to do, in your own words;
- the images installed on the computers of your room, which the Distribution field of the Add window of a machine lists: a lab that asks for a missing image cannot run anywhere;
- what the student produces (a configuration written by hand, a script, answers on paper), which decides what the key will be able to check;
- whether the lab will be graded, and on which documents (see § 6).
Before you believe an agent that reports the lab as finished, ask it for the following four items, which the skill requires it to produce (see its § 8), and read them:
| What to ask for | Why |
|---|---|
| the counts of a full run of the key: assertions passed, failed, skipped | they show that the lab was actually run, not only written |
| the key run against a deliberately wrong lab (forwarding off, a cable missing) | a key that any copy passes marks nothing |
the list of SKIPs in a run on the correct lab |
a SKIP means that Marionnet has no way of knowing: a SKIP you did not intend is an assertion that marks nothing |
the .mar saved, closed, then reopened and run again |
it is the file you will hand out, so it must work once reopened, outside the agent’s session |
In Claude Code, the sources of Marionnet also provide this procedure as a skill named
marionnet-driving; its content is the same.
8. When it does not work
| What you see | What to do |
|---|---|
grade.sh lists no document |
the machines of the copy were not shut down properly, and no archiving took place (§ 6): only marking in replay mode is possible |
a report assertion fails on a router, or on a machine installed from an older image |
these images write no report when they shut down: in recorded mode, write no report assertion about them, and rely on the console, the terminal, or the report of the neighbouring machines |
wait … --ready is rejected with the message is “off”, not “on” |
start answers before the startup is over: the machine was not running yet, or did not start. First wait for wait <machine> --state=on, then for the marker file |
wait … --ready fails with timeout |
the machine did not write its marker file: check that its startup configuration is enabled (--enable), and read what it did with mrnctl log <machine> |
mrn-verify gives unexpected SKIPs |
Marionnet has no way of answering, for instance for a machine that is off: start it, or run the key in replay mode; the --strict option counts a SKIP as a failure |
an answer of mrnctl log carries "truncated": true |
an answer holds at most 400 lines, and --tail=<n> picks the last ones; the output of an exec is limited to 200 lines: for more, have the machine write a file |
The full list of known traps, each with its remedy, is in § 6 of the skill.
Appendix: one example per command
This appendix gives one line for each command that help lists. The lines form a single
session, to be run in order on a Marionnet started in driven mode (see § 2), since the last ones
need what the first ones created. They do not replace the help of each command, which gives its
exact syntax and is the authority:
mrnctl help <command>
The session and the vocabulary
# What this Marionnet understands, the authority:
mrnctl help
# The syntax of a single command:
mrnctl help connect
# The open project, what is running, and since when:
mrnctl status
# What the session did on its own since you last asked:
mrnctl notifications
The project
A project must exist before any component: without one, add answers no_active_project.
# A new project, at this path:
mrnctl new /tmp/teaching-demo.mar
# Save it where it is:
mrnctl save
# Save it elsewhere, and carry on there:
mrnctl save-as /tmp/teaching-copy.mar
# Close it, saving it, then reopen it:
mrnctl close --save
mrnctl open /tmp/teaching-copy.mar
Components and cables
# A machine, with its default interface:
mrnctl add machine m1
# A machine with three interfaces, eth0, eth1 and eth2:
mrnctl add machine r1 --ports=3
mrnctl add switch sw1 --ports=8
mrnctl add hub h1 --ports=4
# A cable is created by connecting its two ends:
mrnctl connect c1 m1:eth0 sw1:port1
# Every component, its kind and its state:
mrnctl ls
# … or those of one kind only:
mrnctl ls --kind=machine
# Every field of a component, or a single one:
mrnctl get m1
mrnctl get m1 memory
# One field at a time:
mrnctl set m1 memory 128
mrnctl rename h1 h2
# What m1 accepts right now:
mrnctl can m1
# A component that may be deleted right now:
mrnctl del h2
Port names differ from one component to another: eth0, eth1… for a machine, port0, port1…
for a router, and port1, port2… for a switch or a hub, which therefore count from 1. When a name
is wrong, the rejection gives the valid ones.
The four tables of the interface
These are the tabs of the graphical interface, seen from a script: same content, same column names. The Disks tab comes further down, with stopping the machines.
# The declared addresses, interface by interface:
mrnctl ifconfig m1
mrnctl ifconfig-set m1 eth0 ipv4-address 192.168.1.1/24
# The defects of a link, in each direction:
mrnctl defects m1
# 5 % loss on the way in:
mrnctl defects-set m1 eth0 inward loss 5.0
# What a session archived in the project:
mrnctl documents
ifconfig gives what was declared in Marionnet, which the machine applies when it starts,
never what the machine has configured by itself since.
The startup configuration
# What m1 will run at the end of its boot:
R=/mnt/hostfs/marionnet-guest-ready
mrnctl rc-set m1 "printf 'ready\n' > $R"
# What it will run, and whether it is enabled:
mrnctl rc-get m1
This text is run by bash inside the machine, and /mnt/hostfs is a real host directory there:
whatever the machine writes in it, the host can read without going through the network. The line
above writes the marker file that wait --ready waits for. The quotes are essential: your own shell
reads the line first, and an unquoted > would redirect the output of mrnctl itself, on the host,
instead of travelling to the machine. A configuration of several lines is better given in a file
(--from=<absolute path>, see § 2).
Starting, and waiting for what actually happened
# start only requests the startup:
mrnctl start m1
# The machine's process is running:
mrnctl wait m1 --state=on --timeout=120
# The machine has written its marker file:
mrnctl wait m1 --ready --timeout=300
mrnctl start-all
mrnctl wait-all --state=on --timeout=300
--state=on says that a process exists; --ready says that the machine has written the marker
file its configuration was meant to write, which implies that its whole boot has taken place.
Observing a running machine
# What its startup configuration did:
mrnctl log m1
# Another of its journals, its last five lines:
mrnctl log m1 boot --tail=5
# Run a command INSIDE the machine:
mrnctl exec m1 -- uname -r
# A fresh report on the state of the machine:
mrnctl report m1 --timeout=180
# What a switch knows right now:
mrnctl switch-info sw1
# … one of its tables only:
mrnctl switch-info sw1 macs
These four commands do not tell the same thing: log serves traces (what was run), report a
state (what the machine is now), switch-info the state of a switch, and exec is the only one
that acts. A trace does not record redirections, and a report describes a state, never whether
something can be reached: only an experiment, a ping run with exec or a reaches assertion in a
key, proves that something gets through.
Suspending, resuming, restarting
mrnctl suspend m1
mrnctl resume m1
# A proper shutdown, followed by a start:
mrnctl restart m1
mrnctl wait m1 --state=off
mrnctl wait m1 --state=on --timeout=180
Stopping, and the states a machine leaves behind
# The proper shutdown, which archives in exam mode:
mrnctl stop m1
mrnctl wait m1 --state=off --timeout=180
# The saved states of m1 (Disks tab):
mrnctl history m1
# The name of a state is generated: read it.
Q='.rows[0].children[0].fields."File name"'
COW=$(mrnctl -q "$Q" history m1)
mrnctl history-set "$COW" comment before the firewall
# Export it as a variant (--force replaces
# a variant of the same name):
mrnctl history-export "$COW" teaching-demo --force
# Restart the machine from that state:
mrnctl history-start "$COW"
mrnctl wait m1 --state=on --timeout=180
# Forget a saved state:
mrnctl history-del "$COW"
history-export does what the Export as machine variant entry of the Disks tab does: it
copies the chosen state, under the given name, into your directory of variants, and the machine
must be off. The copy is sparse, that is, it only takes up on disk what has changed (less than
6 MB measured for a 5 GB state). For a Debian 13 machine, this directory is for instance:
~/.marionnet/filesystems/machine-debian-trixie-16341_variants/
Leaving
# The power cut: no shutdown, nothing archived:
mrnctl poweroff m1
# Every running component, properly:
mrnctl shutdown-all
mrnctl poweroff-all
# Wait until they are all off, then save:
mrnctl wait-all --state=off --timeout=180
mrnctl save
# Close Marionnet itself:
mrnctl quit
stop and poweroff are not two ways of doing the same thing: in exam mode, the four documents
of a machine are archived by its proper shutdown, whereas a power cut leaves nothing behind.
How this appendix stays accurate
These lines are not copied from help: a test bench runs them, in order, against a running
Marionnet, and checks that every command help lists has its example here, and that no example uses
an unknown command. A command added to Marionnet therefore makes this bench fail until it has its
example here, and a renamed option makes the line that uses it fail.
