IP and Subnet masks

Source: Internet
Author: User

On the Internet to find a special detailed introduction, write the special fine, everyone slowly look down:

As we all know, IP is made up of four numbers, here, let's first look at the Class 3 commonly used IP
Class A IP segment 0.0.0.0 to 127.255.255.255
Class B IP segment 128.0.0.0 to 191.255.255.255
Class C IP segment 192.0.0.0 to 223.255.255.255
The default subnet mask assigned by XP is only 255 or 0 per segment
Class A default subnet mask 255.0.0.0 a subnet can hold up to more than 16.77 million computers
Default subnet mask for Class B 255.255.0.0 a subnet can hold up to 60,000 computers
Default subnet mask for Class C 255.255.255.0 a subnet can hold up to 254 computers
I used to think that in order to put some computers in the same network segment, as long as the first three paragraphs of the IP can be, today, I know I was wrong. If I say this, a subnet can only hold 254 computers? It's a bit of a joke. Let's take a look at it in detail.
To be in the same network segment, as long as the network identity is the same, then how to look at the network identity it? The first thing to do is to convert each segment of the IP to binary. (Some say I won't convert yes, it doesn't matter, we use Windows to bring a calculator on the line.) Open Calculator, point to view > scientific type, enter decimal number, then click "Binary" This single point, you can switch to binary. )
Switch the netmask to binary, and we'll find that all the subnet masks are made up of a string of contiguous 1 and a string of contiguous 0 (altogether 4 segments, 8 bits per segment, total 32 digits).
255.0.0.0 11111111.00000000.00000000.00000000
255.255.0.0 11111111.11111111.00000000.00000000
255.255.255.0 11111111.11111111.11111111.00000000
This is the A/B/C three types of default subnet mask binary form, in fact, there are a lot of seed netmask, as long as a series of 1 consecutive and a string of 0 can be (each segment is 8 bits). such as 11111111.11111111.11111000.00000000, this is also a legitimate subnet mask. The subnet mask determines the number of computers in a subnet, and the computer formula is 2 M-times, where we can see how many of the 0 are behind. such as 255.255.255.0 converted to binary, that is 11111111.11111111.11111111.00000000, followed by 8 0, that M is 8,255.255.255.0 this subnet mask can accommodate 2 of the 8 (Taiwan) computer, that is 256 units, but there are two I P is not available, that is, the last paragraph can not be 0 and 255, minus the two, is 254 units. Let's do one more.
255.255.248.0 How many computers can this subnet mask hold?
Calculation method:
Convert it to a binary four-digit number (each paragraph if 8 bits, if 0, can be written as 8 0, that is, 00000000)
11111111.1111111.11111000.00000000
Then, after counting a few 0, altogether there are 11, that is 2 11 square, equals 2048, this subnet mask can accommodate up to 2048 computers.
The maximum number of computers a subnet can hold you're going to forget it, let's get a problem with the inverse algorithm.
A company has 530 computers, the formation of a peer LAN, the subnet mask to set how much appropriate?
First of all, undoubtedly, 530 computers with Class B IP most suitable (class A needless to say, too much, C class is not enough, certainly is B class), but the class B default Subnet mask is 255.255.0.0, can accommodate 60,000 computers, obviously not quite suitable, that subnet mask set how much appropriate? Let's set out a formula first.
2 m-Time Square =560
First, we determine that 2 must be greater than 8 square, because we know that 2 of 8 is 256, that is, the number of Class C IP maximum capacity of the computer, we from 9 times a trial 2 9 is 512, less than 560, 2 10 is 1024, it seems 2 of the most suitable. The subnet mask consists of a total of 32 bits, has determined that the next 10 bits is 0, the front 22 bits is 1, the most appropriate subnet mask is: 11111111.11111111.11111100.00000000, converted to 10, that is 255.255.252.0.
Assigning and calculating subnet masks you will, now, let's take a look at the network segment of the IP address.
Believe that a lot of people and I like, think IP as long as the first three paragraphs of the same, is in the same network segment, in fact, not so, the same, I kind of IP every paragraph into a binary number, here take ip:192.168.0.1, subnet mask: 255.255.255.0 do experiment bar.
192.168.0.1
11000000.10101000.00000000.00000001
(Here is the same as the subnet mask, 8 bits per paragraph, less than 8 bits, the front plus 0 is padded.) )
IP 11000000.10101000.00000000.00000001
Subnet Mask 11111111.11111111.11111111.00000000
Here, let's talk about exactly how to calculate the same network segment.
Want to be in the same network segment, must do network identity is same, that network identification how to calculate? All types of IP network identification algorithms are not the same. Class A, only the first paragraph. Class B, only the first to second paragraph is counted. Class C, calculate tertiary segment.
The algorithm simply puts the IP and subnet mask on each digit and is available.
and methods: 0 and 1=0 0 and 0=0 1 and 1=1
such as: and 192.168.0.1,255.255.255.0, first converted to binary, then and each bit
IP 11000000.10101000.00000000.00000001
Subnet Mask 11111111.11111111.11111111.00000000
Draw and result 11000000.10101000.00000000.00000000
Convert to Decimal 192.168.0.0, which is the network identifier,
The subnet mask is then reversed, which is 00000000.00000000.00000000.11111111, with the IP and
The result is 00000000.00000000.00000000.00000001, converted to 10 binary, i.e. 0.0.0.1,
This 0.0.0.1 is the host identity. To be in the same network segment, you must do the same as the network identity.
Let's take a look at this. Class B IP with default subnet mask
such as ip:188.188.0.111,188.188.5.222, the subnet mask is set to 255.255.254.0, in the same network segment?
Convert these to binary first
188.188.0.111 10111100.10111100.00000000.01101111
188.188.5.222 10111100.10111100.00000101.11011010
255.255.254.0 11111111.11111111.11111110.00000000
Separate and, get
10111100.10111100.00000000.00000000
10111100.10111100.00000100.00000000
The network identity is different, that is, not the same network segment.
Judging is not in the same network segment, you will, below, we have to point to the actual.
A company has 530 computers, a peer local area network, subnet mask and IP set how much is the most appropriate?
The subnet mask is not said, the result of the previous calculation came to 11111111.11111111.11111100.00000000, which is 255.255.252.0
We now want to determine how IP is allocated, first of all, select a Class B IP segment, here to choose 188.188.x.x Bar
Thus, the first two paragraphs of IP are determined, the key is to determine the third paragraph, as long as the network identity is the same. Let's start by determining the network number. (We are in the net mask of 1 and the IP in the right up, 0 and * corresponds to, as follows:)
255.255.252.0 11111111.11111111.11111100.00000000
188.188.x.x 10111100.10111100.?????? **.********
Network identity 10111100.10111100.?????? 00.00000000
It can be easily filled out (only 0 and 1 fill, not necessarily all 0 and 1), we use the full fill 0, * anywhere, so, our IP is
10111100.10111100.000000**.********, a total of 530 computers, IP of the last paragraph 1~254 can be divided into 254 computers, 530/ 254=2.086, the use of 1 method, an integer 3, so that we determine the third paragraph of the IP to be divided into three different numbers, that is, the 000000** in the * * Fill three times, can only fill 1 and 0, and each time the number is not the same, as for what to fill, as we have, such as 00000001,00000010,00000011, converted into binary, respectively, is three-way, so, the third paragraph is also determined, so, You can divide the IP into 188.188.1.y,188.188.2.y,188.188.3.y,y, as long as within the 1~254 range, and the 530 computers each and each IP is not the same, you can.
Some people may say, since the algorithm is so troublesome, simply use Class A IP and Class A default subnet mask, I want to tell you, because the Class A IP and Class A default subnet mask host number is too large, this is undoubtedly a needle in the haystack, if at the same time the local network access is too frequent, too large, will affect efficiency, so, It is best to set your own IP and subnet mask ^_^

IP and Subnet masks

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.