Computer network principle IP calculation summary

foreword

I have been picking up computer network principles for the past few days, but found that many IP calculation topics can’t be calculated, and then Baidu (Google) couldn’t find a better article for a long time, and it took me almost 3-4 hours to solve it. Come out, so just write an article to summarize it!

start

Before you start, you need to understand the basic concept of IP address

Basic concepts of IP addresses

1. IP address range, you need to know what type of IP address it is

A 0.0.0.0 - 127.255.255.255
B 128.0.0.0 - 191.255.255.255
C 192.0.0.0 - 223.255.255.255
D 224.0.0.0 - 239.255.255.255
E 240.0.0.0 - 255.255.255.255

2. Combination of IP address, you need to know what combination it is made of

ps: Mainly look at the three types of addresses A, B, and C

They are composed of: network number + host number

3. To know what is and (&) operation, what is or (||) operation

And operation (&): that is, both sides must be 1 to get 1

1 1 = 1、1 0 = 0、0 1 = 0、0 0 = 0

Or operation (||): that is, if one of the two parties is 1, then 1 is obtained

1 1 = 1、1 0 = 1、0 1 = 1、0 0 = 0

4. Know what 11111111 stands for

255.255.255.255   =  11111111 11111111 11111111 11111111

So 8 add up = 255

1     1      1     1    1    1    1    1

128  64  32  16    8    4    2    1

topic one

It is known that the IP address of a host in a certain subnet is: 203.123.1.135, and the subnet mask is: 255.255.255.192.

(1). What is the subnet address of this subnet?

(2). What is the direct broadcast address of this subnet?

(3). What is the number of IP addresses in this subnet?

(4). What is the range of IP addresses that can be allocated?

(1). Subnet address = IP address and (&) operation subnet mask

203.123.1.135      11001011 01111011 00000001 10000111

255.255.255.192  11111111 11111111 11111111 11000000

203.123.1.128     11001011 01111011 00000001 10000000

Subnet address: 203.123.1.128

(2).Broadcast address = IP address or (||) operation The inverse of the subnet mask

The inverse code of the subnet mask: it is to turn all 1 into 0, and 0 into 1

255.255.255.192 11111111 11111111 11111111 11000000

0.0.0.127            00000000 0000000 0000000 00111111

Formal calculation: P address or (||) operation The inverse code of the subnet mask

203.123.1.128   11001011 01111011 00000001 10000000

0.0.0.127           000000 0000000 0000000 00111111

203.123.1.191   11001011 01111011 00000001 10111111

Broadcast address: 203.123.1.191

(3). Number of IP addresses = 2^host number (such as: 2^5)

Problem-solving idea: You need to memorize the network number and host number of the above-mentioned A, B, and C addresses, and then check how many 1s there are in the subnet mask, and then compare the network numbers. If there are fewer, use the host number to supplement. The rest of the host number is the number of IP addresses.

The slave host IP (203.123.1.135) is a class C address, the network number of the class C address is 24 bits, and the host number is 8 bits

Subnet mask to binary: 11111111 11111111 11111111 11000000, there are 26 1s, so: the subnet mask number is 26 bits

Subnet mask number - network number = 2, so the network number needs to borrow 2 from the host number, so 8-2=6, the host number is 6 digits

So the number of IP addresses = 2^6= 2*2*2*2*2*2 = 64

Number of IP addresses: 64

(4). IP assignable range = subnet address (+1) - broadcast address (-1)

Assignable IP address range: 203.123.1.129 - 203.123.1.190

Topic two

Known IP network 202.112.14.0/26

(1). Write down the number of its assignable IP addresses

(2). Suppose it is divided into three subnets, the first subnet has no less than 30 assignable IP addresses, the second subnet has no less than 14 assignable IP addresses, and the third subnet has no less than 14 assignable IP addresses. There are no less than 10 IP addresses, write their subnet address, subnet mask, and broadcast address respectively

(1). Number of IP addresses = 2^host number (such as: 2^5)

First write out the subnet mask , from 202.112.14.0/26, we know that the subnet mask number is 26 bits (IP/26: / is followed by the subnet mask number)

11111111 11111111 11111111 11000000

Subnet mask: 255.255.255.192

From the IP address (202.112.14.0), it is known that it is a class C address, the network number is 24 digits, the host number is 8 digits, the subnet mask number is 26 digits (see above), subnet mask number-network number= 2. The network number needs to borrow 2 from the host number, and the host number is 8-2=6 digits

So the number of IP addresses = 2^6= 2*2*2*2*2*2=64

The number of IP addresses is 64

(2).

No less than 30 problem-solving ideas

From the above we know how to calculate the number of IP addresses, let’s infer other cases from one instance, first calculate the lowest number of IP addresses, then look at the number of host numbers, and then deduce the subnet mask number, and then reverse the subnet address according to the subnet mask Perform an OR operation to obtain the broadcast address

2*2*2*2*2 = 32

2^5

 Therefore, the host number is 5 digits, the network number is 24 digits, and the formula for calculating the subnet mask number is: original network number + (original host number - current host number)

24 + (8-5) = 24+3 = 27, so the subnet mask number is 27 bits

11111111 11111111 11111111 11100000

So the following result is obtained:

Subnet mask: 255.255.255.224

Subnet address: 202.112.14.0/27

Broadcast address = subnet mask inversion and subnet address for OR operation

11111111 11111111 11111111 11100000

00000000 00000000 00000000 00011111

Inverse subnet mask: 0.0.0.31

202.112.14.0   11001010 01110000 00001110 00000000

0.0.0.31           00000000 00000000 00000000 00011111

202.112.14.31 11001010 01110000 00001110 00011111

Subnet mask: 255.255.255.240

Subnet address: 202.112.14.0/28

Broadcast address: 202.112.14.31

No less than 14 problem-solving ideas

The logic of solving the problem is the same as above, but   the subnet address = the broadcast address of the above problem + 1

2*2*2*2 = 16

2^4

24+(8-4) = 28

11111111 11111111 11111111 11110000

Subnet mask: 255.255.255.240

Subnet address: 202.112.14.32/28

Inverse subnet mask:

11111111 11111111 11111111 11110000

00000000 00000000 00000000 00001111

0.0.0.15

Broadcast address:

202.112.14.32 11001010 01110000 00001110 00100000

0.0.0.15 00000000 00000000 00000000 00001111

202.112.14.47 11001010 01110000 00001110 00101111

Subnet mask: 255.255.255.240

Subnet address: 202.112.14.32/28

Broadcast address: 202.112.14.47

No less than 10 problem-solving ideas

The logic of solving the problem is the same as above, but   the subnet address = the broadcast address of the above problem + 1

2*2*2*2=16

2^4

24+(8-4) = 28

11111111 11111111 11111111 11110000

Subnet mask: 255.255.255.240

Subnet address: 202.112.14.48/28

Inverse subnet mask:

11111111 11111111 11111111 11110000

00000000 00000000 00000000 00001111

0.0.0.15

Broadcast address:

202.112.14.48 11001010 01110000 00001110 00110000

0.0.0.15 00000000 00000000 00000000 00001111

202.112.14.63 11001010 01110000 00001110 00111111

Subnet mask: 255.255.255.240

Subnet address: 202.112.14.48/28

Broadcast address: 202.112.14.63

Summarize

Did you see this and suddenly feel that solving the problem is very simple, hhh

Guess you like

Origin blog.csdn.net/echo_Ae/article/details/124005167