Every machine on a network needs an address, and on the internet that address is four numbers separated by dots. This lesson reads one of those addresses from scratch: what each number means, what the address actually identifies, and why 4.3 billion of them ran out.
Difficulty: Beginner · Know this first: F12 — Networks: Two Computers Talking
One address on the screen: 192.168.1.1. Four numbers, three dots. This lesson reads it like a sentence.
An IPv4 address is 32 bits, and the four octets split them evenly. The bar below is exact, not an estimate: each octet is 8 bits, and the four together are 32. There is nothing hidden in this bar. That is the point. The whole address fits in four equal pieces.
Extra diagram · from scratch to master
Start with four numbers. Break each one into bits until the whole address is visible, then read it back as a single number.
Extra diagram · from scratch to master
Four well-known addresses. Each one tells a different story about what an address can name.
The simulator below reads any IPv4 address you type. Give it four numbers and it shows the 32-bit binary, the single decimal number, and what kind of address it is. Every value is computed live, and every value is exact. Try 192.168.1.1, then 8.8.8.8, then 127.0.0.1.
Each octet is 8 bits, from 0 to 255. The first octet is the most significant: it changes slowest.
The fourth octet is the least significant: it changes fastest, and it usually names the machine on its network.
Try this: (1) Set all four to 192, 168, 1, 1. The decimal value is 3,232,235,777 and the kind is private. (2) Set them to 8, 8, 8, 8. The value is 134,744,072 and the kind is public. (3) Set them to 127, 0, 0, 1. The value is 2,130,706,433 and the kind is loopback. Same four sliders, three different stories.
Three questions. No score is saved anywhere — this is just you against the material.
I take the same idea four times here. First I read one address. Then I sort addresses into kinds. Then I plan addressing for a network. Last I run it for the world.
Definition: An IPv4 address is four numbers from 0 to 255, separated by dots. Each number is an octet, 8 bits. Four octets make 32 bits, and 32 bits give 4,294,967,296 possible addresses.
Types:
Uses: I use this reading every time I see an address in a log. The first octet tells me a lot: 10, 172, or 192.168 means private. 127 means loopback. Anything else is usually public.
Dimensions: At this size one address is one line to read. What breaks first is my assumption that an address names a person, and I notice it when a laptop gets a new address and I think it is a new machine. It costs nothing to read an address. It costs real confusion to read it wrong. The trade is simple: four numbers are easy to read, and easy to misread too.
Definition: At this level I sort every address into a kind: public, private, loopback, link-local, or reserved. The kind tells me where the address works and where it does not. A private address works inside a network and nowhere else. A loopback address never leaves the machine.
Types:
Uses: I use this when a service cannot be reached. The first question is always the kind: is this a private address I am trying to reach from outside, or a public address that should work from anywhere?
Dimensions: As the network grows, the kinds multiply in the logs, and the sorting has to be automatic. What breaks is a private address leaking into a public log, and I notice it when a user pastes it into a ticket and wonders why nobody can reach it. It costs a habit: check the kind before you share an address. The trade is that kinds make debugging fast, and they cost the discipline to learn the ranges.
Definition: At this level I plan which addresses a network uses, and I write it down. The office gets one range, the lab gets another, the printers get their own corner. Servers get fixed addresses. Laptops get addresses handed out automatically. Nothing is improvised, because improvised addressing is how conflicts happen.
Types:
Uses: I use this when a new network is built or an old one is cleaned up. The plan fits on one page, and it saves hours of debugging later, because every address on the network can be explained in one line.
Dimensions: At ten times the machines the plan matters more than the addresses. What breaks is an undocumented range someone borrowed for a test and never gave back, and I notice it when a new machine takes an address that already belongs to a server. It costs a page of documentation and the habit of updating it. The trade is that documentation is boring to write, and it is the only thing that stops addressing from rotting.
Is this address in my network. An address belongs to a network or it does not, and guessing is how machines end up talking to the wrong place. I test membership with code, not by eye. The check below says yes for 10.0.0.5 and no for 10.0.1.5, and the difference is one number in the third spot.
$ python3 -c "
import ipaddress
net = ipaddress.ip_network('10.0.0.0/24')
print(ipaddress.ip_address('10.0.0.5') in net)
print(ipaddress.ip_address('10.0.1.5') in net)"
True
False
Every flag in the commands above, letter by letter.
python3 -c: -c means run the string that follows as code. The quotes hold the program. Without -c, python3 expects a filename.python3 -m runs a module by name. python3 -m json.tool reads JSON and prints it indented. It is the flag I reach for when a tool ships as a module instead of a file.Check it: run python3 -c "print(1+1)". It prints 2. Then run echo '{"a": 1}' | python3 -m json.tool.
Try it: run the check above, then test your own address against your own network. If the answer is False, your machine is on a different network than you thought, and that explains why it cannot reach the service.
Network, broadcast, and the hosts between. A /24 network has 254 usable addresses. The first is the network address and the last is the broadcast address. Neither one belongs to a machine. I count them before I hand out addresses, because handing out the broadcast address breaks the whole network.
$ python3 -c "
import ipaddress
net = ipaddress.ip_network('10.0.0.0/24')
hosts = list(net.hosts())
print('hosts:', len(hosts), 'first:', hosts[0], 'last:', hosts[-1], 'broadcast:', net.broadcast_address)"
hosts: 254 first: 10.0.0.1 last: 10.0.0.254 broadcast: 10.0.0.255
Try it: run the code above with a /25 and then a /28. A /25 has 126 hosts. A /28 has 14. The smaller the network, the fewer machines it holds, and the sooner it runs out.
Definition: At this level addresses are a managed resource. The organisation owns public blocks, registers them, and watches them. Private ranges are planned across regions and clouds so nothing overlaps. Every address is accounted for, and every block has an owner and a purpose.
Types:
Uses: I use this when networks span regions and clouds. It is also how I review addressing I did not build: I ask who owns each block, what it is for, and when it was last audited.
Dimensions: At a hundred times the scale the shortage is the story: public addresses are scarce, so they are shared, translated, and guarded. What breaks is an overlap between two networks that must now connect, and I notice it when the connection works for half the machines and fails for the rest. It costs planning before building, and it buys networks that can join together without renumbering.
The address that looks right and is not. 10.0.1.5 looks like it belongs with 10.0.0.5. It does not. They are on different /24 networks, and a machine on one cannot reach the other without a router. I have seen a whole afternoon lost to an address that looked right and was one network over.
$ python3 -c "
import ipaddress
net = ipaddress.ip_network('10.0.0.0/24')
for a in ['10.0.0.5', '10.0.0.200', '10.0.1.5']:
print(a, 'in 10.0.0.0/24:', ipaddress.ip_address(a) in net)"
10.0.0.5 in 10.0.0.0/24: True
10.0.0.200 in 10.0.0.0/24: True
10.0.1.5 in 10.0.0.0/24: False
Try it: run the check with three addresses of your own. Two in, one out. The one that is out is the one that cannot talk to the others directly. When two machines cannot reach each other, I run this check before I touch any cable.
An octet is called an octet because it is 8 bits. The name is the definition. 8 bits hold 256 values, 0 to 255, and that is why no part of an IPv4 address is ever above 255. If you see 192.168.1.300, it is not an address. It is a typo, and the machine will tell you so.
The dotted form is for humans. Machines use the 32 bits. When you type 192.168.1.1, something converts it to 11000000.10101000.00000001.00000001 before a single packet moves. The dots exist because humans cannot read 32 bits at a glance. The machine has no such problem.
Every address is also a number. 192.168.1.1 is 3,232,235,777. That single number is how machines sort, compare, and store addresses. It is also how you can tell whether one address is bigger than another, which matters when you start carving networks into pieces in the next lessons.
The 4.3 billion was not wasted evenly. Big blocks went to big organisations early, and some of those blocks are barely used today. That is part of why the shortage hurts: the addresses exist, but they are not where they are needed, and taking them back is a political problem, not a technical one.
At 10x the machines, the address is no longer typed by hand. It is handed out automatically, recorded, and tracked. The skill stops being reading an address and starts being reading the system that hands them out.
At 100x, the design changes. Public addresses become scarce enough to share, and sharing needs translation, which is the next lesson. And the long-term answer is a new address format with 128 bits, which gets its own lesson after that.
Try it: three addresses, two in, one out. Run the membership check with 10.0.0.5, 10.0.0.200, and 10.0.1.5 against 10.0.0.0/24. The first two print True. The third prints False. The third address looks like it belongs, and it does not. That one number in the third spot is the whole difference between two networks.
$ python3 -c "
import ipaddress
net = ipaddress.ip_network('10.0.0.0/24')
for a in ['10.0.0.5', '10.0.0.200', '10.0.1.5']:
print(a, 'in 10.0.0.0/24:', ipaddress.ip_address(a) in net)"
10.0.0.5 in 10.0.0.0/24: True
10.0.0.200 in 10.0.0.0/24: True
10.0.1.5 in 10.0.0.0/24: False
A new printer arrived in the office, and I gave it an address from memory: 192.168.1.50. It printed fine for a day. Then, on the second day, print jobs started vanishing. Some printed. Some did not. The printer was fine. The address was not. Another machine on the network was already using 192.168.1.50, and the two of them had been fighting over it since the printer arrived.
Three things. First, an address record: one page that lists every fixed address and what it belongs to. No address is given out from memory any more. Second, a rule: before any new fixed address, check the record, then check the network for a reply. Third, a sweep of the old machines, because if one forgotten server could hold an address for a year, there were probably more. There were two.
You are setting up a home network. The router is 192.168.1.1. You have a laptop, a phone, a printer, and a smart TV. The printer needs a fixed address so everyone can always find it. The rest can get addresses automatically. Plan the addresses.
The network 192.168.1.0 holds 256 addresses, from 192.168.1.0 to 192.168.1.255. The router takes .1. I give the printer .50, a round number in the middle, far from the automatic pool. The automatic pool runs from .100 to .200, which is 101 addresses, more than enough for a home. The printer's address is written on a card taped to the router, and in a note on my phone. One fixed address, one pool, one record.
A fixed address buys reliability and costs bookkeeping: someone has to remember it. Automatic addresses buy zero effort and cost surprise: the address can change. A small pool buys order and costs room to grow. A big pool buys room and costs the chance of a clash with a fixed address. The record is what makes all of it work, and the record costs one minute to write.