10.0.0.5/8, 10.0.0.5 255.0.0.0, or just an address and use the slider. A 32-bit integer or hex value like $c0a80182 works too.| # | Network | Usable range | Broadcast |
|---|
| Name | Needs | Gets | Network | Usable range | Broadcast |
|---|
An IPv4 address looks like four numbers with dots between them, but that's just how we write it down. Underneath, it's a single 32-bit number. Each of the four parts is one byte, which is why each one runs from 0 to 255. The dots mark where one byte ends and the next one starts.
Take 192.168.1.130. Write each byte in binary and put them side by side:
192 168 1 130 11000000 10101000 00000001 10000010
Read as one number, that's 3,232,235,906, or $c0a80182 in hex. That's how the network code in your computer handles it. The dotted form is for people. The calculator above accepts the plain number too, if you want to check.
Every address is split into two parts. The left part says which network the machine is on. The right part says which machine it is on that network. It works like a street name and a house number. The post office moving a letter across the country only looks at the city and street, and the house number only matters at the very end.
Routers do the same thing. A router on the internet doesn't keep a list of every computer in the world. It keeps a list of networks, and it sends each packet toward whichever network the address belongs to. The host part only matters once the packet gets there.
Nothing in the address itself tells you where the split falls. You need one more piece of information, and that's the mask.
A subnet mask is another 32-bit number, written the same dotted way. It's always a run of 1s followed by a run of 0s. The 1s cover the network part, and the 0s cover the host part.
address 11000000.10101000.00000001.10000010 192.168.1.130 mask 11111111.11111111.11111111.11000000 255.255.255.192
To find the network, AND the address with the mask, one bit at a time. Where the mask has a 1, the address bit passes through untouched. Where the mask has a 0, the result is 0.
address 11000000.10101000.00000001.10000010 mask 11111111.11111111.11111111.11000000 ----------------------------------- network 11000000.10101000.00000001.10000000 192.168.1.128
If you've written any 6502, you've done this. and #$c0 keeps the top two bits of the accumulator and clears the other six. A subnet mask is the same trick stretched across 32 bits. For the last byte of this example, it's literally and #$c0, since 192 is $c0.
Old specs allowed masks with gaps in them, like 255.255.0.255. Nobody could reason about those, and CIDR (below) put an end to them. Today a mask with a 0 in the middle of the 1s is just an error.
Since a mask is always 1s and then 0s, you can describe it by counting the 1s. 255.255.255.192 has 26 of them, so the network gets written as 192.168.1.128/26. This is CIDR notation, short for Classless Inter-Domain Routing, and the number after the slash is the prefix length.
The prefix is easier to think with than the dotted mask. /24 means the first three bytes are network and the last byte is host. /16 is two and two. /26 is three bytes plus two more bits, which is why the boundary in the binary view above lands inside the last byte.
Before 1993, nobody wrote the split down. It was baked into the first few bits of the address. Class A addresses (first byte 0 to 127) had 8 network bits. Class B (128 to 191) had 16, and Class C (192 to 223) had 24. You got whatever size came with the class.
That wasted a lot of space. A Class C gave you 254 hosts and a Class B gave you 65,534, with nothing in between. A company with 300 machines was too big for a C, so it got a B and left 65,000 addresses sitting idle. The B's were running out fast.
CIDR (RFC 1519) threw the classes out in 1993 and let the mask land on any bit. People still say "a Class C" when they mean a /24, so it's worth knowing the term. The calculator shows the old class for reference, but it has no effect on the math.
If the prefix is p, there are 32 − p host bits. Each host bit doubles the number of addresses, so the network holds 232−p of them. A /26 has 6 host bits, and 26 is 64.
Two of those 64 are spoken for. The address with every host bit set to 0 is the network address. It names the network itself, so you don't give it to a machine. The address with every host bit set to 1 is the broadcast address, and a packet sent there goes to every machine on the network.
network 11000000.10101000.00000001.10000000 192.168.1.128 broadcast 11000000.10101000.00000001.10111111 192.168.1.191
That leaves 64 − 2 = 62 usable addresses, from .129 to .190.
There's a bitwise way to get the broadcast, too. Flip the mask to get the wildcard (0.0.0.63 here, just the host bits set), then OR it with the network address. Cisco access lists use wildcard masks, so you'll run into them.
The two smallest sizes break the minus-two rule. A /32 is a single address, used to point at one specific machine. A /31 has two addresses and no room for a network or broadcast address. RFC 3021 lets a link between exactly two routers use both, which saves half the space compared to the traditional /30.
You don't need binary for most of this. Find the byte where the mask stops being 255. Subtract that byte from 256 to get the block size. Subnets start at every multiple of the block size.
For /26, the mask ends in 192. 256 − 192 = 64, so subnets in that last byte start at 0, 64, 128, and 192. The address ends in 130, which falls between 128 and 192. So the network is .128, and the broadcast is one less than the next block, .191.
It works on any byte. A /20 has the mask 255.255.240.0. 256 − 240 = 16, so the third byte steps by 16 (0, 16, 32, 48, and on up). 172.16.37.9/20 has 37 in the third byte, which lands in the block starting at 32. The network is 172.16.32.0, and the broadcast is 172.16.47.255, the last address before the block at 48.
Say you have 10.0.0.0/24 and want four separate networks, maybe one per floor of a building. You borrow bits from the host part. Two bits give you four combinations (00, 01, 10, 11), so the prefix grows from /24 to /26:
10.0.0.00000000 = 10.0.0.0/26 10.0.0.01000000 = 10.0.0.64/26 10.0.0.10000000 = 10.0.0.128/26 10.0.0.11000000 = 10.0.0.192/26
Each bit you borrow doubles the number of subnets and cuts each one in half. The split panel above does this for whatever network you type in.
Real networks aren't all the same size. The sales floor might need 100 addresses while the link between two routers needs 2. Giving everyone the same /25 would burn through the space in no time. Variable-length subnet masking, or VLSM, just means giving each subnet the size it actually needs.
There's one rule. A subnet has to start on a multiple of its own size. A /26 (64 addresses) can start at .0, .64, .128, or .192 and nowhere else. If it started at .32, the mask would slice through the middle of it, and ANDing any of its addresses with the mask would give you a network address that isn't where the subnet starts.
The easy way to follow that rule is to hand out the biggest blocks first. Take 192.168.10.0/24 with these needs:
/25, so Sales gets 192.168.10.0/25./26, at .128/26./27, at .192/27./30, at .224/30.That leaves .228 through .255 free for later. Now try it in the other order. Put the router link at .0/30 first, and Sales can't start at .4. The next multiple of 128 is .128, so Sales takes the whole top half. Office needs 64 more addresses on a 64 boundary above that, and there aren't any left. You'd have to go back and fill in the gaps below by hand. Biggest-first avoids the mess, and it's what the planner above does.
Some ranges are set aside for special jobs. The private ranges from RFC 1918 are for use inside homes and companies, and internet routers won't carry them. Your home network almost certainly uses one, and your router swaps it for a single public address on the way out. That swap is NAT (network address translation), and it's a big part of why IPv4 hasn't completely run out.
| Range | What it's for |
|---|
172.16.0.0/12 trips people up. It runs from 172.16.0.0 all the way to 172.31.255.255, not just 172.16.x.x. Type an address into the calculator and the Type box will tell you which of these it falls in.
Same idea, bigger number. An IPv6 address is 128 bits, written as eight groups of four hex digits, and the prefix works the same way. The difference is that nobody counts hosts anymore. A normal LAN is a /64, which leaves 64 host bits, about 18 quintillion addresses on one network. There's no broadcast address in IPv6, and subnetting mostly comes down to splitting on hex-digit boundaries so the numbers stay readable.
| Prefix | Mask | Wildcard | Addresses | Usable hosts |
|---|