|
| |
|
Subnet
masks
With the
rapid growth of the Internet and the ever-increasing demand for new
addresses, the number of available networks and hosts in the standard
address class structure can be expanded by borrowing bits from the host
portion and using them to allow for more networks. Under this addressing
scheme, called subnetting, separating the network and host requires a
special mechanism called a subnet mask. A subnet mask, which contains
a binary bit pattern of ones and zeros, is applied to an address to extract
the network ID for purposes of determining whether an address is on the
local network. If not, the address is switched or routed on.
Determining the proper mask
value to assign to router and client IP addresses is sometimes difficult.
You are usually pretty safe using 255.255.255.0 for your IPNetRouter
gateway's private subnet, especially if you never intend to have more than
254 unique LAN clients on your LAN.
|
|
 |
The function of a subnet
mask is to extract the network ID portion of an IP destination address
and determine whether an IP address exists on the local network or
whether it must be routed outside the local network. If the extracted
network ID matches the local network ID, the destination is located on
the local network. However, if they don't match, the message must be
routed outside the local network. The process used to apply the subnet
mask involves Boolean algebra to filter out nonmatching bits.
|
|
|
Boolean Nightmares
Don't worry; you don't
need to relive your past-life algebraic nightmares to pass the CCNA exam.
Boolean algebra is a process that applies binary logic to yield binary
results. What a relief, huh?
Working with subnet
masks, you need only four basic principles of Boolean algebra:
Or in other words, the
only way you can get a result of a 1 is to combine 1 and 1. Everything else
ends up as 0.
|
|
 |
The process of combining
binary values with Boolean algebra is called anding. |
|
Address Class |
Subnet Mask |
|
Class A |
255.0.0.0 |
|
Class B |
255.255.0.0 |
|
Class C |
255.255.255.0 |
|
|
|
|
|
|
There are default standard subnet masks for
Class A, B, and C addresses. Table 1 lists the commonly used subnet masks
for each IP address class.
Table 1:
Standard IP Class Default Subnet Masks |
|
|
|
 |
The subnet
mask is like a strainer or filter that is applied to a message's
destination IP address. Its objective is to determine whether the
local network is the destination network. It goes like this: |
|
|
|
|
|
1. If a destination IP
address is 206.175.162.21, you know that it's a Class C address and its
binary equivalent is 11001110 10101111 10100010 00010101.
2. The default standard
Class C subnet mask is 255.255.255.0 and its binary equivalent is
11111111 11111111 11111111 00000000.
3. When these two binary
numbers (the IP address and the subnet mask) are combined using Boolean
algebra (anding), the network ID of the destination network is the
result:
|
|
206.175.162.21 11001110 10101111 10100010 00010101
and
255.255.255.0 11111111 11111111 11111111 00000000
yields
11001110 10101111 10100010 00000000
4. The
result is the network ID of 206.175.162.0.
|
 |
Subnet masks apply only to Class A, B, or C IP addresses. |
|
|
|
|
The tables below are commonly used
subnet masks and hosts.
Class C
|
| |
| Mask |
Notation |
Subnets
|
Hosts |
| 255.255.255.0 |
/24 |
1 |
256 |
| 255.255.255.128 |
/25 |
2 |
128 |
| 255.255.255.192 |
/26 |
4 |
64 |
| 255.255.255.224 |
/27 |
8 |
32 |
| 255.255.255.240 |
/28 |
16 |
16 |
| 255.255.255.248 |
/29 |
32 |
8 |
| 255.255.255.252 |
/30 |
64 |
4 |
| 255.255.255.254 |
/31 |
128 |
2 |
| 255.255.255.255 |
/32 |
256 |
1 |
| |
Class B
|
| |
| Mask |
Notation |
Subnets |
Hosts |
| 255.255.0.0 |
/16 |
2 |
65,536 |
| 255.255.128.0 |
/17 |
2 |
32,768 |
| 255.255.192.0 |
/18 |
4 |
16,384 |
| 255.255.224.0 |
/19 |
8 |
8,192 |
| 255.255.240.0 |
/20 |
16 |
4,096 |
| 255.255.248.0 |
/21 |
32 |
2,048 |
| 255.255.252.0 |
/22 |
64 |
1,024 |
| 255.255.254.0 |
/23 |
128 |
512 |
| 255.255.255.0 |
/24 |
256 |
256 |
| |
Class A
|
| |
| Mask |
Notation |
Subnets |
Hosts |
| 255.0.0.0 |
/8 |
1 |
16,777,216 |
| 255.128.0.0 |
/9 |
2 |
8,388,608 |
| 255.192.0.0 |
/10 |
4 |
4,194,304 |
| 255.224.0.0 |
/11 |
8 |
2,097,152 |
| 255.240.0.0 |
/12 |
16 |
1,048,576 |
| 255.248.0.0 |
/13 |
32 |
524,288 |
| 255.252.0.0 |
/14 |
64 |
262,144 |
| 255.254.0.0 |
/15 |
128 |
131,072 |
| 255.255.0.0 |
/16 |
256 |
65,536 |
|
| |
| |
| |
|