IP addresses, masks and subnets
How a machine decides whether the destination is next to it or across the planet, and what NAT does to your packets.
An IP packet carries exactly two addresses: who sent it and who should get it. Nothing else. IP makes no promises — the packet may be lost, duplicated or arrive out of order. That is why IP is called best-effort, and why TCP has a job at all.
192.168.1.37 = 11000000.10101000.00000001.00100101
255.255.255.0 = 11111111.11111111.11111111.00000000
└────── сеть (24 бита) ──────┘└─ хост ─┘
192.168.1.0 — адрес самой сети (не выдаётся машинам)
192.168.1.255 — широковещательный адрес
192.168.1.1 … 192.168.1.254 — 254 адреса для устройствSome ranges are reserved for private networks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. They are not routable on the internet, so thousands of homes can reuse 192.168.1.0/24 without collision. 127.0.0.1 is loopback: it always means this machine. 169.254.x.x means DHCP never answered and the machine gave itself an address.
Practice
Interface 192.168.1.37 with mask 255.255.255.192. How many usable addresses does this subnet have, and what is its network address?
Hints
- Convert the last mask octet to binary: 192 is 11000000.
- Bits set to 0 in the mask are the device number inside the network.
12 XP
Order what happens when you open a site on a server in another country.
Hints
- A packet leaves the machine only after the destination has been classified as local or remote.
- NAT happens on the way out of the private network, after the gateway has been chosen.
14 XP
Match each address with what it means in practice.
Hints
- Private addresses start similarly — that shared prefix is the point.
- A 169.254.x.x address is what a machine gives itself when DHCP stays silent.
16 XP