Subnet Mask entry

Source: Internet
Author: User


The primary function of the subnet mask is to inform the network device which part of a specific IP Address Contains the network address and subnet address and which part is the host address. The routing device of the network can make a routing addressing decision by identifying the network number and subnet number of the destination address. The host part of the IP address is not involved in the routing addressing operation of the router, only an interface that uniquely identifies a network device in a CIDR block.

Originally, if only the primary class addresses A, B, and C are used in the network system, and the primary class addresses are not divided into subnets or summarized, the network device can determine which primary network belongs to A, B, and C based on the value range of the first byte of the IP address, and then determine the network part and host part of the IP address, the subnet mask is not needed.

However, the Classless Inter-Domain Routing and CIDR technologies (Classless Inter-Domain Routing) are used to divide the primary class Networks A, B, and C) when CIDR blocks are summarized, the network and subnet of IP addresses can be correctly differentiated from those of hosts. Therefore, you must rely on the help of the subnet mask.

The subnet mask uses the same address format as the IP address. The subnet mask of 1 corresponds to the network and subnet of the IP address, and the subnet mask of 0 corresponds to the host of the IP address. After the subnet mask and IP address are used as "and" operations, the host part of the IP address will be discarded, and the remaining are the network address and subnet address. For example, the destination IP address of an IP group is 10.2.2.1. If the subnet mask is 255.255.255.0, the operation "and" is calculated as 10.2.2.0, the network device considers the IP address's network number and subnet number as 10.2.2.0. The subnet mask is used to determine whether the IP addresses of any two computers belong to the same subnetwork.

The simplest understanding is that after the IP address AND subnet mask of the two computers perform the AND operation, if the result is the same, the two computers are on the same sub-network and can communicate directly. That's simple.

See the following example:

Computing Demonstration: aa

I P address 192.168.0.1

Subnet Mask 255.255.255.0

AND Operation

Convert to binary for calculation:

I P address 1102.16.10101000.00000000.00000001

Subnet Mask 11111111.111111.1111111111.00000000

AND Operation

111000000.10101000.00000000.00000000

Converted to decimal:

192.168.0.0

Operation demonstration 2:

I P address 192.168.0.254

Subnet Mask 255.255.255.0

AND Operation

Convert to binary for calculation:

I P address 1102.16.10101000.20.2.16.11111110

Subnet Mask 11111111.111111.1111111111.00000000

AND Operation

111000000.10101000.00000000.00000000

Converted to decimal:

192.168.0.0

Computing demonstration 3:

I P address 192.168.0.4

Subnet Mask 255.255.255.0

AND Operation

Convert to binary for calculation:

I P address 1102.16.10101000.00000000.00000100

Subnet Mask 11111111.111111.1111111111.00000000

AND Operation

111000000.10101000.00000000.00000000

Converted to decimal:

192.168.0.0

After the AND operation on the IP addresses AND subnet masks of the three groups of computers, we can see that the operation results are the same. All are 192.168.0.0

Therefore, the computer will regard the three computers as the same sub-network and then communicate with each other. The proxy server used by my current organization is planned as the internal network.

Maybe you have to ask, how many IP addresses are available for such subnet masks? You can calculate this.

According to the above, we can see that the IP address inside the LAN is defined by ourselves (of course, it is the same as other IP addresses), which is determined by the subnet mask through the analysis of 255.255.255.0. It can be concluded that:

The first three IP addresses can only be fixed to 192.168.0, so only the last one is left. Obviously, an IP Address can only have (Power 8-1 of 2), that is, 256-1 = 255. Generally, the last digit is 0 or 255.

However, this division is a waste of addresses, so a new algorithm called VLSM (variable long mask) was introduced later.

If there are 50 machines in total, the class C address must be used. However, if you use Class C, you can use 253 hosts for each network segment, but now you only have 50 hosts. Isn't that a waste of 200 hosts? However, if VLSM is used, it is different.

If it is a static mask, the class C address is 255.255.255.0.

To the power of <2, convert it to decimal form 64. Therefore, VLSM is just 64

Example 1: IP: 192.168.0.1

SubstMask: Too Many 64

Convert to binary 11000000.10101000.00000000.00000001

11111111.111111.20..000000

AND operations

111000000.10101000.00000000.00000000

Convert to decimal 192.168.0.0

Example 2: 192.168.0.50

SubstMask: Too Many 64

Convert to binary 11000000.10101000.00000000.00110010

11111111.111111.1111111111.0000000

AND operations

111000000.10101000.00000000.00000000

Convert to decimal 192.168.0.0

The two addresses are in the same CIDR block.

Let's look at it again:

Example 3: IP Address: 192.168.0.65

SubstMask: Too Many 64

Convert to binary 11000000.10101000.000000000000000001

111000000.10101000.000000000000000000

AND operations

1110000000.10101000.20.00000000000

Convert to decimal 192.168.0.64

Split !! That's easy!

The subnet mask cannot exist independently. It must be used together with the IP address. The subnet mask has only one function, namely dividing an IP address into a network address and a host address.

