Subnet Mask and IP address operations

Source: Internet
Author: User

Subnet Mask and IP address operation subnet mask: function: divide an IP address into two parts: network address and host address. Once the subnet mask is set, the network address and host address are fixed. Calculation: Convert the IP address and subnet mask to a binary format, and then perform "and" calculation. Obtain the network number, that is, the first address of the subnet. I have been entangled in why this computation is made. Now I want to understand this computation: 1. First, the subnet mask can be obtained based on the number of hosts in the subnet. The number of hosts is expressed in binary, and the number of binary is N. After the 32-bit binary number, the N position 0 and the others are all 1. Obtain the subnet mask. For example, there are 15 hosts in the subnet. 15 = 1011. The binary value is 4 digits, N = 4. The subnet mask is 11111111.1111111111.1111111111111111111111111111111111111111111_1_1_2402: the first IP address of the subnet ~~~~~ IP address + 2 ^ N. 3. Obtain the first IP address of the subnet Based on the IP address of the current machine. The current IP address is the first IP address + n (n <N). To obtain the first IP address of the subnet, use the IP address minus n, directly perform operations with the subnet mask to obtain the first IP address of the desired subnet. No matter whether the problem is simple or not, or whether you understand the right or wrong, you must first straighten out your own ideas. Otherwise, you will be able to suffocate yourself in the case of a simple problem ~~

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.