Every device on a network needs an address. That part isn’t controversial. The part that trips up most people is the format: 192.168.1.42. Why four numbers? Why dots? Why does the third one matter and the fourth one feel like the “identity” of the device? And what on earth is a /24?
This is lesson 2 of Networking from Scratch. In lesson 1 we walked through the eight stages of loading a webpage. One of those stages was “your computer figures out the IP address of the server.” This article is everything you need to know about what an IPv4 address actually is — without the panic. We’ll save the heavy subnetting math for the next article and just build the mental model here.
An IPv4 address is just one big number
Forget the dots for a second. An IPv4 address is a single 32-bit number. That’s it. 32 ones-and-zeros in a row.
11000000 10101000 00000001 00101010
Humans don’t read binary well, so we break the 32 bits into four 8-bit chunks called octets. Each octet is between 0 and 255 in decimal (which is the largest number you can make with 8 bits). We write the four octets in decimal and separate them with dots:
11000000.10101000.00000001.00101010
192 . 168 . 1 . 42
So 192.168.1.42 is genuinely just the decimal-with-dots presentation of those 32 bits. The dots are punctuation for humans — they don’t mean anything special to the computer. This is called dotted decimal notation, and you’ll see it everywhere from now on.
Because each octet is 0–255, the whole IPv4 space contains 2^32 = 4,294,967,296 possible addresses. That sounded like a lot in 1981 when the spec was written. It is famously not enough today — which is why we’ll get to IPv6 in a few articles, and why we have NAT (Network Address Translation) doing heroic work in the meantime.
Two parts in one number: network and host
Here’s the idea that makes everything else click. An IPv4 address isn’t just an identifier — it’s actually two identifiers crammed into the same 32 bits:
- The network portion says which network the device is on.
- The host portion says which specific device on that network.
Think of it like an apartment address: 123 Main Street, Apartment 42. The street address tells the postal service which building to go to; the apartment number tells the building’s mailroom which door to slide it under. The IP address is the same thing — first the network, then the host within that network — but they’re packed into one string of digits instead of having a clear delimiter.
The thing that splits the address into network-portion and host-portion isn’t in the address itself. It’s a separate value called the subnet mask, or equivalently the prefix length. We write it next to the address.
The subnet mask, in two equivalent forms
You’ll see two ways of writing the same thing:
| Form | Example | What it means |
|---|---|---|
| Subnet mask (decimal) | 255.255.255.0 |
The first 24 bits are network, the rest are host. |
| CIDR / prefix length | /24 |
Same thing, shorter. |
The trick is to look at the binary form. 255 in binary is 11111111 — eight ones. So 255.255.255.0 is:
11111111 11111111 11111111 00000000
<-- 24 ones --> <-- 8 zeros -->
The ones mark which bits of the IP address belong to the network portion, and the zeros mark which bits belong to the host portion. That’s the entire job of a subnet mask.
The CIDR notation just counts the ones. /24 means “there are 24 ones in the mask, so the first 24 bits are network.” 192.168.1.42/24 says: this address, on a network where the first 24 bits define which network we’re on.
You’ll occasionally still see masks written in the long form (255.255.255.0), especially in older Windows network dialogs. CIDR (/24) is the modern shorthand and is what every engineer says out loud. They are exactly the same information.
Common prefix lengths and what they look like
| Prefix | Subnet mask | Total addresses | Usable hosts | Where you’ll see it |
|---|---|---|---|---|
/8 |
255.0.0.0 |
16,777,216 | 16,777,214 | Huge ISP allocations, old “Class A” networks |
/16 |
255.255.0.0 |
65,536 | 65,534 | Big organisations, old “Class B” networks |
/24 |
255.255.255.0 |
256 | 254 | Most home networks, small office subnets |
/30 |
255.255.255.252 |
4 | 2 | Point-to-point links between routers |
/32 |
255.255.255.255 |
1 | 1 | A single specific host |
Why are usable hosts always two less than the total? Two addresses in every subnet are reserved:
- The network address (all host bits zero) — identifies the network itself.
- The broadcast address (all host bits one) — means “everyone on this network.”
For a /24 like 192.168.1.0/24:
192.168.1.0— the network address. Don’t assign to a host.192.168.1.1through192.168.1.254— the 254 usable host addresses.192.168.1.255— the broadcast address. Don’t assign to a host either.
One subnet, 254 useable hosts. That’s a typical home or small office network in a single line.
How a computer uses this
When your computer is about to send a packet to 203.0.113.42, it does one calculation: it ANDs the destination address against its own subnet mask, ANDs its own address against the same mask, and compares the two results.
- If the masked destination matches its own masked address, the destination is on the same network — deliver locally (with ARP, which we’ll cover in a later article).
- If they don’t match, the destination is somewhere else — send the packet to the default gateway.
That’s the entire decision a host makes for every packet it sends. The subnet mask is the single thing that lets a computer tell “is the destination my neighbour, or somewhere on the wider internet?”
Special IPv4 ranges worth recognising on sight
Some address blocks have specific meanings. You’ll see these in the wild constantly — recognising them at a glance saves real time when troubleshooting.
| Range | What it’s for |
|---|---|
10.0.0.0/8 |
Private. Anyone can use it on their internal network. Big organisations love this range because it’s huge. |
172.16.0.0/12 |
Private. Spans 172.16.0.0 to 172.31.255.255. Common in corporate VPNs and some cloud defaults. |
192.168.0.0/16 |
Private. The classic home-router range. 192.168.0.0/24 and 192.168.1.0/24 are the defaults on most consumer gear. |
127.0.0.0/8 |
Loopback. Always points at the local machine. 127.0.0.1 is “me, this computer.” |
169.254.0.0/16 |
Link-local. What you see when DHCP fails — a self-assigned address that only works on the local segment. If you see one of these on your machine, DHCP isn’t working. |
0.0.0.0 |
“Any address” or “unspecified.” You’ll see it as the default route (0.0.0.0/0) and as a placeholder when a service binds to all interfaces. |
255.255.255.255 |
Limited broadcast. “Everyone on this physical network.” DHCP discovery uses it. |
224.0.0.0/4 |
Multicast. Used by routing protocols, mDNS / Bonjour, streaming, and a few legacy applications. |
The three private ranges (10/8, 172.16/12, 192.168/16) are defined in RFC 1918. Anything outside those ranges (and outside the other reserved ranges) is publicly routable — it can appear as a source or destination on the internet at large.
A worked example you can actually picture
Imagine a small office on 192.168.10.0/24:
| Device | Address | Notes |
|---|---|---|
| Router (default gateway) | 192.168.10.1 |
Conventional, but not required — the gateway can be any usable address. |
| File server | 192.168.10.10 |
Static. |
| Printer | 192.168.10.20 |
Static. |
| DHCP pool start | 192.168.10.100 |
Laptops and phones get addresses from here. |
| DHCP pool end | 192.168.10.200 |
101 dynamic addresses available at any time. |
The router’s job, very loosely, is to be the bridge between this private world (everything in 192.168.10.0/24) and the wider internet. Devices inside this subnet talk to each other directly; anything bound elsewhere goes through 192.168.10.1. That’s why home and office networks all look the same regardless of brand — everyone implements the same model.
Things that confuse people, sorted out
- The subnet mask is not part of the address. It’s a separate value the OS stores alongside the address.
192.168.1.42/24and192.168.1.42/16are the same machine on two completely different networks. - The dots are not boundaries. A
/22mask cuts across the third octet — the network portion is 22 bits, which means the first 16 bits and 6 of the next 8 bits are network. We’ll work through that in the next article. - Two devices on the same physical wire can be on different IP networks. The wire doesn’t care. The hosts will only talk to each other through a router, even if they’re plugged into the same switch.
- And two devices on different physical wires can be on the same IP network if a switch (or VLAN) ties them together at layer 2.
- An IP address is not a MAC address. The MAC is burned into the network adapter; the IP is configured (statically or by DHCP). MAC addresses identify the hardware on a physical segment; IP addresses identify the host on a logical network. Both exist for different reasons. We’ll spend more time on this when we get to ARP.
Quick check: can you read these?
Test yourself before moving on. For each address-and-prefix pair, what’s the network portion and what’s the host portion?
| Address | Network portion | Host portion |
|---|---|---|
10.42.0.7/8 |
10. |
42.0.7 |
172.20.5.99/16 |
172.20. |
5.99 |
192.168.50.1/24 |
192.168.50. |
1 |
198.51.100.7/30 |
198.51.100.4 (the first 30 bits) |
3 (just 2 bits) |
If the first three rows feel intuitive, you’ve got the picture — the prefix is on an octet boundary so the split is visible by eye. The fourth row is the case that makes people uncomfortable, because /30 doesn’t land on a dot. That’s exactly what we’ll tackle in the next article.
What’s next
You now have the mental model: an IPv4 address is 32 bits, written in four octets, paired with a subnet mask that says how many of those bits are the network portion. The first reserved address in any subnet is the network ID, the last is the broadcast, and the rest are usable hosts. Private ranges (10/8, 172.16/12, 192.168/16) are for internal use; everything else is publicly routable.
Next article: Subnetting math: the cheat sheet that finally sticks. We’ll work through how to take an arbitrary /N and figure out the network ID, the broadcast, the usable range, and the next subnet — for any prefix length, including the awkward ones that don’t land on a dot.