IP addresses and gateways
An IP address with a prefix length, like 10.10.0.11/24, contains two pieces of information:
- The network: the first 24 bits, 10.10.0. Every host on this network has an address starting 10.10.0, and the network itself is written 10.10.0.0/24.
- The host: the remaining 8 bits, .11 here. A /24 has 256 addresses: .0 is the network address, .255 is the broadcast address, and .1 to .254 are for hosts.
| Prefix | Addresses | Usable hosts | Typical use |
|---|---|---|---|
| /24 | 256 | 254 | An office LAN or VLAN |
| /30 | 4 | 2 | A point-to-point link between two routers |
| /31 | 2 | 2 | A point-to-point link (RFC 3021) |
| /32 | 1 | 1 | A single address, such as a loopback |
The plan for this lab uses private address space (RFC 1918), one /24 per group of devices:
| Network | Devices | Gateway |
|---|---|---|
| 10.10.0.0/24 | pc1 (.11), pc2 (.12) | 10.10.0.1 (R1) |
| 10.20.0.0/24 | pc3 (.13) | 10.20.0.1 (R1) |
Every host makes one decision for every packet: is the destination on my own network? If yes, it uses ARP to find the destination's MAC address and sends the frame directly. If no, it sends the frame to its default gateway, the router. That decision is a route lookup, and you can try it below with pc1's real routing table.
root@pc1:~# ip route
default via 10.10.0.1 dev eth0
10.10.0.0/24 dev eth0 proto kernel scope link src 10.10.0.11- Line 2: Anything not local goes to the gateway, R1's VLAN 10 address.
- Line 3: 10.10.0.0/24 is directly on eth0: no gateway needed.
Interactive: Route lookup on pc1 pc1's real routing table. Look up pc2 (same subnet: direct), pc3 (another subnet: via the gateway), then delete the default route and try again. (needs JavaScript)
Check your understanding
How many usable host addresses does a /24 network have?
- 254
- 256
- 24
- 255