About the purpose of the subnet mask

Source: Internet
Author: User

Have always felt that the internet is a magical thing, in the use of the time is also very confusing, you think?

Have you ever wondered: what does a subnet mask do? Why is it as if it can be configured to surf the Internet (of course, now sometimes it seems to be a spell of luck)?

Pre-Knowledge:

  1. Windows View routing commands:

    Route print

  2. The route is mainly divided into: (detail reference: http://blog.csdn.net/ghostly78/article/details/480706)

    @ Default route (if you don't know where to go next, please come with me)

    @ Straight-line segment routing record: When the router receives packets destined for a straight-line segment, this is the case where the interface and gateway of the routing record are the same, or "on the link" under Windows.

    @ Local loop: 127.0.0.0 all addresses in this network segment point to their own machines, and if such a data is received, where should it be sent

    @ Local Host routing: What will be handled when the router receives a packet sent to itself

    @ Local Broadcast routing: How to handle when a router receives a local broadcast to a straight-line segment

    @ Multicast routing: What to do when the router receives a multicast packet

    @ Broadcast routing: What to do when the router receives an absolute broadcast

The text explains:

    1. When we give a network card with an IP address, the system will automatically add a network by (and of course add host routes, broadcast routes).

      For example, assigning an IP address 132.134.91.71/16 to the NIC, and entering route print in cmd, you can see that the target network for the new route is 132.134.0.0. Description 132.134. The IP at the beginning is in the same broadcast domain.


2. Take a look at the next scenario:

The network topology is as follows, figure ugly don't care about these details ~

now Ping pc2 on PC1, the whole situation is as follows:

@pc1 first to see if there is a suitable route, this machine has a destination network 132.134.100 route, but and 132.134.254 does not match, so go to the default route (if you do not know where to go after the road, just follow me! So PC1 set the destination MAC for the packet as the gateway 132.134.100.254 mac.

@ Now the data reaches the gateway, the gateway to see the destination IP is 132.134.254.100, so look at their own routing table, if there is a target host for 132.134.254.100 host route, it will send the data to PC2; The gateway will send the data to the Internel network (if the private address should be discarded), the data will no longer reach PC2, so the PC1 will show that the host is not reachable ~

What happens if you set the subnet mask of PC1 to 16?

@pc1 or first look at the routing table, find a target network for the 132.134.0.0 of the direct network segment routing , indicating that both in the same networks, and then directly to the data to PC2.

@ data to PC2,PC2 will send the response result to PC1. PC2 first looks at the routing table and finds that there are no proper routes (the straight-link segment is routed to 132.134.254.0) and sends the data to the default gateway.

@ Now the data reaches the gateway, the gateway to see the destination IP is 132.134.100.100, so look at their own routing table, if there is a target host for 132.134.100.100 host route, it will send the data to PC1; The gateway will send the data to the Internel network (if the private address should be discarded), the data will no longer reach pc1, so the result of the ping is still not through ~

only the PC1 and PC2 subnet are set to 16 o'clock, both to bypass the Gateway direct communication, the entire process is the core of the action is the routing table query matching!!!

Remember so much first, hope can be a start. It's a magical thing----internel:)


Think: After looking at the above content, will there be such a misunderstanding: the smaller the subnet mask the better?

Specific explanation I haven't thought well, everyone help answer it, haha

About the purpose of the 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.