What is an IP Address Subnet?
The Functions of an IP Address
IP addresses are defined by layer 3 of the OSI reference model. All addresses in this layer have two functions;
- To identify the network to which they belong
- To identify the host machine within the network
In order to achieve both of these functions in a manner flexible enough to suit every scenario on the Internet a subnet mask is included with every IP address. This mask to can manipulated in order to logically divide a network into different segments.
Classful Networks
Subnets are created when segmenting classful networks into a number of smaller networks, so in order to understand subnetting one must understand classful network boundaries. The following classful network boundaries have been defined by IANA (Internet Assigned Numbers Authority).
Class A - 0.0.0.0 - 127.255.255.255
Classful Network Mask 255.0.0.0 (/8)
Class B - 128.0.0.0 - 191.255.255.255 Classful Network Mask 255.255.0.0 (/16)
Class C - 192.0.0.0 - 223.255.255.255 Classful Network Mask 255.255.255.0 (/24)
IP Subnets Explained
Subnets are created when the prefix length is increased to define more network bits than the classful network mask.
For example:
Network 10.32.12.0/8 is said to be subnetted when more than 8 bits are used as the network mask. i.e. 10.32.12.0/9
For a class B network, a mask greater than /16 signifies subnets.
For a class C network, a mask greater than /24 signifies subnets.
Explanation of a Subnet Mask
The network portion of the IP address is identified when the corresponding subnet mask bit is set to 1.
Simple Example of How a Subnet Mask Works
324568643 - Imaginary number
111100000 - Imaginary subnet mask
3245
- Network portion of the address because the corresponding mask bits are set to 1.
68643
- Host portion of the address because the corresponding mask bits are set to 0.
Related Facts
- IP addresses are 32 bits in length.
- IP addresses are binary numbers that are represented in decimal for legibility.
- The 32 bits of an IP address are composed of 4 x 8bits otherwise known as Octets
- Octets are represented in Decimal. For example 192.168.1.1
- A subnet mask is 32 bits in length
- Every bit on a subnet mask corresponds to a bit in the IP address
- Every bit on a subnet mask that is set to 1 tells the device that the corresponding bit on the IP address is identifying the network.
- Every bit on a subnet mask that is set to 0 tells the device that the corresponding bit on the IP address is identifying the host.
Why Subnets Exist
The Internet is vast so there are many different requirements for network sizes. Some networks are very small, for example a home network, and some are very large. In order to cater for many different sizes of networks a mask can be modified in order to support more hosts or less hosts as required.
IP network masks are also manipulated to help to decrease the size of the Internet routing table by grouping many networks together.
The Solution
IP address network masks enable network administrators and engineers to adjust network sizes more precisely in order to conserve IP addresses.
Technical Details
IP address masks are binary 1s represented by Decimal numbers. If you wanted to use the first 24 bits of an IP address as the network and the last 8 bits as the host then the mask would look like this.
Example 1 - This example uses a standard 24 bit mask to use the first 3 Octets as the network portion of the address.
Mask
Bit
1 -------------------------------------------------------32

11111111.11111111.11111111.00000000
IP Address
Bit
1 -------------------------------------------------------32

11000000.10101000.00000010.00000001
{------------ Network -----------------}{---Host---}
Example 2 - This example uses a 25 bit mask to include the first bit of the 4th Octet as part of the network portion of the address.
Mask
Bit
1 -------------------------------------------------------32

11111111.11111111.11111111.10000000
Decimal 255
.255
.255
.128
IP Address
Bit
1 -------------------------------------------------------32

11000000.10101000.00000010.00000001
{------------ Network -------------------}{--Host---}
Other notations. The slash (/) notation tells the reader how many bits are used in the mask.
192.168.1.0/24 is the same as 192.168.1.0 255.255.255.0 because 255.255.255 represents 24 bits of the mask.
How do you calculate the decimal notation? - Binary to Decimal Conversion
Every bit is 2^N - if you are setting the 8th bit then the value is 2^8=128, the 7th bit is 2^7=64 and so on. When you add all 8 bits together = 128+64+32+16+8+4+2+1 = 255 (derived from 2^8+2^7+2^6+2^5+2^4+2^3+2^2+2^1)
If you only wanted to set the first 3 bits of the octet then you simply add the first 3 values.
11100000 = 2^8 + 2^7 + 2^6 = 128 + 64 + 32 = 224