The background,
When conducting business cooperation with foreign companies, we need to provide our company's export IP to open the white list. To find the company operation and maintenance to ask the export IP, got a reply: XX.xx.xx.128/25 this network segment more than one hundred IP are our IP heart:?? 100 + IP? What does this 25 mean? I think I mistook 255 for 25. Xx.xx.xx.128 to XX.xx.xx.255 this is almost more than 100!! But after all, it is for outside companies, or carry forward the spirit of asking! Asked what the 25 was, o&M replied that it was a subnet mask. Fortunately, I asked one more sentence and found a knowledge blind area, so I carefully understood the basic knowledge of the network, and sorted out and recorded it.Copy the code
Second, the IP
1. What is the IP
Official definition: AN IP address is a way of addressing a host on the Internet, also known as an Internet protocol address. An IP address is a unified address format provided by the IP protocol. It allocates a logical address to each network and each host on the Internet to shield physical address differences. Common IP addresses are classified into IPv4 and IPv6. This is mainly about IPv4.
2.IP representation
An IP address is a 32-bit binary number. For easy memory, it is usually divided into four “8-bit binary numbers” and represented in dotted decimal notation as A.B.C.D, where a,b,c, and d are decimal integers ranging from 0 to 255.
3.IP address classification
Class A reserved for government agencies (0.0.0.0 to 127.255.255.255)
Class B assigned to medium-sized companies (128.0.0.0 to 191.255.255.255)
Class C allocated to anyone who needs it (192.0.0.0 to 223.255.255.255)
Class D for multicast (224.0.0.0– 239.255.255.255)
Class E for experiment (240.0.0.0– 247.255.255.255)
In class A, B, and C, IP address = network address + host address, while class D and E do not distinguish network address and host address
Special note:
(1) class A 10.x.x.x is private; X.X.X is reserved
(2) 172.16.0.0 to 172.31.255.255 in class B are private addresses
(3) 192.168.x. x in class C is a private address
4. Network address and host address
A network address can be simply understood as a network segment
The host address is the address of the different devices in the network segment
So given an IP address, how do we get the network address and the host address?
This is where the subnet mask comes in!
3. Subnet mask
1. The role
A subnet mask is used to divide an IP address into a network address and a host address.
(A common mask consists of a series of 1’s and a series of 0’s, but alternate 1’s and 0’s are also possible.)
The default assigned subnet mask is 255 or 0 for each segment
- The default subnet mask of class A is 255.0.0.0
- The default subnet mask of class B is 255.255.0.0
- The default subnet mask of class C is 255.255.255.0
Principle 2.
A subnet mask is a 32-bit address like an IP address. You can calculate the IP address and the subnet mask to obtain the network address.
Ex. :
The IP address is 192.168.10.2 and the subnet mask is 255.255.255.240. Convert decimal to binary first: IP address: 11000000 10101000 00001010 00000010 Subnet mask: 11111111 11111111 11110000 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - 11000000, 10101000, 00001010, 00000000 was the network identity, however, as the 192.168.10.0, host identification of 2.Copy the code
3. Different representations of masks
Having said that the subnet mask is also a 32-bit address, how to convert the beginning of the 25?
25 means the network number is 25, which means 25 consecutive ones, and then the rest are filled out with zeros
That is 11111111 11111111 11111111 10000000
4. Other information included
Or take this information as an example: XX.xx.xx.128/25, what else can we get?
(1) Host ID: Host ID + network ID =32, 32-25=7
(2) Network address: when the 7-digit host number is all 0, that is xx.xx.XX.128
(3) Broadcast address: when all the 7-bit host numbers are 1, that is xx.xx.xx.255
(4) Number of available addresses: there are 2^7 kinds of results for 7-bit host numbers, but the network address and broadcast address should be removed, that is: 2^7-2=126(this is also the operation of more than 100 IP addresses)
There are tools on the web that can directly help you calculate this information, as long as you understand the principles.
Four, the last
Don’t pretend to know what you don’t know. It doesn’t hurt to ask.