- What is an Internet Protocol subnet mask (IP subnet mask)?
- What does an IP subnet mask do?
- What is an IP subnet mask used for?
- Where are subnet masks used?
An IP subnet mask is a binary masking value used to identify and describe IP subnets.
That is the short definition but this short definition probably makes no sense, so we will explain what an IP subnet is first, and then look at how a subnet mask is used to create a subnet. From these two definitions we'll get a better idea of what an IP subnet mask really is. After we define what a subnet mask is, we'll look at what a subnet mask does, what it is used for and where it is used.
An IP subnet is a subnetwork. Subnetworks are smaller portions of larger networks that have been separated by breaking a larger range of IP addresses into two or more smaller ranges of addresses. To really understand what a subnet is, you need to understand the original IP addressing scheme called 'classful addressing'. The original classful IP addressing scheme created networks of varying sizes and identified the class, and therefore the size of the network using the first four bits of the IP address. This was not very efficient because some networks did not use all the IP addresses available in the range provided to them.
Breaking a larger network into subnets allows you to restrict certain kinds of network traffic such as broadcasts. Broadcasts are when a single computer sends data to all equipment on the network. This type of communication is necessary for functions such as ARP, RARP, WINS etc.
Breaking a larger network into subnets also allows the network to grow (to 'scale') more efficiently and wastes fewer IP addresses.
A binary mask is a string of zeroes and ones that is used to filter or mask the values of specific bits in a second binary value. A logical operation is performed which uses the bits from the value to be masked and bits from the mask itself. The resulting output is then used for various purposes. See our tutorial about binary masks elsewhere on this site for more information.
The IP subnet mask allows a computer to mask out the host portion of an IP address. But why would you want to do this? A host needs to know if the computer it is communicating with is on the same network or on a different network.
This leaves only the network portion of the original IP address. Knowing which network an IP address is part of is very important in IP communication. Hosts on the same subnet can talk to each other directly. Hosts on different subnets need a router to communicate with each other.
An IP subnet mask gets used a lot of different ways. An IP subnet mask is used to identify which portion of an IP address identifies the network, and which portion identifies the host. With the subnet mask and the IP address, a computer can tell whether the IP address it wants to talk to is on the local network, or outside your local network, beyond the default gateway.
One IP address and subnet mask is always configured on each network interface installed on a piece of network-capable computing equipment, such as the Ethernet port on your desktop computer. The network address and subnet mask are usually part of dynamic route announcemnets exchanged between routers (though BGP converts the dotted quad format mask into a mask represented in CIDR notation).
Hosts are configured with a unique IP address and subnet mask for each interface on the network. Nearly all hosts have a single network interface, so only a single IP address and subnet mask are used. Hosts receive their IP address and subnet mask from DHCP or the IP address and subnet mask are set manually by the network administrator when the computer is first installed.
Routers are devices with multiple network interfaces, each configured by the network administrator with a unique IP address and subnet mask pair for each interface that is connected to an active network. When routers receive an IP packet, they use a subnet mask to identify the network portion of the address in order to determine which route they should use to forward the IP packet.
Switches contain subnet masks in the VLAN declarations. The Network Address and the subnet mask are used as part of the VLAN declaration so that the switch knows which IP addresses belong to which VLAN.