How To Calculate The Subnet Mask

Table of contents:

How To Calculate The Subnet Mask
How To Calculate The Subnet Mask

Video: How To Calculate The Subnet Mask

Video: How To Calculate The Subnet Mask
Video: IPv4 Addressing Lesson 2: Network IDs and Subnet Masks 2024, November
Anonim

A subnet mask is a convenient mechanism for separating a network address from a specific host address. Such a mechanism was already established in the first IP standard in September 1981. To simplify routing and increase its efficiency, you need to be able to calculate the mask.

How to calculate the subnet mask
How to calculate the subnet mask

Instructions

Step 1

The subnet mask, like the network address, is represented by four one-byte numbers (for the IPv4 protocol version, in the IPv6 protocol, they are 8 groups of sixteen-bit digits). For example: IP address 192.168.1.3, subnet mask 255.255.255.0. In TCP / IP networks, a mask is a bitmap that identifies which part of a network address is the network address and which part is the host address. To do this, the subnet mask must be represented in binary form. Bits set to one indicate the network address, and bits set to zero indicate the host address. For example, the subnet mask is 255.255.255.0. You can represent it in binary: 11111111.11111111.11111111.00000000. Then for the address 192.168.1.1 the part 192.168.142 will be the network address, and.142 will be the host address.

Step 2

As you can see from the previous step, there is a limit on the number of hosts and networks. It is obtained from the limitation on the number of variants represented by a given number of bits. One bit can encode only 2 states: 0 and 1. 2 bits - four states: 00, 01, 10, 11. In general, n bits encode 2 ^ n states. However, remember that all ones and all zeros in the host and network address are reserved by the standard to mean "current host" and "all hosts." Thus, it turns out that the total number of nodes in the network is determined by the formula N = (2 ^ z) -2, where N is the total number of nodes, z is the number of zeros in the binary representation of the subnet mask.

Step 3

Remember that the mask may not be composed of arbitrary numbers. The first bits of the mask are always one, the last ones are zero. Therefore, sometimes you can find the address format in the form 192.168.1.25/11. It means that the first 11 bits of the address are the network address, the last 21 are the network node address. This entry corresponds to the address 192.168.1.25 and the subnet mask 255.224.0.0. When calculating the subnet mask, consider the number of computers on the network. Consider its possible expansion: if the number of computers exceeds the possible for a given network, it will be necessary to manually change all addresses and masks on each computer.

Step 4

Addressing is classless and classless. Class separation was used in early implementations of the protocol, and later, with the growth of the Internet, it was supplemented by classless addressing. Class addressing distinguishes 5 classes: A, B, C, D, E. The class determines how many bits of the address will be allocated for the network address, and how many - for the host address. In this case, you will not have to count anything. In class A, 7 bits are allocated for the network address, in class B - 14 bits, in class C - 21 bits. Class D is used for multicast and class E is reserved for experimental use. In this case, the first few bits of the address are used to determine its class. In class A it is 0 in the first bit, in class B - 10, in class C - 110, in class D - 1110, in class E - 11110.

Step 5

Class-based addressing reduced the flexibility of IP in terms of address allocation, and reduced the number of possible addresses. Therefore, classless addressing was adopted. To find the mask, first determine how many nodes you will have in your network, including gateways and other network equipment. Add two to that number and round up to the nearest power of two. For example, you have 31 computers planned. Add two to this, you get 33. The closest power of two is 64, that is, 100 0000. After that, complete all the most significant bits with ones. Receive mask 1111 1111. 1111 1111. 1111 1111. 1100 0000, which is 255.255.255.192 in decimal. In a network with such a mask, you can get 62 different IP addresses that are not reserved in the standard.

Recommended: