RecapDifficulty: Advanced1 min

Recap: IP Addresses and Subnets

A prefix splits an address in two, a count follows from the host bits, and ranges must never overlap.

IP addresses let a packet cross networks, and the prefix is the key to every question about them.

  • The network layer gives each machine an address that means something across networks. IP does its best and promises nothing more.
  • An IPv4 address is 32 bits, split by the prefix into a network part and a host part. The all-zeros and all-ones host values are reserved.
  • Reading a block: 32 minus the prefix gives the host bits, 2 to that power gives the addresses, and subtracting two gives the hosts.
  • Same network or not depends on the prefix: compare the network parts.
  • Private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. NAT rewrites the source address and port on the way out.
  • IPv6 has 128-bit addresses, /64 subnets and no shortage, so it rarely needs NAT.
  • Ranges must not overlap if two networks will ever be joined. Plan them before the first one is built.
The three everyday address questions and the method for each
QuestionMethod
How many addresses in this block?2 to the power of (32 minus the prefix); subtract 2 for usable hosts, and more on a cloud platform
Are these two addresses on the same network?Set the host bits of each to zero under the shared prefix, and compare
Do these two ranges overlap?Write each as first to last address; they overlap if either range contains the other's first address