CIDR (classless Inter Domain Routing) improves the traditional IPV4 address classification. Traditional IP classifications directly correspond to the default classification of IP addresses, thus dividing the internet into networks. CIDR adds a subnet mask (subnet masking) to the routing table, which allows for more subdivision of the network. With CIDR, we have the flexibility to assign a range of IP addresses to a network.  1) IP Address classification in the IP relay, I mentioned that the IP address can be divided into the following categories: ip class from to & nbsp Subnet mask a 1.0.0.0 &NBS P 126.255.255.255 255.0.0.0 b 128.0.0.0 191.255.25 5.255 255.255.0.0 c 192.0.0.0 223.255.255.255 &N bsp;255.255.255.0 This is the original IPV4 address classification design. A total of 32 bits of a IPV4 address can be divided into two parts: Network and host. The subnet mask (subnet mask) is used to indicate which bits represent the network part. For example, the following subnet mask 255.0.0.0 binary representation is: 11111111 00000000 00000000 00000000 its first eight bits is 1, so that the first eight bits of the IP address is the network part. The next 24 generations refer to each host of the network. A Class A network can have 224 hosts, which is 16777216. Since the IPV4 address has been divided into classes, so when we get an IP address, we can find its subnet mask above. (class B, 216; Class C, 2) traditional routingTable  IP Classification facilitates the relay of IP packets. When an IP packet arrives at a router, the next station of the relay is determined based on the router's routing table (routing table). A traditional routing table looks like this: destination gateway IFACE&NBSP ; 199.165.145.0 0.0.0.0 eth0 199.165.146.0 0.0.0.0 eth1 0.0.0.0 199.16 5.146.8 eth1 The routing table represents the following network topology: because of IP classification, we do not need to record subnet mask. When we go to 199.165.146.17, we already know that this host is located in a Class C address, so its subnet mask is 255.255.255.0, which means 199.165.146 represents the network, and 17 represents the host.  3) CIDR routing table However, due to the default classification, the network can only exist in the form of a, B, C. Assuming a network (such as the MIT Network) assigns a Class A address, the network will allow 16,777,216 hosts. If the network cannot run out of these IP addresses, these IP addresses will not be available to other networks. Another example of the above network, 199.165.145 must exist as an entire network. If we only have 10 hosts, then more than 200 IP addresses will be wasted. The essence of CIDR is to add a subnet mask to the routing table and partition the network based on the column information, rather than dividing it by the default a,b,c. For example: destination gateway Genmask &N Bsp iface 199.165.145.254 0.0.0.0 255.255.255.254 &N Bsp eth2 199.165.145.0 0.0.0.0 255.255.255.0 eth0 199.165.146.0 0.0.0.0 255.255.255.0 eth1 0.0.0.0 199.165.146.8 0.0.0.0 eth1 According to the first record of the routing table, 199.165.145.254 (IP address): 11000111 10100101 10 010001 11111110 255.255.255.254 (subnet mask): 11111111 11111111 11111111 11111110 (31 1, 1 0) By subnet mask you know, The first 31 bits represent the network, and the last one represents the host. The subnet mask always has a number of consecutive 1 components, such as the above 31 1. So it can also be remembered as 199.165.145.254/31 to represent both the IP address and the subnet mask. The router splits a portion of the original 199.165.145 network. This network can hold two computers, namely 199.165.145.254 and 199.165.145.255. This network corresponds to the NIC is eth2. When an IP packet leads to these two IP addresses, it goes to eth2 instead of eth0. network topology as follows: using CIDR, we can split the IP address as needed, thus not wastingIP address.
CIDR Address Classification