Subnet Mask resolution

Source: Internet
Author: User

You must know something about the IP address, right? We know that the TCP/IP protocol that is widely used in the Internet is to differentiate between different hosts by using IPs. If you've ever had a TCP/IP protocol set up, then you're bound to encounter the term subnet mask (Subnet mask), so do you know what a subnet mask is? What role does it have?

We know that the IP address is a 4-byte (total 32bit) number, divided into 4 segments, 8 bits per segment, and periods separated by a period. For ease of expression and recognition, the IP address is expressed in decimal form such as 210.52.207.2, each paragraph can represent the maximum number of decimal not more than 255. The IP address consists of two parts, the network number (Netgwork ID) and the host ID. The network number identifies a subnet on the internet, and the host number identifies a host in the subnet. The decomposition of the Internet address into two domains brings an important advantage: When an IP packet arrives from one network to another, the selection path can be based on the network instead of the host. This advantage is particularly noticeable in large networks because the routing table stores only network information rather than host information, which can greatly simplify the routing table. The IP address is divided into a, B, and C three classes based on the number of network and host numbers:

Class A IP address: a 7-bit (bit) to identify the network number, 24-bit identification of the host number, the first one is "0", that is, a class of address the value between 1~126. A Class A address is typically provided for large networks, with a total of only 126 possible class A networks, each of which can connect up to 16777214 hosts per Class A network.

Class B IP Address: Use 14 bits to identify the network number, 16 bits to identify the host number, and the preceding two bits are "10". The first paragraph of the Class B address is between 128~191, and the first and second paragraphs together represent the network number. Class B addresses are available for medium-sized networks, with around 16,000 class B networks worldwide, and each class B network can connect up to 65534 hosts.

Class C IP Address: Use 21 bits to identify the network number, 8 bits to identify the host number, the front three bits are "110". The first paragraph of the Class C address has a value between 192~223, the first, second, and third paragraphs together to represent the network number. The last segment identifies the host number on the network. Class C addresses are suitable for small networks such as campus networks, and each class C network can have up to 254 hosts.

From the above introduction we know that the IP address is the network number and host number to indicate the host on the network, only in a network number under the computer can be "direct" interoperability, different network number of the computer to be through the gateway to exchange. But such a division appears and is very inflexible in some cases. For this reason, the IP network is also allowed to be partitioned into smaller networks called subnets (Subnet), which creates a subnet mask. The function of the subnet mask is to determine whether any two IP addresses belong to the same subnet, when only the computer on the same subnet can be "directly" interoperable. So how do you determine the subnet mask?

Referring to the IP address sub-network number and host number, to divide a network into multiple subnets, so the network number will occupy the original master, for example, for a class C address, it uses 21 bits to identify the network number, to divide it into 2 subnets will need to occupy 1 bits of the original host identity bit. At this point the network number bit becomes 22 bits and the host label becomes 7 bits. Similarly borrowing 2 host bits can divide a class C network into 4 subnets ... How does the computer know if the network is divided into subnets? This can be seen from the subnet mask. The subnet mask is as 32bit as the IP address, and the subnet mask is determined by using "1" for all corresponding bits that identify the network number in the IP address, and the bits corresponding to the host number are "0". such as a class C IP address divided into 2 subnets with 22 bits to identify the network number, its subnet mask is: 11111111 11111111 11111111 10000000 is 255.255.255.128. So we can see that the default subnet mask for Class A addresses is the 255.0.0.0,b class of 255.255.0.0,c class 255.255.255.0. The following table is the Class C address subnetting and related subnet masks:

Number of subnet-subnet-netmask hosts available hosts

1 255.255.255.128 128 126

2 255.255.255.192 64 62

3 255.255.255.224 32 30

4 255.255.255.240 16 14

5 255.255.255.248 8 6

6 255.255.255.252 4 2

You may notice that the table above is divided by the number of hosts and the number of hosts available two, which is why? Because, when all host bits of the address are "0", the address is a line (or subnet) address and a broadcast address when all host bits are "1".

We can also use a variable-length mask (VLSM), which means that a network can be configured with a different mask. This is done to make it easier to divide a network into multiple subnets. In the absence of VLSM, a network can use only one subnet mask, which limits the number of hosts in the given subnet number condition. For example, you are assigned a class C address that has a network number of 192.168.10.0, and you now need to divide it into three subnets, one of which has 100 hosts, and two hosts for the rest of the seven subnets. We know that a class C address has 254 available addresses, so how do you choose a subnet mask? From the table above, we find that this problem cannot be solved when we use a subnet mask in all subnets. At this point vlsm comes in handy, we can use the 255.255.255.128 mask on the subnet of 100 hosts, which can use 192.168.10.0 to 192.168.10.127 128 IP addresses, where the host number is 126. We'll take the rest of the 192.168.10.128 to 192.168.10.255. The 128 IP addresses are divided into two subnets with a subnet mask of 255.255.255.192. The address of one of the subnets is from 192.168.10.128 to 192.168.10.191, and the address of the other subnet is from 192.168.10.192 to 192.168.10.255. The subnet mask for 255.255.255.192 has 62 available host addresses for each subnet, which is required. It can be seen that the reasonable use of the subnet mask can make the IP address easier to manage and control.

Subnet Mask resolution

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.