Subnet Mask and IP address

Source: Internet
Author: User
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.

So you may ask: what if my subnet mask is not 255.255.255.0? You can also do this. Assume that your subnet mask is 255.255.128.0.

Then the first two IP addresses in your lan must be fixed (What, why? Do you understand the above? · # ¥)

In this way, you can follow the calculation below to see how many machines can be deployed in the same sub-network.

1. Decimal 128 = binary 1000 0000

2. the IP address and subnet mask must be used for and operations.

3,
I P address 0001000000001001.1 *******.********
Subnet Mask 11111111.111111.0000000.00000000
And Operation

000000000001001001.0000000.00000000
Converted to decimal:

16. 73. 128. 0

4. We can see that the available IP addresses on the Intranet are:

000000000001001001.0000000.00000000
To
0001000000001001001.11111111.111111

5. Convert to decimal:

16.73.128.0 to 16.73.20.255

6. 0 and 255 are generally used internally for special purposes. Usually not used.

7. The final result is as follows: all available IP addresses in our unit are:
192.168.128.1-192.168.128.254
192.168.129.1-192.168.129.254
192.168.130.1-192.168.130.254
192.168.131.1-192.168.131.254
.............
192.168.139.1-192.168.139.254
192.168.140.1-192.168.140.254
192.168.141.1-192.168.141.254
192.168.142.1-192.168.142.254
192.168.143.1-192.168.143.254
.............
192.168.254.1-192.168.254.254
192.168.255.1-192.168.255.254

8. The total number is (255-128 + 1) * (254-1 + 1) = 128*254 = 32512

Faint !!!! @#! @ We can't afford to buy so many machines after buying all our companies! · ¥! ·#

9. Check whether the result is correct.

(1) set the IP address to 192.168.128.1

Ping 192.168.129.233 and pass the test

Visit http: // 192.168.129.233 to display the Home Page

(2) set the IP address to 192.168.255.254

Ping 192.168.129.233 and pass the test

Visit http: // 192.168.129.233 to display the Home Page

10. Conclusion

The above proves that our conclusion is correct. Now you can check the number of machines in your subnet.

2017100000000128
Decomposition:
11111111.111111.1111111111.000000
Therefore, the IP address of your internal network can only be
XXXXXXXX. XXXXXXXX. xxxxxxxx.0 ???????
To
XXXXXXXX. XXXXXXXX. xxxxxxxx00001111 111

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.