The subnet mask must be set according to certain rules. Same as the IP address, the subnet mask length is also 32 bits, the network bits on the left are represented by the binary number "1", and the host bits on the right are represented by the binary number "0. As shown in the following figure, the IP address is "192.168.1.1" and the subnet mask is "255.255.255.0. Among them, "1" has 24, representing the corresponding 24-bit IP address on the left is the network number; "0" has 8, the eight-digit host number on the right of the corresponding IP address. In this way, the subnet mask determines the network number and host number in the 32-bit binary number of an IP address. This is very important for networks using the TCP/IP protocol. Only by using the subnet mask can the relationship between the subnet of a host and other subnets be indicated, so that the network can work normally.

Common Subnet Mask

There are hundreds of subnet masks. Here we only introduce the two most commonly used subnet masks, which are 255.255.255.0 and 255.255.0.0 ".

1. The subnet mask is "255.255.255.0" network: the last digit can be 0 ~ Any change within the range of 255, so 256 IP addresses can be provided. However, the actual number of available IP addresses is 256-2, that is, 254, because the host number cannot be "0" or all "1 ".

2. The subnet mask is a network of "255.255.0.0". The two numbers can be 0 ~ Any change within the range of 255 can provide 2552 IP addresses. However, the actual number of available IP addresses is 2552-2, that is, 65023.

The subnet mask of the IP address is not set arbitrarily. If the subnet mask is set too large, that is, the subnet range is expanded, data from the destination machine in the same subnet as the local machine may be sent according to the subnet routing rule, if the destination machine is considered to be in the same subnet due to incorrect judgment, the data packet will be circulated in the subnetwork until it times out and is discarded, so that the data cannot reach the destination machine correctly, network Transmission Error. If the subnet mask is set too small, the communication between machines in the same subnet will be considered as cross-subnet transmission, and data packets will be handed over to the default gateway for processing, this will inevitably increase the burden on the default gateway, resulting in reduced network efficiency. Therefore, the subnet mask should be set based on the network size.

If a network has no more than 254 computers, you can use "255.255.255.0" as the subnet mask. Currently, most local networks will not exceed this number, therefore, "255.255.255.0" is the most commonly used IP address subnet mask. I have seen that the largest primary and secondary school campus network has more than 1500 computers, and such a LAN can use "255.255.0.0 ".

Default Subnet Mask

In Windows 2000 Server, If you specify an IP address for a network adapter, the system automatically fills in a default subnet mask. This is the subnet mask automatically generated by Windows 2000 Server to save user input time. For example, the default subnet mask of "192.168.x.x" is "255.255.255.0 ". Generally, the IP address can use the default subnet mask.


Based on the above analysis, we recommend that you define the subnet mask for the subnet and instance according to the following steps.

1. The number of subnets to be divided is converted to the m power of 2. If you want to divide 8 subnets, 8 = 23.

2. The power of m to which the number of subnets to be divided is obtained. For example 23, m = 3.

3. Convert the power m defined in the previous step to the m-bit host address in descending order and convert it to decimal. For example, if m is 3, it is 11100000 and converted to decimal 224, which is the final subnet mask. For a class-C network, the subnet mask is 255.255.255.255.255.255.255.255.255.224.0. For a class-B network, the subnet mask is 255.255.255.224.0.0.

Here, there is an equation between the number of subnets and the number of addresses occupied by the Host: 2 m = n. M indicates the number of digits that occupy the host address, and n indicates the number of subnets. Based on these principles, a class C network is divided into four subnets. If the network number we use is 192.9.200, the IP address of the host in the class C network is 192.9.200.1 ~ 192.9.200.254 (because the host addresses of all "0" and "1" have special meanings and are not valid IP addresses), the Network is divided into four parts. follow these steps:

4 = 22, take the power of 22, that is, 2, then the binary is 11, the host address occupies the High Order is 11000000, is converted to decimal 192. In this way, we can determine that the subnet mask is 192.9.200.192, And the IP address ranges of the four subnets are:

Binary decimal

① 11000000 00001001 11001000 00000001 11000000 00001001 11001000 00111110 192.9.200.1

192.9.200.62

② 11000000 00001001 11001000 01000001 11000000 00001001 11001000 01111110 192.9.200.65

192.9.200.126

③ 11000000 00001001 11001000 10000001 11000000 00001001 11001000 10111110 192.9.200.129

192.9.200.190

④ 11000000 00001001 11001000 11000001 11000000 00001001 11001000 11111110 192.9.200.193

192.9.200.254

Here, we will list the conversion tables of the number of network subnets and subnet masks in class A, B, and C for your reference.

 

Class:

 

Number of subnets occupied by the number of digits subnet mask number of hosts in the subnet

2 1255.128.0.08, 388,606

4 22.16192.0.04, 194,302

8 32.16224.0.02, 097,150

16 255.5.240.0.01, 048,574

32 52.16248.0.0524, 286

64 62.16252.0.0262, 142

1287426254.0.0131, 070

128820.00000.065, 534

 

Class B:

 

Number of subnets occupied by the number of digits subnet mask number of hosts in the subnet

2 1255.20.128.0 32,766

4 2100000000192.0 16,382

8 32.1610000224.0 8,190

16 2.165.20.240.0 4,094

32 5100000000248.0 2,046

64 62.16255.252.0 1,022

128700000000254.0 510

2568213255.255.0 254

 

Class C:

 

Number of subnets occupied by the number of digits subnet mask number of hosts in the subnet

2 1255.00000000128 126

4 2nd percentile limit 192 62

8 336600000000000030

16 2.165.20.0000240 14

32 51000000000000248 6

64 61000000000000252 2

Author's "Star8816 column"

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.