All class addresses have default subnet masks because the subnet bits come from the high order bits of the host field. The following list provides the default subnet masks used for each class of IP address:
These default masks have a binary 1 in every position that corresponds to the default network address component of the appropriate IP address class.
Now that you are familiar with the complete technical explanation of subnet masking, lets discuss it in terms that might be a bit easier to understand. The most important thing to remember about subnet masks is that you cannot just assign IP addresses without any consideration. The question then becomes: Why should I use subnetting on my network? The simple answer is that you should do so in order to route across your network. Then we must ask: Why route? Complicated and convoluted, isnt it?
Assume for the purpose of this discussion that you have a large Ethernet segment that has gotten so full of users that the collisions occurring on it are negatively impacting the users and the segments performance. The quick and easy answer is to use a bridge that will enable you to split the network but retain connectivity. The problem here is that bridges use MAC addresses to make decisions on where to forward packets. The bad news is that if the bridge does not know where to send a packet, it resorts to broadcasting it to everyone. The catch is that your slow, busy Ethernet segment will have been split into two segments; your network performance should increase as a result. The problem is that as you begin to connect more and more segments, you end up with broadcasts flowing all across the network to the point that it could bring the whole intranet to a standstill. Typically, large amounts of broadcasts, such as those described here, are called broadcast storms, which are definitely a bad thing. What is needed is a piece of hardware with more intelligencethe router.
In general terms, the router connects multiple networks and makes decisions on where to and if it should forward packets based upon the packets addresses. The router has been designed to drop all packets if it does not know where to forward them; hence, there are no more out-of-control broadcasts.
For example, lets say you have network 172.24.0.0 out interface #1 of your router and network 10.37.0.0 out interface #2. First, IP addresses must be assigned to each router interfacelets say xxx.xxx.1.1and at least one PC would need to be on each network. Figure 2-4 demonstrates this scenario.
A router will not learn about every individual address out there. Instead, the router believes that if interface #1 has an IP address of 172.24.1.1 255.255.255.0, then all packets destined for the 172.24.0.0 network must be located out on that interface. To recap, if the router receives a packet that is not destined to either of the networks it knows about (in this case, 172.24.0.0 or 10.37.0.0), then that packet is dropped, or rather erased, from its memory.
If PC-A is trying to communicate with PC-B, then the packets destination IP address will be 10.37.100.212. So how does the router actually know that this IP address is located in the same network as the IP address assigned to its interface (10.37.1.1)? Well, simply put, the subnet mask must be entered.
Thus, when you assign the IP address 10.37.1.1 to interface #2, you must also specify a subnet mask.
If you have assigned a subnet mask of 255.255.0.0 to interface #2, then you are telling the router when it needs to make a routing decision on a packet if the first two octets of the destination IP address match (10.37). The router then forwards the packet out interface #2.
This is because when designing a subnet mask (as previously discussed), 255 in a subnet mask means the router needs an exact match, whereas 0 means it doesnt matter what this octets value is.
Lets look at this in another way. If you give that interface a subnet mask of 255.255.255.0, then you are telling the router to only look at the first three octets of the destination IP address when it needs to make a routing decision. Because, as previously discussed, the first three octets for a natural class C address define the network number.
You can even make subnet masks extremely explicit by applying a subnet mask of 255.255.255.255 to the interface. By doing this, you are telling the router to only look at the first four octets of the destination IP address when it needs to make a routine decision. Therefore, only packets destined to IP address 10.37.100.212 would be routed through that interface.
There are a variety of different ways that you use subnet masks to segment your network, and that really goes beyond the scope of this book. If you are interested in learning more about basic subnetting techniques, then refer to the RFCs mentioned at the end of this section. But before you move on, there are some restrictions you must be aware of when using subnets.
In a traditional subnetted network, several restrictions apply that have been lifted if classless interdomain routing (CIDR) is being used along with a protocol that supports CIDR (such as OSPF or BGP). However, if older, non-CIDR routing protocols (such as RIPv1) are in use, these restrictions must still be observed.
For identical subnet masks, a router assumes that the subnet mask, which has been configured, is valid for all subnets. Therefore, a single mask must be used for all subnets with a network. Different masks can be used for different networks.
A subnetted network cant be split into isolated portions because all subnets must be contiguous. Within a network, all subnets must be able to reach all other subnets without passing traffic through other networks.
Further discussion or examples on this topic would fall outside the scope of this book; however, if you require further information, I would recommend the following sources: