The subnet mask is a 32-bit number that identifies the network address portion of an IP address. There are two types of subnet masks: Default subnet mask and Custom subnet mask
+ Default subnet mask (Default Subnet Mask)
Each network address layer has a default subnet mask. Class A subnet mask covers 8 bits, class B covers 16 bits and the first 24 bit C layer. The remaining bits are used to type the device address.
To understand this concept, imagine the subnet mask is a grid covering the network address part in an IP address. Each computer or router will use the subnet mask to determine the network address of the IP addresses it will send the message to. Bits that are not covered by the subnet mask are bits that identify the device address in an IP address.
The internal bits in the subnet mask correspond to the network definition bits of the IP address with a value of 1, the bits corresponding to the bits that identify the device have a value of 0. In decimal, if the The network identification part of an IP address occupies an entire octet, so the corresponding octet in the subnet mask will have a value of 255.
If there is no custom subnet mask, the default subnet mask will be used to distinguish the network definition and device identification part in an IP address.
Custom subnet mask
The subnet address is the network address for a subnet. A custom subnet mask allows us to identify these subnet addresses in an IP address. When creating a custom subnet mask for a subnet, you also specify the maximum number of devices that can be connected in that subnet.
For example, imagine your network is assigned an address of class C, but you need to divide it into subnets to improve network performance. If you place a subnet mask as in the Class C example in the image above, your network can have up to 14 subnets (24-2) and each subnet can have up to 14 devices.
Most custom subnet masks cover bits covered by the default subnet mask but in addition to those bits, it extends a few other bits out of the next octets.
Just like the default subnet mask, the custom subnet mask also includes bits 1, corresponding to the bits in the IP address covered by the subnet mask. In decimal form, each octet in the subnet mask completely covers an octet in the IP address that also has a value of 255. The decimal value of the remaining octets in the subnet mask depends on the number of bits. Used to determine the subnet address.
Without a custom subnet mask, all computers on your network must belong to the same physical network segment. With the subnet mask, you can create different subnets. When you add a bit to the default subnet mask, you have turned that bit into a bit that identifies the subnet address, but it also means reducing the number of remaining bits for the device address.
IP address management
IP address management in a TCP / IP network usually begins with obtaining a network address from an Internet service provider (ISP) or organizations responsible for allocating Internet addresses. After having a network address, the following three important tasks must be completed to type IP addresses for devices on the network.
- Select subnet mask
- Assign addresses to subnets
- Assign addresses to devices on the subnet
To determine the subnet mask, you must first determine the number of subnets needed. This needs to be calculated based on the current status and expected growth of the company's network. Here are two ways you can use to define subnet masks.
Problem: Need to divide C network address 162.199.0.0 into 10 subnets. What is the value of the subnet mask?
In this example, we have a class B address that needs to be divided into 10 subnets. To specify a custom subnet mask, the following steps need to be performed:
First, get the number of subnets needed and convert that number into binary. In this case, if you need 10 subnets, switch 10 to binary and 1010
Step 2, convert all the bits in that binary value to 1. We will convert all bits of 1010 to 1 and add the zeroes after the result to get an entire octet. The result will be 11110000. Convert this binary value to decimal, 240. This is the extension (in addition to the default subnet mask) of the custom subnet mask. To get a custom subnet mask, just add this value after the default subnet mask 255255.0.0 and get 255.255.255.240.
We have diagrams and summaries of the following steps:
Because each outer bit of the default mask of each layer is only 1 or 0, there are only 8 network mask values.
Customizable children vary for each octet. Therefore, it is possible to set up a table to help us quickly determine the appropriate mask value.
Let's start with the binary conversion table and calculate the possible subnet mask values by accumulating the bit values in the diagram. The mask covers a bit with a value of 128. The 2-bit mask covers a value of 128 + 64, or 192. The mask covers 3 bits with a value of 192 + 16, or 224.
Continue doing so until you reach the rightmost column, when all the bits of the octet are used in the subnet mask. It will have a value of 255.
Next, determine the number of subnets corresponding to each subnet mask value. The subnet number can be determined by the formula 2 ^ m-2, where m is the number of bits entered in the subnet mask (in addition to the default mask bits). You need to subtract 2 because there are two reserved addresses on each network. For example, if only 1 bit is used for the subnet mask (then the subnet mask value is 128), there will be 2 ^ 1-2 = 0 valid addresses for this subnet. If using 2 bits for the subnet mask (the subnet mask value is 192), there will be 2 ^ 2-2 valid values for the subnet address. Just like that, we calculate the next column.
The final step is to define the column in the table that allows you to divide the network into the desired subnetwork number. For example, if you need 8 subnets, select the column that allows up to 14 subnets, corresponding to that value of 240 in the subnet mask.
Note: In some cases, we must calculate the number of subnets that may be available with a network address and the given subnet mask. This is the inverse problem of the above problem. The steps are as follows:
Calculate the number of devices on each subnet
After determining the subnet mask value, it is necessary to specify the number of devices that can be connected to each subnet.
Problem: How many devices can connect to subnets in the following networks?
For example, the mask 255.255.240.0 for Class B networks divides the network into 14 subnets. There will be 12 unmarked bits. Applying the above formula will calculate the maximum number of devices per subnet of 2 ^ 12-2 = 4094
We have diagrams and summaries of the following steps:
After you have defined the subnet mask that matches the requirements for the number of subnets to be set up, you need to specify the addresses that will be assigned to each subnet.
Problem: List all valid subnet addresses for a class B network with 131.56.0.0 address with subnet mask 255.255.240.0.
In this example, you have been given a class B address of 131.56.0.0, and you have chosen 255.255.240.0 as a subnet mask. To calculate valid subnet addresses, first convert the mask value to binary. Find the rightmost 1 bit and convert that bit to decimal. In this example, the rightmost 1 bit has the corresponding decimal value of 16. This is called progressive value
Next, create a list of subnet addresses by adding the accumulated value into the allocated network address. Note that the list will stop at the same number as the subnet mask value.
131.56.0.0
131.56.128.0
131.56.16.0
131.56.144.0
131.56.32.0
131.56.160.0
131.56.38.0
131.56.176.0
131.56.64.0
131.56.192.0
131.56.80.0
131.56.208.0
131.56.96.0
131.56.224.0
131.56.112.0
131.56.240.0
The address list will start with 131.56.0.0 and end at 131.56.240.0. Finally, leave the addresses with all 0 or 1 bits in the subnet mask (these are reserved addresses). If you set up the address list this way, the reserved addresses will be the first address and the last address of the list.
To check the list, count the number of bits included in the mask in the subnet mask and calculate the number of company subnets 2 ^ m-2. In this case, there are 4 bits included in the mask so the subnet number is 2 ^ 4-2 = 14, exactly the same as the number of subnets in the list above.
The last step in IP address management is to identify the IP addresses that can be assigned to devices in each subnet. You need to know the subnet mask, subnet address, progressive value to calculate the first address and the last address on each subnet. The range of valid IP addresses in each subnet is defined as follows:
- Start address: By plus network address 1
- Address ends. By the next subnet address minus 2 (with the current subnet address + accumulated number -2).
Problem: Determining the address range for workstations on subnet 131.56.32.0 of class B network with 131.56.0.0 address and having subnet mask 255.255.240.0
In this case, you have been assigned a 131.56.0.0 Class B address and selected subnet mask 255.255.240.0 to divide this Class B network into different subnets. You want to specify the address range for workstations on subnet 131.56.32.0.
First, switch the mask value to binary. Determine the rightmost 1 bit and the decimal value corresponding to that bit you will get the progressive value of 16.
The first device address will be 131.56.32.1. The next subnet address can be calculated by adding the accumulated value to the subnet part of the address. In this example, the next subnet address will be 131.56.48.0. Subtracting 2 from this value will get the final value of 131.56.47.254 within the subnet address of 131.56.32.0.