The role and significance of subnet mask

Source: Internet
Author: User

When I used to configure a static IP address for a linked router, I only knew to change the subnet mask to 255.255.255.0. Just change the first three digits of the IP address and the last digit of the gateway to an unused IP address, I have never understood what the subnet mask means. Before I took the course "computer network", I heard the teacher say that I didn't listen carefully. I only knew the network address and host address.

I read "TCP/IP details" today to understand the subnet mask. The following is a summary.

The subnet mask is actually used to split the network. For example, A Class A address can accommodate 2 ^ 24-2 hosts. Generally, it is impossible for an organization to use so many addresses, this will inevitably cause waste. However, we can use A subnet mask to divide A Class A address into multiple subnets. Based on the IP address and subnet mask, we can determine whether the host under the same network address is in the same network segment.

The subnet mask divides the IP address into three parts: network number, subnet number, and host number. The network number can be obtained directly from the IP address, and the subnet number is the IP address and subnet mask minus the network number. The remaining part is the host number. you can determine whether the two hosts are in the same network segment based on the network number and subnet number.

If host A's Ip address is 192.168.1.2, host B's Ip address is 192.168.1.126, and the subnet mask is always too large.

Convert to hexadecimal as follows:

Machine A: 11000000 10101000 00000001 00000010 & Computation: 11000000 10101000 00000001

Machine B: 11000000 10101000 00000001 01111110 & Computation: 11000000 10101000 00000001

Mask: 11111111 11111111 11111111 11100000

& The results obtained after calculation are different, so we can conclude that machine A and Machine B are not in the same network segment.

When server A sends data to server B, the IP address and subnet mask of server B are first calculated to check whether the IP address and subnet mask of server B are in the same network segment, if not within the same CIDR block, the data is sent to the gateway, and the same CIDR block can communicate directly at the data link layer.

The role and significance 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.