Converting a Subnet Mask to Dotted Decimal Notation

The network administrator typically assigns a subnet mask to each host as part of the TCP/IP configuration. If the host receives an IP address through DHCP (see Hour 12, "Dynamic Host Configuration Protocol (DHCP)"), the DHCP server can assign a subnet mask along with the IP address.

Subnet masks must be carefully calculated and must reflect the internal organization of the network. All the hosts within a subnet should have the same subnet ID and subnet mask. For the benefit of people, the subnet mask is usually expressed in dotted decimal notation similar to the notation used for an IP address.

As you'll recall from the preceding section, the subnet mask is a 32-bit binary number. You can convert the binary subnet mask to a dotted decimal address using the address conversion techniques described in Hour 4. A subnet mask is usually much easier to convert to dotted decimal format than an IP address. As you'll recall, the subnet mask bits representing the IP address's network ID and the subnet ID are 1 bits. The bits representing the IP address's host ID are 0 bits. This means that (with a few rare and bewildering exceptions) the 1 bits are all on the left and the 0 bits are all on the right. Any full octet of ones in the subnet mask will appear as 255 (binary 11111111) in the dotted decimal subnet mask. Any full octet of zeros will appear as 0 (binary 00000000) in the subnet mask. Hence, the common subnet mask

 11111111111111111111111100000000 

is expressed in dotted decimal notation as 255.255.255.0. Likewise, the subnet mask

 11111111111111110000000000000000 

is expressed in dotted decimal notation as 255.255.0.0.

As you can see, it is very easy to determine the dotted decimal equivalent of a subnet mask that divides the address at an octet boundary. However, some subnet masks do not divide the address at an octet boundary. In that case, you must simply determine the decimal equivalent of the mixed octet (the octet containing both ones and zeros).

To convert a binary subnet mask to dotted decimal notation, follow these steps:

  1. Divide the subnet mask into octets by writing the 32-bit binary subnet mask with periods inserted at the octet boundaries:

     11111111.11111111.11110000.00000000 
  2. For every all-ones octet, write down 255. For every all-zeros octet, write down 0.

  3. Convert the mixed octet to decimal using the binary conversion techniques discussed in Hour 4. To summarize, add up the bit position values for all one bits (refer to Figure 4.5).

  4. Write down the final dotted decimal address:

     255.255.240.0 

    In most cases, this dotted decimal subnet mask is the value you will enter as part of a computer's TCP/IP configuration.



Sams Teach Yourself TCP/IP in 24 Hours
Sams Teach Yourself TCP/IP in 24 Hours (4th Edition)
ISBN: 0672329964
EAN: 2147483647
Year: 2003
Pages: 259
Authors: Joe Casad

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net