Subnet Masks

As I mentioned in the previous chapter, subnets masks hold the key to understanding the breakdown between the network and host portions of an IP address. The reasons why the classes of IP addresses are split in the way they are is because of the subnet mask assigned to each class by default. The list below outlines the default subnet mask assigned to each class of address.

Class A:

Class B:

Class C:

Right off the bat, an association should become clear. Notice that for a Class A address, the default subnet mask occupies the entire first octet, with a value of 255. If you convert this subnet mask to binary, it becomes:

11111111 00000000 00000000 00000000

When the subnet mask in converted, the entire first octet is made up of binary 1s. The division between the network and host portion of a Class A address occurs where the 1s stop – in this case, right between the first and second octet. As such, we can say that when the default subnet mask is used, the address is separated as shown in the figure below.

Figure: Network and host portions of Class A address with the default subnet mask.

Notice the relationship between the subnet mask and the address. Think of a subnet mask as a cookie cutter that separates the network and host portions of an address. Without a subnet mask, you cannot make an educated statement about how the network and host portions of an address are defined. That may not be fully evident quite yet, given that we’ve only looked at classful addressing and default subnet masks. Later in the chapter, when we look at how custom subnet masks are defined, this distinction will become even more important.

IP Addressing Rules

In order to be certain that IP addresses are valid, there are a number of rules that must be followed. Be sure to pay particular attention to these rules, as they form the basis of determining valid IP addresses.

The first rule of IP addressing is critical. The host portion of an address cannot be set to all binary 0s or all binary 1s. When the host portion of an address is set to all binary 0s, it is used as a way of referring to that particular network. For example, consider the Class B address shown in the figure below, where the host portion is set to all binary 0s.

Figure: Host portion of an IP address in all binary 0s represents the network.

The IP address is simply another way of saying “the 131.107 network”.
The requirement that the host portion of an address cannot be all binary 1s exists for a different reason. When the host ID is set to all 1s, it represents a broadcast on that particular network. For example, consider the Class C address in the figure below, where the host portion is set to all binary 1s.

Figure: Host portion of an IP address in all binary 1s represents a network broadcast.

In this example, the address represents the broadcast address for the network. Any packets sent to this special address are destined for all hosts on the network.

Recall how we subtracted 2 when attempting to figure out how many hosts a given network could support – this was to account for when the host portion is set to all binary 0s or 1s, as I just described.

The second rule that you need to remember is the use of all binary 0s or 1s in the network portion of an address. When the network portion is set to all 0s, it is interpreted to mean “this network”. For example, the address would be interpreted as “host 12.145 on this network”. When the network portion is set to all ones, for example, this is the same as saying “host 1.2 on all networks”. For the most part, you will not be manipulating the network portion of addresses in this manner – these designations will be used by the protocols, as per their programming.

