This project has been created as part of the 42 curriculum by masad.
NetPractice is a hands-on introduction to IPv4 networking. The training interface presents small, simulated network diagrams — hosts, switches, routers, and "the Internet" — with some configuration fields locked and others blank or wrong. The goal of each of the 10 levels is to fill in those fields (IP addresses, subnet masks, default gateways, static routes) so that every device on the diagram can actually reach the ones it's supposed to. Nothing here touches a real network; it's a pure addressing/routing logic exercise.
An IPv4 address is a 32-bit number, normally written as four decimal bytes (e.g. 104.198.227.124). Every address is really made of two parts: a network portion, which identifies which subnet the device sits on, and a host portion, which identifies the device itself within that subnet. You can't tell where one part ends and the other begins just by looking at the address — you need the subnet mask.
A subnet mask is also a 32-bit value, but instead of identifying a device, it tells you how the address above is split. In the mask, a bit set to 1 means "this bit belongs to the network," and a bit set to 0 means "this bit belongs to the host." A mask like 255.255.255.128 in binary is:
11111111.11111111.11111111.10000000
That's 25 network bits and 7 host bits — which is exactly why it's also written in CIDR shorthand as /25. level3.json in this repo uses that mask: host C1 sits at 104.198.227.126/25, and everything else attached to the same subnet (A1, B1, connected through switch S1) has to share that same network portion, differing only in the last 7 bits.
To find the network address, you AND the IP address with the mask (i.e. keep the network bits, zero out the host bits):
IP address | 01101000.11000110.11100011.01111100
Mask | 11111111.11111111.11111111.10000000
─────────────────────── AND ────────
Network | 01101000.11000110.11100011.00000000 → 104.198.227.0
The range of valid host addresses is everything the host bits can express — except the all-zero and all-one combinations, which are reserved:
- All host bits = 0 → the network address itself, not assignable to a device.
- All host bits = 1 → the broadcast address, used to reach every host on that subnet at once.
Everything in between is a usable host address, and it has to be unique within that subnet.
A switch (like S1 in level3.json) just connects multiple devices onto the same subnet. It doesn't route between different networks and it doesn't need an IP configuration of its own for that — it's a Layer 2 device, forwarding traffic locally.
A router connects different subnets together, and has one interface per subnet it touches — level4.json and later levels use R1, R2, R3 this way. Each router interface needs its own IP address inside the subnet it faces, with a mask that matches the devices on that side. Critically, the address ranges on a router's different interfaces must not overlap — if they did, the router couldn't tell which side a given address belongs to. This becomes the central puzzle from level 7 onward, where multiple point-to-point links between routers (each typically a tiny /30 subnet, since only 2 usable addresses are needed) all have to be carved out of a shared address space without colliding.
A host that isn't directly connected to the subnet it wants to reach sends the traffic to its default gateway — the IP of the router interface on its own subnet that knows how to forward it onward. In level5.json, host A's route (Ar1) is 0.0.0.0/0 → 17.151.135.126: that gateway address is R1's interface IP on A's own subnet, not some address further away.
A route entry has two parts: a destination network and a gateway (next hop) to send matching traffic to. 0.0.0.0/0 (sometimes written default) is the special "match anything" route — it's used when a device only has one way out and doesn't need to distinguish between destinations, which is why it shows up constantly on hosts and edge routers throughout these levels (level5.json, level6.json, level7.json, level8.json, level9.json all use it). More specific routes (e.g. Ir1's 71.115.155.227/26 in level6.json) are used when a device needs to send certain traffic down a particular path instead of just defaulting everywhere.
Several levels connect a subnet out to a node called "Somewhere on the Net" or "I1" (Internet), which behaves like just another router as far as routing logic goes: it needs a route back into the local network, and the local network needs a default route out to it. The one addressing rule that comes with this: an interface facing the public Internet can't sit in a private address range — those ranges are reserved for internal networks only, so any address here is assumed to be routable/public unless the puzzle says otherwise:
| Range | Size |
|---|---|
10.0.0.0/8 |
16,777,216 addresses |
172.16.0.0/12 |
1,048,576 addresses |
192.168.0.0/16 |
65,536 addresses |
The later levels (level7.json through level10.json) chain several routers together, each hop being its own small subnet. The recurring skill is: pick (or verify) a mask small enough to give each link its own non-overlapping slice of address space, make sure every interface on a given link shares the same network address under that mask, and make sure every host's default route actually points at the router interface sitting on its own subnet — not at a router interface on the far side of a link it can't directly reach.
Run ./run.sh (or python3 -m http.server <port> and open it in a browser) to launch the training interface, solve a level, then use Get my config to export it before moving to the next one. Ten exported configs — level1.json through level10.json — belong at the root of this repository, one per level.
Concepts studied: TCP/IP addressing, subnet masks and CIDR notation, network/broadcast addresses, default gateways, static and default routes, routers vs. switches, private vs. public address space, and the Layer 2 / Layer 3 split of the OSI model that separates local switching from inter-network routing.
AI usage: AI was used to explain networking concepts, and find resources to study from.
References:
- RFC 791 — Internet Protocol — the original IPv4 specification: addressing, header format, fragmentation.
- Default Gateway — PowerCert Animated Videos — short animated explainer on what a default gateway is and why hosts need one.
- IP Addresses & Subnetting explained — walkthrough of IP addressing basics and why subnet masks exist.
- What is a Subnet Mask? — NetworkChuck — subnet masks and CIDR notation explained with worked examples.
- Subnetting basics — Cisco Networking Academy — reference material on subnetting, routing, and the OSI model.