Practice network maths until it is automatic.
Random spanning tree topologies, subnetting and routing questions, checked instantly, with the working shown for every answer. Nothing to sign up for.
What is inside
Try the calculator
Type an address with a prefix.
How it helps
Root bridge
Which switch wins the election?
Root path cost
Total cost from each switch to the root along its best path. The root itself is 0.
Port roles
Port roles
| Role | STP | RSTP | Function | State |
|---|---|---|---|---|
| Root (RP) | Yes | Yes | Best path from a non-root switch to the Root Bridge | Forwarding |
| Designated (DP) | Yes | Yes | Best port on a network segment to forward traffic toward that segment | Forwarding |
| Alternate | No separate role | Yes | Backup path to the Root Bridge through another switch | Discarding |
| Backup | No separate role | Yes | Backup for a Designated Port on the same shared segment | Discarding |
| Disabled | Not an STP role | Not an RSTP role | Port is disabled or not participating | No forwarding |
Election rules, in order
Bridge table
Hub wiring
Subnet calculator
Type an IPv4 address with a prefix or mask. See the network, broadcast, host range and the bits behind them. Subnet info also lets you subnet the network you type, with every subnet listed in a searchable table. Use the other tab to plan VLSM.
Address in binary
Subnet this network
You can subnet right here. Choose how many subnets you need, or the new prefix length, and every subnet is listed below with its usable host range.
Select any value to copy it.
Networks and hosts needed
Each network gets the smallest block that holds its hosts plus the network and broadcast addresses. Largest networks are placed first.
Subnetting guide
From bits to VLSM, with the shortcuts you can use on paper in an exam. Every example on this page is computed live, so the numbers always match the calculator.
1. An address is 32 bits
An IPv4 address is 32 bits, written as four groups of 8 bits (octets) in decimal. Each bit in an octet is worth a power of two, from 128 on the left to 1 on the right.
| Bit value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Example 37 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
37 = 32 + 4 + 1, so its bits are 00100101. To convert, go from left to right and write 1 whenever the bit value fits into what is left.
2. The mask splits the address in two
The prefix length, like /26, says how many bits from the left are the network part. The rest are host bits. The mask writes the same thing as 1s for network bits and 0s for host bits.
3. Five numbers every subnet has
- Network address: all host bits 0. It names the subnet and is not given to a host.
- Broadcast address: all host bits 1. It reaches every host in the subnet.
- First usable host: network + 1.
- Last usable host: broadcast − 1.
- Usable hosts: 2host bits − 2.
/31 has no network or broadcast address, so both of its addresses are usable (RFC 3021, for point-to-point links). A /32 is a single host, used for loopbacks.4. The block-size shortcut
You do not need binary for most questions. Find the octet the mask cuts through, then:
- Block size = 256 − the mask value in that octet.
- Network addresses in that octet are multiples of the block size.
- The network address is the biggest multiple that is not above the host's octet.
- The broadcast address is one below the next multiple.
Worked example
5. Choosing a prefix for N hosts
Add 2 (network and broadcast), then find the smallest power of two that is at least that big. The exponent is the number of host bits. The prefix is 32 minus that.
| Host bits | Prefix | Addresses | Usable hosts |
|---|
Example: 100 hosts need 102 addresses. 26 = 64 is too small and 27 = 128 fits, so 7 host bits and a /25.
6. Splitting a network
To make more subnets, borrow host bits and add them to the prefix. Borrowing b bits gives 2b subnets, each with 232 − new prefix addresses.
7. VLSM step by step
Variable-length subnet masks let each network get the size it needs instead of one size for all. The trick is to always work with blocks: sizes that are powers of two.
- List what each network needs. Write the number of hosts for every LAN and add 2 for the network and broadcast addresses. A point-to-point link needs 2 hosts, so 4 addresses.
- Round each up to a power of two. 100 + 2 = 102 becomes 128. 50 + 2 = 52 becomes 64. The block size gives the prefix: 128 addresses means 7 host bits, so /25.
- Sort largest first. Big blocks need big alignment, so they go first.
- Allocate in order. Start at the first address of the parent network. Each next subnet starts where the previous one ended (previous network + its block size).
- Check alignment and fit. Every network address must be a multiple of its own block size, and the last block must end inside the parent network. What is left over is free for growth.
8. Special address ranges
| Range | Use |
|---|
Classes still show up in exams: A starts 0 to 127, B 128 to 191, C 192 to 223, D (multicast) 224 to 239, E (reserved) 240 to 255. Real networks use CIDR, so the class does not decide the mask.
9. Prefix cheat sheet
| Prefix | Mask | Wildcard | Block size | Addresses | Usable |
|---|
Block size is the step between network addresses in the octet the mask cuts through (or 1 for a whole-octet mask in the last octet).
10. Common mistakes
- Forgetting to subtract 2 for usable hosts, or subtracting 2 on a /31 or /32.
- Using the host's own octet as the network address instead of rounding down to a multiple of the block size.
- Mixing up the wildcard mask with the subnet mask. The wildcard is 255 minus each mask octet.
- Starting VLSM allocations at an address that is not a multiple of the block size.
- Counting from 0: the first subnet is number 1, so subnet j starts at (j − 1) × block size.
Ready to try it? Open the exercises.
Subnetting exercises
Every set is generated from a seed. Answer, check, and read the working for each question.
Answers accept 192.168.1.0, /26 or 26, and numbers with or without commas.
Route table simulator
Build a routing table from connected, static and dynamic routes, see which routes the router installs, then look up a destination to see how it picks one.
Learned routes
172.16.1.1/30. The router adds the local /32 itself.Routing table
What show ip route would print. Only the best route for each prefix is installed.
Static route commands
Look up a destination
How the router decides
- Longest prefix match. Among all routes that contain the destination, the one with the longest prefix wins. /24 beats /16, and the default route /0 is last.
- Administrative distance. If two routes have the same prefix, the lower AD is more trusted and only that route is installed.
- Metric. If AD is also equal, the lower metric wins. Equal metrics are installed together and traffic is shared.
| Route source | Code | Default AD |
|---|
Routing exercises
Static routes, administrative distance and route selection, the way the CCNA asks them. Every set comes from a seed. Answer, check, and read the working.
Write routes as 10.0.0.0/8. For commands, type the whole line, for example ip route 10.0.0.0 255.0.0.0 172.16.1.2. For protocols, the code (O) or the name (OSPF) both work.