The remaining rules are fairly simple. They include:

  • The network ID of is reserved for diagnostics and testing. The address is referred to as the loopback address
  • An IP address of all 0s ( is used to represent the default route, or where all packets destined for unknown networks should be sent.
  • An IP address of all 1s ( is used to represent a broadcast to all hosts on a network.
  • Network IDs of 224 and above in the first octet are not valid to assign to hosts, since Class D and E addresses are not valid for hosts.

The table below summarizes the IP addressing rules that we’ve looked at in this section.




Host ID cannot be all binary 1s This address represents a network broadcast
Host ID cannot be all binary 0s This address identifies a network
Network ID cannot be all binary 0s This address represents “on this network”
Network ID cannot be all binary 1s The address represents “ on all networks”
Network ID cannot be decimal 127 This address range is reserved for the loopback address
IP address cannot be all binary 0s This address is used to represent the default route
IP address cannot be all binary 1s This address is used to represent a broadcast
Network IDs of 224 and above in the first octet cannot be assigned to hosts Class D addresses are reserved for multicasting, while Class E addresses represent an experimental range

As a quick test, see if you can answer the following question. Is the address valid to assign to a host? You may not have thought so, but answer is yes. Why? The fact that the address ends in a decimal value of 0 doesn’t make a difference. Since this is a Class A address, if you convert it to binary, you’ll notice that the host portion (the last three octets) is neither all binary 0s nor all binary 1s. This is just another example of why it’s so important to always consider addresses in binary. Try not to let assumptions based on what you see in decimal throw you off.

Classful IP Addressing

Since there are literally millions of IP addresses available, the IETF originally designated what are known as classes of IP addresses. The purpose of these classes was to break up the IP address space into ranges that accounted for networks of different sizes. The term “classful” is used to describe addresses that are looked at according to their class. In reality, the world of IP addressing has changed such that classes of addresses are much less important than they used to be – later in the chapter, we’ll take a look at classless addressing, including how and why it came about.

You’ll definitely need to be familiar with classful addressing, since it forms the basis upon which IP addresses were originally defined, and is still a factor with routing protocols such as RIP version 1 and IGRP. Five different classes of addresses exist, and are distinguished according to the values found in their first octet. The table below outlines each of the five ranges.

Class First Octet Decimal Value Network and Host Portions Hosts Supported Per Network Details
A 0-126 N.H.H.H 16,777,214 Intended for the largest networks only
B 128-191 N.N.H.H 65,534 Intended for medium sized organizations
C 192-223 N.N.N.H 254 Intended for small organizations
D 224-239 N/A N/A Reserved range used for multicasting
E 240+ N/A N/A Experimental range

The value of the first octet of an IP address holds the immediate answer to the class an address falls into. Notice that Class A addresses always begin with a value between 0 and 126. As such, the address can safely be identified as Class A. From the table above, you should also note that in a Class A address, the first octet uniquely identifies the network (designated by the “N”), while the last three octets uniquely identify a host (designated by the “H”) on that network. Only Class A, B, and C addresses are valid to assign to hosts. Class D addresses are used to support multicasting, while Class E addresses are reserved for experimental use.

You may have noticed that the first octet value of 127 is missing from the table above. What is the reason for this? The 127 range is actually reserved for diagnostic functions – for example, the address is the loopback address. Ping that address, and you’re actually testing the TCP/IP connectivity of the source machine.

IP Addressing Basics

Back in Chapter 4, we took a very basic and introductory look at the concept of an IP address. Recall that IP addresses are logical addresses made up of two parts – the first part represents a network, and the other, a unique host on that network. Before we get into the details of IP addressing, you’ll first need to know a little more about how binary and decimal numbers relate to each other.

Binary-Decimal Conversions

Remember that IP addresses are 32-bits in length, but are usually represented in dotted-decimal notation. As such, the address can also be represented as:

11000000 10101000 00000010 11001000

But why should you care about the binary version? The answer is absolutely critical – in order to truly understand how IP addressing works, you must always take a look at elements such as addresses and subnet masks in binary form. After you’ve had lots of practice in binary, you’ll get very good at “understanding” the numbers when you see them in decimal. Just remember that when starting off, it is important that you convert addresses to binary – doing so will ultimately unlock the secrets of subnetting, determining if hosts are on the same or different networks, and whether IP addresses are valid.

Having said that, our first logical step is learning how to do decimal-to-binary conversions and vice versa. Recall that a 32-bit address is actually grouped into four octets in its decimal form – each octet represents 8 bits in binary. The figure below outlines the decimal and binary values for each of the 8 bits.

DECIMAL 128 64 32 16 8 4 2 1
BINARY 1 1 1 1 1 1 1 1

Notice that each of the eight binary digits has a single decimal value associated with it. An important pattern should be clear in the decimal row – moving from right to left, the value doubles in each successive column.

This is part of what make binary numbering so useful – for any given decimal number, there is one (and only one), way to represent it in binary. After a few examples, understanding how binary numbering works will be clear.

We’ll start with converting binary to decimal, since this is the easiest way to illustrate the conversion process. Imagine you wanted to convert the binary number 01010101 to decimal. Using Table 5-1, you’ll notice that each binary “1” value corresponds to the decimal value above it. If we add together the decimal values that correspond to the 1s in the binary number, we’ll have completed the conversion process. For example, the decimal value of the binary number 01010101 would be:

0 + 64 + 0 + 16 + 0 + 4 + 1 = 85

All I did was take the decimal value of each of the 1s in the binary number and replace them with their corresponding decimal value. In cases where the binary digit was 0, I did not add that value. Consider another example, the binary number 11100011. In this case, the corresponding decimal value would be calculated as:

128 + 64 + 32 + 0 + 0 + 0 + 2 + 1 = 227

I’ve left the 0 decimal values in my examples to act as placeholders – you should consider doing this until you feel comfortable that you remember the decimal values associated with each binary digit.

IP Addressing and Subnetting

For some reason, nothing seems to scare people preparing for the CCNA or CCDA quite as much as subnetting. While I’m not quite sure why this fear exists, I can tell you one thing for certain – subnetting isn’t very difficult at all, as long as you can remember a few simple rules. If you follow along closely, by the end of this chapter you too will realize how easy subnetting can be.

While subnetting is certainly important, there are many IP addressing concepts that you’ll need to understand in order to be successful in passing your CCNA and CCDA exams. Topics that we’ll cover in this chapter include:

  • Binary-decimal conversions
  • Determining classes of addresses
  • Private IP address ranges
  • Defining custom subnet masks and address ranges
  • Classless addressing
  • Classless Inter-Domain Routing (CIDR)

In your new life as a network engineer, these concepts will represent the foundation of your knowledge. Take the time to truly understand them, as you will ultimately use them again and again.