✅ Status: Completed (10/10 levels exported)
🏫 School: 42 – NetPractice
🏅 Score: 100/100
A hands-on networking sandbox: subnetting, gateways, and routing — with instant feedback.
-
- Subnetting from Bits (Calculator‑friendly)
- CIDR → Mask (the bit view)
- Mask → CIDR (fast)
- “Step / Block size”
- Why network boundary IPs appear in routes
- IP AND MASK = NETWORK
- Network / Broadcast: quick boundary rules
- Fast host validity checklist
- CIDR → Mask (Fast Table)
- Block Size Method (Fastest Way)
- Network / Broadcast / Host Range
- Common CIDR Patterns in NetPractice
NetPractice is an interactive networking project where you fix 10 broken network topologies by configuring:
- IPv4 addresses
- Subnet masks (CIDR)
- Default gateways
- Router routes (static routing)
Each level provides goals and a live packet simulation log, so you can validate your changes instantly.
By the end, you’ll be comfortable with:
- ✅ Understanding subnets and CIDR (
/24,/26,/30, …) - ✅ Calculating network address, broadcast, and host ranges
- ✅ Recognizing what belongs to Layer 2 vs Layer 3
- ✅ Setting correct default gateways
- ✅ Adding static routes to reach non-direct networks
- ✅ Reading logs and reasoning about where packets break
- Extract the NetPractice archive.
- Open
index.htmlin a browser (Chrome/Chromium recommended). - Solve levels 1 → 10.
- For each level, click Get my config and export your file.
- Put all 10 exported files into the root of this repository.
- Switch (L2): forwards frames inside a LAN. No routing logic.
- Router (L3): forwards packets between networks. Chooses next hop by routing table.
A router interface belongs to exactly one subnet.
So whenever you see a link from R1 to a host/switch segment:
- the router interface IP must be inside that segment’s subnet
- hosts in that segment must also be inside that subnet
Two devices can communicate directly only if:
- their IPs are in the same subnet (based on the mask)
- and the link is physically connected
If not, you need a router (gateway) in between.
When you only have a basic calculator, think in bits → bytes → decimals.
A CIDR /n means: n network bits, then the rest are host bits.
-
Split
ninto full octets + remainder:full = n / 8rem = n % 8
-
The first
fulloctets are255. -
The next octet is built from the first
rembits set to 1.
Remainder → octet value table:
| rem bits | binary | value |
|---|---|---|
| 0 | 00000000 | 0 |
| 1 | 10000000 | 128 |
| 2 | 11000000 | 192 |
| 3 | 11100000 | 224 |
| 4 | 11110000 | 240 |
| 5 | 11111000 | 248 |
| 6 | 11111100 | 252 |
| 7 | 11111110 | 254 |
| 8 | 11111111 | 255 |
Example: /26
26 = 3×8 + 2→255.255.255.(192)→ 255.255.255.192
- Count
255octets: each255= 8 bits - Then add bits from the table above for the first non‑255 octet
Example: 255.255.255.224
- three
255→ 24 bits 224corresponds torem=3→ total /27
If subnetting happens inside an octet, compute:
block = 256 − mask_octet
Then subnet starts in that octet are:
0, block, 2×block, 3×block, ...
This is the fastest method you and I used across levels.
Example: /26 → last octet mask is 192 → block = 64 → starts: 0, 64, 128, 192.
A route destination is a network, not a host.
So writing 129.128.239.128/25 is valid even if no device has .128.
It simply means “the subnet that starts at .128”.
This is the bit-level truth behind everything.
-
Convert IP and mask to binary (mentally you usually only need the changing octet).
-
Apply AND:
1 AND 1 = 11 AND 0 = 00 AND 1 = 00 AND 0 = 0
Example: 192.168.10.130/26
- changing octet:
130 /26→ mask last octet =192
Binary:
130=10000010192=11000000
AND:
1000001011000000=10000000=128
So the network is 192.168.10.128.
Why we still use “block size”: it’s the same idea, just faster than doing AND every time.
Once you know the block size and subnet start:
- Network = subnet start
- Broadcast = next subnet start − 1
- Valid hosts = between them (excluding both ends)
Example: ...128/26
- next subnet start is
...192 - broadcast is
...191 - hosts:
...129 → ...190
Before you even look at routing, verify:
- ✅ IP is inside the subnet range
- ✅ IP is not the network address
- ✅ IP is not the broadcast address
- ✅ Gateway (if needed) is in the same subnet
| CIDR | Mask | Hosts (usable) | Typical use |
|---|---|---|---|
| /24 | 255.255.255.0 | 254 | classic LAN |
| /25 | 255.255.255.128 | 126 | split /24 in 2 |
| /26 | 255.255.255.192 | 62 | split /24 in 4 |
| /27 | 255.255.255.224 | 30 | small LAN |
| /28 | 255.255.255.240 | 14 | very small LAN |
| /29 | 255.255.255.248 | 6 | tiny LAN |
| /30 | 255.255.255.252 | 2 | point-to-point link |
Quick host count formula: usable hosts = 2^(32−CIDR) − 2
When the mask breaks inside an octet, compute block size:
block = 256 − mask_octet
Examples:
/26→ mask255.255.255.192→ block256 − 192 = 64/27→ mask255.255.255.224→ block256 − 224 = 32/30→ mask255.255.255.252→ block256 − 252 = 4
This block is the step between subnet starts in the changing octet.
If your changing octet is, say, the last one:
- subnet starts at:
0, block, 2×block, 3×block, ... - Network = nearest subnet start ≤ IP
- Broadcast = next subnet start − 1
- Host range =
(network + 1) ... (broadcast − 1)
/26→ block size64→ subnet starts:0, 64, 128, 192130is inside128–191- Network:
192.168.10.128 - Broadcast:
192.168.10.191 - Hosts:
192.168.10.129 – 192.168.10.190
-
Block size
4in last octet -
Each subnet has exactly:
network- 2 usable IPs
broadcast
Example subnet: 10.0.0.8/30
- network:
10.0.0.8 - usable:
10.0.0.9and10.0.0.10 - broadcast:
10.0.0.11
Typical /30 mistakes
- ❌ Using
networkorbroadcastas an interface IP - ❌ Trying to place 3+ devices into a /30 (it only supports 2 usable IPs)
- ❌ Setting next-hop to an IP that is not one of the two usable addresses
-
One
/24becomes 4 subnets:.0/26,.64/26,.128/26,.192/26
This is exactly why you often see addresses like .128 or .192: they are subnet boundaries, not necessarily host IPs.
This is one of the fastest ways to sanity-check your configs.
-
Host bits:
h = 32 − n -
Total addresses in the subnet:
2^h -
Usable hosts (classic subnet):
2^h − 2- one is the network address (all host bits = 0)
- one is the broadcast address (all host bits = 1)
Quick examples:
| CIDR | Host bits h |
Total addresses | Usable hosts |
|---|---|---|---|
| /24 | 8 | 256 | 254 |
| /26 | 6 | 64 | 62 |
| /30 | 2 | 4 | 2 |
Note: Some real-world networks use
/31for point-to-point (RFC 3021) and/32for a single host route. In NetPractice you’ll mostly see the classic “usable = total − 2” rule.
- Each
255means that octet has 0 host bits (it’s fully network bits). - The first non-255 octet tells you the block size and the number of addresses per subnet.
Examples:
-
255.255.255.0is/24- host bits = 8 → total 256 → usable 254
-
255.255.255.252is/30- host bits = 2 → total 4 → usable 2
A /30 has 4 addresses:
network(…0)host(…1)host(…2)broadcast(…3)
That’s why it’s perfect for router-to-router links: one IP per router interface.
These ranges are not “normal public internet” addresses.
10.0.0.0/8172.16.0.0/12(172.16.0.0 → 172.31.255.255)192.168.0.0/16
NetPractice may warn you with messages like “private subnets not routed over internet” if you try to send these through an “Internet cloud”.
169.254.0.0/16
Used when a host can’t get DHCP; traffic stays on the local link (not routed).
127.0.0.0/8(commonly127.0.0.1)
100.64.0.0/10
Not public end-user space; used by ISPs for large-scale NAT.
224.0.0.0/4(224.0.0.0 → 239.255.255.255)
255.255.255.255— limited broadcast0.0.0.0— “unspecified / default route” (you’ll see0.0.0.0/0as the default route)
In NetPractice, the big takeaway is simple:
- Use private ranges for internal LAN segments unless the level forces public-looking IPs.
- Don’t treat special ranges (loopback, link-local, multicast) as normal host LAN addressing.
A host sends traffic like this:
- If destination is in same subnet → send directly.
- Otherwise → send to default gateway.
✅ The default gateway must be:
- in the same subnet as the host
- the IP of the router interface connected to that LAN
A router knows only:
- networks directly connected to its interfaces
- routes you explicitly add (static routes)
- (no dynamic routing in NetPractice)
A static route conceptually says:
“To reach DEST/MASK, forward to NEXT_HOP.”
✅ NEXT_HOP must be:
- reachable via one of the router’s directly-connected networks
Routers choose the most specific matching route:
/24is more specific than/16/26is more specific than/24
So if both exist:
10.0.0.0/8and10.42.0.0/16
Traffic to 10.42.5.10 will use 10.42.0.0/16.
Sometimes one route can cover multiple subnets. Typical NetPractice trick:
- combine multiple contiguous subnets into a bigger prefix
Example:
192.168.10.128/26and192.168.10.192/26- can be summarized as
192.168.10.128/25
That’s why you might write a network boundary address (like .128) even if no device has exactly that IP — it represents the subnet itself.
Use this every time:
-
Read goals first (what exact connectivity is required).
-
Pick one goal pair (A → B) and trace the path.
-
For every link segment:
- ensure endpoints are in the same subnet
-
For every host:
- ensure IP/mask valid
- if talking outside subnet → default gateway set and reachable
-
For every router:
- interfaces must be in correct subnets
- add routes for remote networks
-
Re-run Check again and read logs.
Pro tip: fix one direction first (A→B), then check reverse (B→A).
You can often solve a level just by reading the log like a story.
-
"destination does not match any interface"
- The device is a host and the destination isn’t in its subnet → it will try the routing table.
- If it then uses
0.0.0.0/0, your default route/gateway is in play.
-
"route match 0.0.0.0/0"
- No more specific route existed → device used default route.
- If it fails afterward, your gateway is wrong / unreachable.
-
"send to gateway X through interface Y"
- Device decided to forward to next-hop
Xusing interfaceY. - If
Xis not in the same subnet asY, it can’t ARP / can’t deliver.
- Device decided to forward to next-hop
-
"packet not for me" (on router)
- Router received it, checked destination, and will forward based on routes.
-
"loop detected"
- The packet bounced back to a device it already visited.
In NetPractice logs you may see sequences like:
on switch S: pass to all connectionson switch S test link to Aon A: loop detected
This can happen because the simulator floods / tests links on a switch-like device, and a packet may appear to come back to a node that already saw it.
✅ If you still see "destination IP reached" and all goals are valid, this “loop detected” is often a simulator artifact rather than a real network loop.
Still, treat it as a quick signal to double-check:
- host gateways are in the same subnet
- return routes exist on routers
- default routes don’t point to each other
Think of a packet like this:
If a device doesn’t know the exact path, it sends to its default route. If two devices “default” to each other (or a router sends back where it came from), the packet will ping‑pong → loop.
- Wrong host gateway
- Host
Awants to reach remote network. Auses gatewayG, butGis not the router interface for that LAN (or not even reachable).- The frame gets flooded / bounced, and the simulator detects a loop.
✅ Fix:
- Gateway must be the router interface IP on the same LAN as the host.
- Missing route on a router (return path problem)
- Forward direction works (A → B), because router knows where B is.
- Reverse direction fails (B → A), because some router in the path has no route back.
- Packet goes to default route and comes back → loop.
✅ Fix:
- Always validate both directions.
- Add the missing static route(s) so every router knows how to reach the source subnet.
- Two routers defaulting to each other
- Router
R1has default route →R2 - Router
R2has default route →R1 - Any unknown destination causes infinite ping‑pong.
✅ Fix:
- Avoid mutual default routes.
- Add specific routes (more specific prefix) or make only one side default to the other, and the other side has explicit routes.
- ✅ Is the gateway on each host in the same subnet?
- ✅ Does each router have a route to the destination subnet?
- ✅ Does each router have a route back to the source subnet? (return path!)
- ✅ Are any two routers pointing
0.0.0.0/0at each other? - ✅ Is any next-hop IP reachable via a directly connected subnet?
Pro tip: if logs show a device twice in the path (A → … → A), the loop is usually between the last two hops before it repeats.
-
"private subnets not routed over internet"
- You are trying to route RFC1918 private ranges (e.g.
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16) “through the internet cloud”. - Fix: keep private traffic inside your controlled routers or use the public addressing in the exercise.
- You are trying to route RFC1918 private ranges (e.g.
- ❌ Gateway is set but not in the same subnet as the host
- ❌ Router route points to a next hop that is not reachable
- ❌ Two devices look “close” but are in different subnets due to mask
- ❌ Using a broadcast or network address as a host IP
- ❌ Forgetting that
/30has only 2 usable IPs
Logs usually tell you exactly where the packet died:
- accepted / not for me
- destination does not match any interface
- route match
0.0.0.0/0(default route) - loop detected
When you see loop detected:
- you probably have a wrong gateway or missing route causing packets to bounce.
This repository contains:
- 10 exported config files (one per level) in the repository root
README.md
Double-check exported filenames before pushing.
.
├── README.md
├── level1.*
├── level2.*
├── level3.*
├── level4.*
├── level5.*
├── level6.*
├── level7.*
├── level8.*
├── level9.*
└── level10.*
(Extensions depend on your export format.)
- RFC 791 — IPv4
- RFC 4632 — CIDR
- “Subnetting” basics (any networking textbook)
- OSI vs TCP/IP model overviews
Optional tools for practice (outside defense):
- any subnet calculator website (just for training, not for evaluation)
- Expect to solve random levels during defense.
- External tools are generally not allowed; a simple calculator like
bcmay be allowed. - Practice mental subnetting:
/26,/27,/30should become instant.
If you want, I can also add a mini “level cookbook” section with typical patterns you’ll see (e.g., “2 LANs + 1 router”, “3 routers chain”, “summarize /26 blocks into /25”), based on your exported solutions — you can paste screenshots or describe a couple of your hardest levels.