Simple Calculation of subnet mask

Source: Internet
Author: User

I recently reviewed some network knowledge and saw the subnet mask. The subnet mask is encountered in actual use and tests, but the calculation of the subnet mask involves binary conversion, it is troublesome. This time, I saw a simple calculation method for the subnet mask on the network and forum. For how to calculate the subnet mask and vlsm (variable long mask), see the Introduction to subnet mask.

Take the class C network as an example.
If you want to divide two sub-network segments, use 256/2 = 128 to obtain that each subnet has 128 IP addresses, and use 256 minus the number of addresses of each subnet (256-128 = 128 ), the subnet mask is 255.255.255.255.128.
Divided into 4 CIDR blocks, 256/4 = 64, each subnet has 64 addresses, 256-64 = 192, and the subnet mask is 255.255.255.192.
Divided into 8 CIDR blocks, 256/8 = 32, 32 addresses for each subnet, 256-32 = 224, And the subnet mask is too large.
That is, the last digit of the subnet mask is calculated by subtracting 256 from the number of addresses of each subnet.

======================================
In practical applications, for example, if there are 13 hosts in total, it is a waste to use 255.255.255.0 when setting the subnet mask. We will set vlsm.
13 <4 to the power of 2 (16), that is, use 16 as the calculation base, 256-16 = 240 (Note: instead of 256-13), obtain the subnet mask 255.255.255.255.255.240
The number of addresses in the subnet that is subtracted by 256 must be the Npower of 2 (n from 0 to 10 ).
If the number of hosts is 13, and the number of unavailable network and broadcast IP addresses at both ends is 15 in total, select a 2 n value that is larger than 15 and closest to 15, that is, 16.
If the host is 50, then 52 <2's 6th power (64), 256-64 = 192, subnet mask limit 192

The following values are calculated from 0 to 10 power of 2:
1 2 4 8 16 32 64 128 256 512


Appendix list of common mask bits and subcode masks: number of IP addresses contained in each CIDR Block
32----------255. 255. 255. 255 + 1 = 256
31 ---------- 255. 255. 255. 254 + 2 = 256
30 ---------- 255. 255. 255. 252 + 4 = 256
29 ---------- 255. 255. 255. 248 + 8 = 256
28 ---------- 255. 255. 255. 240 16
27 ---------- 255. 255. 255. 224 32
26 ---------- 255. 255. 255. 192 64
25 ---------- 255. 255. 255. 128 + 128 = 256
24 ---------- 255. 255. 255. 0 256
23 ---------- 255. 255. 254. 0 512
22 ---------- 255. 255. 252. 0 1024
21 ---------- 255. 255. 248. 0
20 ---------- 255. 255. 240. 0
19 ---------- 255. 255. 224. 0
18 ---------- 255. 255. 192. 0
17 ---------- 255. 255. 128. 0
16 ---------- 255. 255. 0. 0

Simple Calculation of subnet mask

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.