Addresses, subnets and CIDR
Unit 1 of 5 in Networking fundamentals.
You will be able to read a CIDR block, say how many addresses it covers and recognise private and documentation ranges.
Lesson
An address names a host
The Internet Protocol sends blocks of data called datagrams from a source to a destination, and both are hosts identified by fixed-length addresses. The addresses in the datagram header are what the network uses to carry it toward its destination.
An IPv4 address is 32 bits long. IPv6 increased the address size from 32 bits to 128 bits, which allows many more addresses and more levels of structure.
Prefixes: how a block of addresses is described
Addresses are handed out and routed in blocks. CIDR, short for Classless Inter-Domain Routing, writes a block as an address followed by a slash and a prefix length, for example 198.51.100.0/24. The prefix length says how many of the leading bits are fixed and are the same for every address in the block. The remaining bits are free to vary.
RFC 4632 explains that explicit prefix lengths allow much more flexible matching of address space to actual need than the old fixed network sizes. A block can be any power-of-two size from one address up to 2 to the power of 32.
The sums are simple. A /24 leaves 8 bits free, so it covers 2 to the power of 8, which is 256 addresses. A /16 leaves 16 free bits, so it covers 65,536. A bigger prefix number means a smaller block.
Private ranges and documentation ranges
Not every address is reachable from the whole internet. IANA reserved three blocks for private internets: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Many organizations have hosts, such as internal workstations and equipment, that never need to be reached from outside, so they can use these addresses inside.
Three more blocks are reserved for examples in documentation: 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24. They are not supposed to appear on the public internet. That is why this site's lessons and labs use them when they need an example address, and a defender should use them when writing a ticket or a report that must not point at a real system.
Key points
- An IP address identifies a host; IPv4 has 32 bits and IPv6 has 128.
- CIDR writes a block as address/prefix length; a longer prefix is a smaller block.
- A /24 covers 256 addresses and a /16 covers 65,536.
- 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private; three TEST-NET blocks are for documentation.
Sources
- RFC 791: Internet Protocol
- RFC 4632: Classless Inter-domain Routing (CIDR)
- RFC 1918: Address Allocation for Private Internets
- RFC 5737: IPv4 Address Blocks Reserved for Documentation
- RFC 8200: Internet Protocol, Version 6 (IPv6) Specification
Practice in the labs
Do the arithmetic by hand once, then see the addresses your own machine already has.
- Subnetting and CIDR made simple: You size blocks by hand: host bits, total addresses and usable hosts.
- Meet IPv6: the addresses your computer already has: You read the IPv6 addresses your computer already has and learn which is which.
Also try, in the simulators
- Two hosts on one switch (Network Builder exercise): You give two hosts addresses in the same block and make one ping the other, using the prefix length from this unit.
Knowledge check
- How many addresses does a /24 block cover? Answer: 256. A /24 fixes 24 of 32 bits, leaving 8 free bits: 2 to the power of 8 is 256 addresses (RFC 4632 describes blocks by prefix length).
- Which of these is a private address block reserved by IANA? Answer: 192.168.0.0/16. RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. 198.51.100.0/24 is reserved for documentation, not private use.
- Why should a report or ticket use addresses such as 203.0.113.10 as examples? Answer: They are reserved for documentation and should not appear on the public internet. RFC 5737 reserves three TEST-NET blocks for documentation and says they should not appear on the public internet, so using them cannot point at a real system.
Back to the syllabus or see all classes.