Page 106 / 162
Scroll up to view Page 101 - 105
97
Figure 138
Network Number and Host ID
How much of the IP address is the network number and how much is the host ID varies according to the subnet mask.
Subnet Masks
A subnet mask is used to determine which bits are part of the network number, and which bits are part of the host ID (using
a logical AND operation). The term ―subnet‖ is short for ―sub
-
network‖.
A subnet mask has 32 bits. If a bit in the subnet mask is a ―1‖ then the corresponding bit in the IP address is part of the
n
etwork number. If a bit in the subnet mask is ―0‖ then the corresponding bit in the IP address is part of the host ID.
The following example shows a subnet mask identifying the network number (in bold text) and host ID of an IP address
(192.168.1.2 in decimal).
Subnet Mask - Identifying Network Number
1ST
OCTET:
2ND
OCTET:
3RD
OCTET:
4TH
OCTET
Page 107 / 162
98
(192)
(168)
(1)
(2)
IP Address (Binary)
11000000
10101000
00000001
00000010
Subnet Mask (Binary)
11111111
11111111
11111111
00000000
Network Number
11000000
10101000
00000001
Host ID
00000010
By convention, subnet masks always consist of a continuous sequence of ones beginning from the leftmost bit of the mask,
followed by a continuous sequence of zeros, for a total number of 32 bits.
Subnet masks can
be referred to by the size of the network number part (the bits with a ―1‖ value). For example, an ―8
-bit
mask‖ means that the first 8 bits of the mask are ones and the remaining 24 bits are zeroes.
Subnet masks are expressed in dotted decimal notation just like IP addresses. The following examples show the binary
and decimal notation for 8-bit, 16-bit, 24-bit and 29-bit subnet masks
Subnet Masks
BINARY
DECIMAL
1ST
OCTET
2ND
OCTET
3RD
OCTET
4TH
OCTET
8-bit mask
11111111
00000000
00000000
00000000
255.0.0.0
16-bit mask
11111111
11111111
00000000
00000000
255.255.0.0
24-bit mask
11111111
11111111
11111111
00000000
255.255.255.0
Page 108 / 162
99
29-bit mask
11111111
11111111
11111111
11111000
255.255.255.248
.
Network Size
The size of the network number determines the maximum number of possible hosts you can have on your network. The
larger the number of network number bits, the smaller the number of remaining host ID bits.
An IP address with host IDs of all zeros is the IP address of the network (192.168.1.0 with a 24-bit subnet mask, for
example). An IP address with host IDs of all ones is the broadcast address for that network
(192.168.1.255 with a 24-bit
subnet mask, for example).
As these two IP addresses cannot be used for individual hosts, calculate the maximum number of possible hosts in a
network as follows:
Maximum Host Numbers
SUBNET MASK
HOST ID SIZE
MAXIMUM NUMBER OF
HOSTS
8 bits
255.0.0.0
24 bits
2
24
–
2
16777214
16 bits
255.255.0.0
16 bits
2
16
–
2
65534
24 bits
255.255.255.0
8 bits
2
8
–
2
254
29 bits
255.255.255.248 3 bits
2
3
–
2
6
Notation
Since the mask is always a continuous number of ones beginning from the left, followed by a continuous number of zeros
for the remainder of the 32 bit mask, you can simply specify the number of ones instead of writing the value of each octet.
This is usual
ly specified by writing a ―/‖ followed by the number of bits in the mask after the address.
Page 109 / 162
100
For example, 192.1.1.0 /25 is equivalent to saying 192.1.1.0 with subnet mask 255.255.255.128.
The following table shows some possible subnet masks using both notations.
Alternative Subnet Mask Notation
SUBNET
MASK
ALTERNATIV
E NOTATION
LAST OCTET
(BINARY)
LAST OCTET
(DECIMAL)
255.255.255.0
/24
0000 0000
0
255.255.255.128
/25
1000 0000
128
255.255.255.192
/26
1100 0000
192
255.255.255.224
/27
1110 0000
224
255.255.255.240
/28
1111 0000
240
255.255.255.248
/29
1111 1000
248
255.255.255.252
/30
1111 1100
252
Subnetting
You can use subnetting to divide one network into multiple sub-networks. In the following example a network administrator
creates two sub-networks to isolate a group of servers from the rest of the company network for security reasons.
In this example, the company network address is 192.168.1.0. The first three octets of the address (192.168.1) are the
network number, and the remaining octet is the host ID, allowing a maximum of 2
8
–
2 or 254 possible hosts.
The following figure shows the company network before subnetting.
Page 110 / 162
101
Figure 139
Subnetting Example: Before
Subnetting
You can ―borrow‖ one of the host ID bits to divide the network 192.168.1.0 into two separate sub
-networks. The subnet
mask is now 25 bits (255.255.255.128 or /25).
The ―borrowed‖ host ID bit can have a value of either 0 or 1, allowing two subnets; 192.168.1.0 /25 and 192.168.1.128 /25.
The following figure shows the company network after subnetting. There are now two sub-networks,
A
and
B
.
Figure 140
Subnetting Example: After
Subnetting
In a 25-bit subnet the host ID has 7 bits, so each sub-network has a maximum of 2
7
–
2 or 126 possible hosts (a host ID of
all zeroes is the subnet‘s address itself, all ones is the subnet‘s broadcast address).