In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
I. brief introduction
The IP address consists of four segments, each field is a byte, that is, 4 bytes, each byte has 8 bits, and the maximum value is 255 (= 256 virtual 255).
Worldwide is a unique 32-bit (4-byte * 8-bit) identifier.
The IP address consists of two parts, the network address and the host address, which are master-slave relationships:
1. The network number net-id, which indicates the network to which the host (or router) is connected, and the network address indicates which network it belongs to.
two。 Host number host-id, which identifies the host (or router), and the host address indicates which host it belongs to in the network.
The IP address of the two levels can be recorded as: IP address:: = {,}
In short: IP address = network number + host number
2. Dotted decimal notation:
The address length of IPv4 is 32 bits, a total of 4 bytes, but in practice we use dotted decimal notation.
III. IP classification
IP address = network number + host number.
It is divided into three categories A, B, C and special addresses D and E.
All zeros and all ones are reserved.
Category A:
Address range: 1.0.0.1-126.255.255.254 (0000 0001.00000000.0000000000011110.1111111.11111111.11111110)
Address range: 1.0.0.0-126.255.255.255 (this method includes all zeros and ones, other categories are similar)
Network number range: 114126 (0000 0001 ~ 0111 1110)
Default subnet mask: 255.0.0.0 or 0xFF000000 (hexadecimal)
Private number range: 10.0.0.0-10.255.255.255
The first 1 byte (8 bits) is the network number, and the last 3 bytes (24 bits) is the host number.
The first bit of class A must be 0.
Maximum number of networks: 126
Maximum number of hosts:
The address of all 0 and all 1 cannot be assigned as a reserved address. It's the same reason to subtract 2 from above.
It is generally used in large networks.
Category B:
Address range: 128.1.0.1-191.255.255.254
Network number range: 128.1 ~ 191.255
Default subnet mask: 255.255.0.0 or 0xFFFF0000 (hexadecimal)
Private number range: 172.16.0.0-172.31.255.255
The first 2 bytes (16 bits) are the network number, and the last 2 bytes (16 bits) are the host number.
The first two places are fixed at 10.
Maximum number of networks:
Maximum number of hosts:
It is generally used in medium-sized networks.
Class C:
Address range: 192.0.1.1-223.255.255.254
Network number range: 192.0.1 ~ 223.255.255
Subnet mask: 255.255.255.0 or 0xFFFFFF00 (hexadecimal)
Private number range: 192.168.0.0-192.168.255.255
The first 3 bytes (24 bits) are the network number, and the last 1 byte (8 bits) is the host number.
The first three places are fixed at 110.
Maximum number of networks:
Maximum number of hosts:
It is generally used in small networks.
Category D:
Address range: 224.0.0.1-239.255.255.254
It's a multicast address. The first IP address of this class is "1110", so the network number of the address is between 224 and 239.
It is generally used for multicasting users.
Category E:
It's a reserved address. The IP address of this class is preceded by "1111", so the network number of the address is between 240 and 255.
Echo address:
According to some information from 127.x.x.x, it belongs to category A.
For example, 127.0.0.1 is equivalent to localhost or native IP. It is generally used for testing.
For example: ping 127.0.0.1 to test whether the native TCP/IP is normal. Http://127.0.0.1:8080 equivalent http://localhost:8080
# Special instructions
The address (0.0.0.0) where each byte is 0 corresponds to the current host.
The IP address (255.255.255.255) in which every byte of the IP address is 1 is the broadcast address for the current subnet.
All class E IP addresses that begin with 11110 in IP addresses are reserved for future and experimental use.
The first 8 digits of the network number cannot all be 0.
The IP address cannot start with 127. the number 127.0.0.1 "127.255.255.254 is used in the loop test.
Classless inter-domain routing
For small and medium-sized enterprises, if there are two thousand machines, give him a Class B address, more than 60,000, too wasteful, a Class C address, a Class C address 254, and not enough, but also have to apply for several more, so the division of IP addresses in Class C is too rigid and inflexible, so it puts forward the method of dividing IP addresses by classless inter-domain routing (CIDR).
Convert the regular subnet mask to binary, and find that the subnet mask format is continuous binary 1 and continuous 0, where the part of the subnet mask of 1 represents the network ID, and the part of the subnet mask of 0 represents the host ID. For example, 255.255.0.0 is converted to binary to 11111111 11111111 00000000 00000000.
In the previous example, why not use the contiguous 1 part to represent the network ID and the consecutive 0 part to represent the host ID? The answer is yes. The IP addressing technology using this scheme is called classless interdomain routing (CIDR). CIDR technology uses a continuous 1 part of the subnet mask to represent the network ID and a continuous 0 part to represent the host ID. For example, if the network contains 2000 computers, only 11 bits are needed to represent the host ID, and the 21-bit table network ID is used, the subnet mask is represented as 11111111.111111111111100000.00000000, and 255.255.224.0 is converted to decimal. At this point, the network will contain 2046 computers, which will not cause a waste of IP addresses, nor will it use routers to connect to the network, adding additional administrative maintenance.
CIDR representation: the number of digits of the IP address / network ID, such as 192.168.23.35 ID 21, where 21 bits represent the network ID.
Example 1: 192.168.23.35 Unit21
Subnet mask: 11111111 11111111 11111000 00000000 is 255.255.248.0
Network ID:192.168.00010111.0 (the red part of the third byte indicates the network ID, the other represents the host ID, and the network ID indicates that part of the network ID remains unchanged and the host ID all changes to 0), then the network ID is 192.168.16.0
Starting IP address: 192.168.16.1 (the host ID cannot all be 0, which means the last bit of the network ID is 1)
End IP address: 192.168.00010111.11111110 (host ID cannot all be 1s, all 1s indicate local broadcast), the end IP address is: 192.168.23.254.
Example 2: divide 163.135.0.0 into 16 subnets, and calculate the network ID, subnet mask, and start and stop IP addresses of the first two subnets.
Step 1: the subnet mask is 255.255.240 (11110000) .0 if 163.135.0.0 is represented by CIDR.
Step 2: first network ID (subnet mask and IP address and operation): 163.135.0.0
First IP address: 163.135.0.1 end IP address: 163.135.15.254
Step 3: the second network ID:163.135.16.0
The first IP address: 163.135.16.1 end IP address: 163.135.31.254. 5. Fast calculation method of subnet mask and network ID
If the subnet mask of CIDR is represented by a continuous 1 followed by a connected 0, the subnet mask can be expressed in the following ways:
0000 0000 0
1000 0000 128
1100 0000 128 / 64 / 192
1110 0000 12864 32224
1111 0000 255 color 1540 240
1111 1000 255 Mutual 7248
1111 1100 255 music 333 252
1111 1110 255 Mustang 254
1111 1111 255
We all know that the decimal number of 11111111 is 255. so how do we quickly calculate the subnet mask? Binary 1meme 111m 3111m 7m 1111m 15; so 1111 1110m 255-1 minus 1111 1100m 255-3meme 1111 1000m 255-8pm 11110000555-15 is that fast? As soon as we determine how many bits in the subnet mask represent the network ID, we can write the subnet mask immediately. So how do we calculate 1000, 000, 100, 0000 and 1110, 0000? 278 is 1000 0000110000001281464, so we don't need to remember the number of each one, we just need to do a simple addition and subtraction to calculate the subnet mask.
The result of the network ID everyone knows that the network ID part remains unchanged, and the host ID part changes to 0, so when calculating the network ID, first look at how many bits in the subnet mask are used to represent the network, and correspondingly convert only the first few bits when converting the IP address to binary, such as 192.168.176.15tick, the network ID has a total of 19 bits, then the first two bytes of the network ID are 192.168.X.0 and the third byte is the third. So how to quickly calculate the value of X for this change? We know that only three bits of the third byte represent the network ID, the first bit is 1176mur128 48 < 64, the second bit is 0mem48 > 32, the third bit is 1, the rest of the calculation is meaningless, if all of them are converted to 0, then the network ID is 10100000 and the network ID is 192.168.160.0, so the possibility of error in the calculation is very small.
VI. Local and remote network concepts
The computer with the same network ID is called the local network, and the computers in the local network do not need to connect with the router to communicate with each other; the computers with different network ID are called the remote network, and the computers in the remote network must be connected through the router if they want to communicate with each other.
Example 1 which IP is legal IP and which is illegal IP address?
Illegal IP addresses with host ID all 0 and host ID all 1 are illegal IP addresses: 192.168.10.15, 192.158.10.16, and 192.168.10.31, respectively.
Example 2 which is not the same network segment? 192.168.10.14, 28192.168.10.15, 28192.168.10.16.
If the network ID is the same, it belongs to the same network segment, then 192.168.10.16lap 28 does not belong to the same network segment.
7. The calculation method of the number of subnets and hosts
Example: 172.168.34.56 Universe 20, how many subnets are divided and how many hosts can be contained in each subnet.
172.168.34.56 is a class B address, which uses 16 bits to represent the network ID. If 20 bits in the topic represent the network ID, then the number of subnet bits is 4 bits, so there are 24 subnets (that is, 16 changes from 0000, 0001 to 1111).
Because the IP address is 32 bits and the network ID is represented by 20 bits, the number of bits of the host ID is 12 bits, then each subnet can contain 212 IP addresses, that is, 4096 IP addresses.
Note: why subtract 2 when calculating IP addresses and not minus 2 when calculating the number of subnets? The reason why the IP address is minus 2 is that the host ID cannot be all 0 or 1; this problem does not exist in the subnet.
VIII. Public IP and private IP addresses
IP addresses are managed and assigned by IANA (Internet address allocation Organization). Any IP address that can be used on Internet must be assigned by IANA, and the IP address assigned by IANA that can be used normally on Internet is called public IP address; IANA retains a part of IP address that is not assigned to any organization or individual, and this part of IP address cannot be used on Internet, this kind of IP address is called private IP address. Why can't private IP addresses be used on Internet? Because there is no route for a private IP address on the Internet. Private IP address ranges include:
Category A: 10.0.0.0 Universe 8
Class B: 172.16.0.0amp 12, that is, 172.16.0.1-172.31.255.254, a total of 16 Class B networks
Class C: 192.168.0.0amp 16, i.e. 192.168.0.1-192.168.255.254, a total of 256 Class C networks
IX. Super net
Division of supernets: merge multiple small networks into a large network, and the host ID borrows bits from the network ID
10. Practice
Now suppose you are the network divider of China Telecom, and now the requirements are as follows:
1. All provincial subsidiaries are in the 10 network segment.
two。 The subsidiaries of each city are subnetted on the basis of provincial companies.
Beg
1. Network id of provincial companies
two。 Number of hosts of companies in each province
Suppose Shandong is assigned to the fourth network segment, find out
1. Network id of companies in each city
two。 Number of hosts of companies in each city
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.