1, Role of mask
1.1 the mask is 32bit from left to right, with 1 on the left and 0 on the right, and 1 cannot be interrupted
1.2 the mask is used to divide the network part and the host part of the ip address
192.168.1.1 255.255.255.0
11000000 10101000 00000001 00000001 IP address 11111111 11111111 11111111 00000000 Mask 11000000 10101000 00000001 network address 192 168 1 00000001 Host address 1
2, Network address
ip address and mask and result of operation
192.168.1.1 255.255.255.0
11000000 10101000 00000001 00000001 IP address 11111111 11111111 11111111 00000000 Mask And operation: 11000000 10101000 00000001 00000000 network address 192 168 1 0
3, Network segment
3.1 function of network segment
- When the host communicates with other devices, use the network segment to judge whether the target host and itself are in the same network segment. If they are in the same network segment, directly find the target host; If you are not in the same network segment, find your own gateway first
- In the router, when forwarding packets, the router should know which network segment the target host is in, and then check the routing table to find the route of this network segment
- Neither the host nor the router knows the ip mask of other hosts, so they use their own mask and each other's ip to calculate the network segment
3.2 network segment composition
The network segment is composed of network address and mask. If 192.168.1.0/24
1. Calculation 192.168.1.250/24 this ip Network segment of address Network address: 192.168.1.250 And 255.255.255.0 And operation results=192.168.1.0 Network segment=Network address masked: 192.168.1.0/24 2. It's 192.168.1.250/26 this ip Network segment of address Network address: 11000000 10101000 00000001 11111010 And 11111111 11111111 11111111 11000000 Doing and Computing=11000000 10101000 00000001 11000000(192.168.1.192) Network segment=192.168.1.192/26
4, Class (main class) ip
Classified ip includes unicast ip, multicast ip and special ip
4.1 unicast ip address
A Class: First 8 bit Is 0 xxx xxxx Minimum first 8 bit Address 0000 0000 Maximum first 8 bit Address 0111 1111 First paragraph ip Address range 0-127,The special addresses 0 and 127 shall be removed; 0.0.0.0/0 Represents all network segments, and represents the default route in the routing table; one hundred and twenty-seven.x.x.x Is the local loopback address; So the final available range is 1-126 Mask/8 B Class: First 16 bit It's 10 xx xxxx Minimum first 8 bit Address 1000 0000 Maximum first 8 bit Address 1011 1111 First paragraph ip Address range 128-191 Mask/16 C Class: First 24 bit It's 110 x xxxx Minimum first 8 bit Address: 11000000 Maximum first 8 bit Address 1101 1111 First paragraph ip Address range 192-223 Mask/24
4.2 special address
4.2.1 default route 0.0.0.0/0
4.2.2 local loopback address 127.x.x.x
4.2.3 global broadcast address
Full f of layer 2 broadcasting
Layer 3 broadcast address 255
4.2.4 local broadcast address
The network bit address remains unchanged, and the host bit address is all 1
4.2.5 network address
The network bit address remains unchanged, and the host bit address is all 0
5, Private network address
A Class: 10.0-255.0-255.0-255 Or 10.0.0.0/8 B Class: 172.16-31.0-255.0-255 Or 172.16.0.0/12 C Class: 192.168.0-255.0-255 Or 192.168.0.0/16
6, Classless address
6.1 in class addresses, the subnet mask of a group of eight bit s is fixed, either 0 or 255, but the mask without class address is not fixed
Therefore, the 8bit of the classless ip address mask can only be 012819222424825254255
6.2 formula for calculating the number of available host addresses in a network segment
2^(32-Mask)-2 Minus 2 is the subtracted segment address and segment broadcast address
172.16.0.0/16
2^(32-16)-2 = 65536-2 = 65534
6.3 how many network segments are there after VLSM calculation
2^(A-B) A Is the mask after lengthening B Is the class mask before getting longer
How many network segments are there after 172.16.0.0/16 becomes 172.16.0.0/24
2 ^ (24-16) = 2 ^ 8 = 256 network segments
6.4 calculate the information of each subnet after VLSM (network segment, network address, local broadcast address, available ip range)
Calculate the ip address 192.168.1.20/28 and find all subnet information divided by this mask
-
Calculate how many ip addresses this subnet has
2^(32-28)=16 -
Each network segment has 16 ip addresses, so the first ip address of each subnet from 0 to 255 is
16 multiply n = 16 0 = 0 16 1 = 16 16 2 = 32 16 3 = 48 16 4 = 64 16 5 = 80 16 6 = 96 16 7 = 112 16 8 = 128 16 9 = 144 16 10 = 160 16 11 = 176 16 12 = 192 16 13 = 208 16 14 = 224 16 15 = 240 16 16 = 256
- Now that you know the first ip address of each subnet, you know the information of each subnet
Network segment network address Local broadcast address available ip Range 192.168.1.0/28 192.168.1.0 192.168.1.15 192.168.1.1-14 192.168.1.16/28 192.168.1.16 192.168.1.31 192.168.1.17-30 192.168.1.32/28 192.168.1.32 192.168.1.47 192.168.1.33-46 192.168.1.48/28 192.168.1.48 192.168.1.63 192.168.1.49-62 192.168.1.64/28 192.168.1.64 192.168.1.79 192.168.1.65-78 192.168.1.80/28 192.168.1.80 192.168.1.95 192.168.1.81-94 192.168.1.96/28 192.168.1.96 192.168.1.111 192.168.1.97-110 192.168.1.112/28 192.168.1.112 192.168.1.127 192.168.1.113-126 192.168.1.128/28 192.168.1.128 192.168.1.143 192.168.1.127-142 192.168.1.144/28 192.168.1.144 192.168.1.159 192.168.1.145-158 192.168.1.160/28 192.168.1.160 192.168.1.175 192.168.1.161-174 192.168.1.176/28 192.168.1.176 192.168.1.191 192.168.1.177-190 192.168.1.192/28 192.168.1.192 192.168.1.207 192.168.1.193-206 192.168.1.208/28 192.168.1.208 192.168.1.223 192.168.1.209-222 192.168.1.224/28 192.168.1.224 192.168.1.239 192.168.1.225-238 192.168.1.240/28 192.168.1.240 192.168.1.255 192.168.1.241-254
6.5 different subnet masks may not be a network segment, because both parties have their own subnet masks to calculate which network segment the other party is
Are 192.168.1.100/28 and 192.168.1.101/29 a network segment?
- 192.168.1.100/28 judge whether 192.168.1.101 is the same network segment as yourself
ip 192.168.1.100 192.168.1.01100100 Mask 192.168.1.1111 0000 Network segment 192.168.1.96/28 Of this network segment ip Range 192.168.1.97-110 So at 192.168.1.100/28 It seems that he and 192.168.1.101 Is in the same network segment
- 192.168.1.101/29 judge whether 192.168.1.100 is the same network segment as yourself
3. 192.168.1.101/29 this ip Addressable vlsm The number of hosts per subnet is 2^(32-29)=8 individual 4. Therefore, each subnet segment is: 8 multiply n be equal to 8 0 0 8 1 8 8 2 16 . . . 8 12 96 8 13 104 5. So 192.168.1.101/29 this ip The subnet segment of the address is 192.168.1.96/29, ip The address range is 192.168.1.97-102 6. So at 192.168.1.101/29 It seems that he and 192.168.100 It is also the same network segment
6.6 the calculation uses CIDR to aggregate several small networks into a large network
Suppose a group of class C addresses are 192.168.8.0/24-192.168.15.0/24. If CIDR is used to aggregate these addresses into a network, what should the network address and subnet mask be?
- First convert the third octet of class C address to binary:
192.168.8.0 192.168.00001 000.0 192.168.9.0 192.168.00001 001.0 192.168.10.0 192.168.00001 010.0 192.168.11.0 192.168.00001 011.0 192.168.12.0 192.168.00001 100.0 192.168.13.0 192.168.00001 101.0 192.168.14.0 192.168.00001 110.0 192.168.15.0 192.168.00001 111.0
- The first 5bit00001 is the same as everyone. It is the network address and mask of the third octet
192.168.00001000.0/21
192.168.8.0/21
6.7 special network segment
6.7.1 Internet segment
/30
Mask 30, with only two available ip addresses, is used for the interconnection of two routers
6.7.2 logical network segment
/32
Mask 32, loop, router ID, BGP, establish neighbors, manage addresses
6.7.3 business network segment
Network segments with more than 2 available ip addresses are used for various terminals
6.8 two algorithms for converting CIDR of several network segments into super network
There are three C network segments 192.168.1.0192.168.2.0192.168.3.0
Aggregate into a Supernet
6.8.1 method 1: take the same bit in the last 8bit network bit as the network bit; Different bits become host bits
192.168.1.0/24 192.168.0000 0001.0 192.168.2.0/24 192.168.0000 0010.0 192.168.3.0/24 192.168.0000 0011.0 Take the third group 8 in the network bit bit The same part is still a network bit 0000 00 Take the third group 8 in the network bit bit Different parts become host bits xx The aggregated subnet mask is/22 The aggregated network address is the third group 8 bit Results with 192.168.0000 0000.0 The aggregated Supernet is 192.168.0.0/22
6.8.1 method 2 super network is to lend the original network address bit to the host bit for use
- If 7 bits in the third 8bit bit are borrowed as host bits, and the mask is / 17, there will be 2 ^ 7 = 128 hosts
128 multiply n be equal to 128 0 0 128 1 128 128 2 256 This division will have 2^1=2 The subnets are: 192.168.0.0/17 192.168.0.128/17 Network segment 192 of the first segment.168.0.0/17 Including subnets 192.168.0.0 192.168.1.0 . . . 192.168.127.0
- If one bit of the third 8bit bit is borrowed as the master bit, and the mask is / 23, there will be 2 ^ 1 = 2
2 multiply n be equal to 2 0 0 2 1 2 2 2 4 . . . 2 128 256 This division will have 2^7=128 The subnets are: 192.168.0.0/23 192.168.0.2 192.168.0.4 . . . Network segment 192 of the first segment.168.0.0/23 It only contains two network segments, and there are no 2 and 3 network segments, so it is not satisfied 192.168.0.0 192.168.1.0
- If 2 bits in the third 8bit bit are borrowed as host bits, and the mask is / 22, there will be 2 ^ 2 = 4
4 multiply n be equal to 4 0 0 4 1 4 4 2 8 . . . 4 64 256 This division will have 2^6=64 The subnets are: 192.168.0.0/22 192.168.4.0 192.168.8.0 Network segment 192 of the first segment.168.0.0/22 Contains 192.168.0.0,192.168.1.0,192.168.2.0,192.168.3.0 So satisfied
- Mask 22 satisfied