Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Hello, thank you for your advice on how to convert IP into integers.
Hello, thank you for your advice on how to convert IP into integers.
A mask is actually a range of address segments.

For example, the mask of 30 is 2 (32-30) = 4.

In other words, there are four IPS belonging to this address segment.

For example, 1.96.0.0/30, then the addresses contained in its IP address segment are 1.96, 0,0 and 4- 1=3 digits, among which there are 4 addresses in itself.

The algorithm of masking is a power of 2. How big is the power? Use 32- mask = power.

For example, the mask of 29 is 2 (32-29) = 2 3 = 8 addresses, that is, the address of 1.96, and 0/29 is the address of 1.96, 0, 0-/kloc-0, 0, 7, which are all converted into integers.

The mask of 12 is 2 (32-12) = 2 20 consecutive addresses.

2 20 consecutive addresses starting from1.96,0,0.