To understand how the netmask works, look at Example 13.2, “Linking IP Addresses
to the Netmask” (page 228). The netmask consists of 32 bits that identify how much of
an IP address belongs to the network. All those bits that are 1 mark the corresponding
bit in the IP address as belonging to the network. All bits that are 0 mark bits inside
the subnetwork. This means that the more bits are 1, the smaller the subnetwork is.
Because the netmask always consists of several successive 1 bits, it is also possible to
just count the number of bits in the netmask. In Example 13.2, “Linking IP Addresses
to the Netmask” (page 228) the rst net with 24 bits could also be written as
192.168.0.0/24.
Example 13.2:
Linking IP Addresses to the Netmask
IP address (192.168.0.20): 11000000 10101000 00000000 00010100
Netmask (255.255.255.0): 11111111 11111111 11111111 00000000
---------------------------------------------------------------
Result of the link: 11000000 10101000 00000000 00000000
In the decimal system: 192. 168. 0. 0
IP address (213.95.15.200): 11010101 10111111 00001111 11001000
Netmask (255.255.255.0): 11111111 11111111 11111111 00000000
---------------------------------------------------------------
Result of the link: 11010101 10111111 00001111 00000000
In the decimal system: 213. 95. 15. 0
To give another example: all machines connected with the same ethernet cable are
usually located in the same subnetwork and are directly accessible. Even when the
subnet is physically divided by switches or bridges, these hosts can still be reached di-
rectly.
IP addresses outside the local subnet can only be reached if a gateway is congured
for the target network. In the most common case, there is only one gateway that handles
all trafc that is external. However, it is also possible to congure several gateways
for different subnets.
If a gateway has been congured, all external IP packets are sent to the appropriate
gateway. This gateway then attempts to forward the packets in the same manner—from
host to host—until it reaches the destination host or the packet's TTL (time to live) ex-
pires.
228 Reference