IP Subnet Partitioning
First, before we learn about subnetting, let's review the knowledge of IP addresses and learn about public and private IP addresses:
There are millions of hosts on the Internet, in order to differentiate these hosts, each host is assigned a dedicated address, called an IP address. The Internet IP address is unified by the NIC (Internet Network information Center) for the planning and management of global addresses, while Inter NICs, APNIC, Ripe Three Network information centers are responsible for IP address assignment in the United States and other regions.
In today's network, IP addresses are divided into public IP addresses and private IP addresses. Public IP is the IP address used on the Internet, and the private IP address is the IP address used in the local area network.
In the previous blog, we introduced the A, B, C, D, e five IP addresses, where D, E class has a special purpose, so the actual IP address we can use is a, B, C three class address, where public address is addressed by Inter NIC (Internet Network Information Center Internet Information Center) is responsible. These IP addresses are assigned to organizations that register and apply to the inter NIC. Direct access to the Internet through it.
Private address is a non-registered address and is intended for use within an organization.
The following lists the retained internal private addresses
A类:10.0.0.0--10.255.255.255B类:172.16.0.0--172.31.255.255C类:192.168.0.0--192.168.255.255
Except for these addresses, the other is a public IP, so the address range for a common IP is:
A类:0.0.0.1-- 9.255.255.255 & 11.0.0.0--126.255.255.255B类:128.0.0.0--172.15.255.255 & 172.32.0.0--191.255.255.255C类:192.0.0.0-- 192.167.255.255 &192.169.0.0--223.169.255.255
Reasons for subnetting
The subnetting technology discussed today is implemented on the basis of the IPv4 protocol.
First look at Baidu's definition of IPv4:
IPV4, the fourth edition of the Internet Protocol (Internet Protocol,ip), is also the first protocol to be widely used to form the basis of today's Internet technology. 1981 Jon Postel defined in RFC791 that Ip,ipv4 can run on a wide variety of underlying networks, such as end-to-end serial data links (PPP protocol and SLIP Protocol), satellite links, and so on. Ethernet is the most commonly used in LAN.
IPv4 put forward only 1981 years, when the Internet is not universal, people demand for the internet is very small, but with the development of the Times, the Internet, the number of netizens increasing, the demand for the network is increasingly large, the original IPV4 address gradually began to be insufficient.
In the Internet, we can use a switch to form a local area network, a local area network can be a separate network segment, two LAN communication between the need to use a router connection, the function of the router is used to connect different network segment equipment to pass.
And so many routers in the world, if all are connected together, the existing IPv4 network segment is definitely not enough. And the world's Internet can only appear on the public IP, a network segment in the public network has appeared in any place, in other places can not reappear, once the emergence of the Internet will cause network conflicts.
ABC three types of addresses add up to so many network segments, we imagine that if a company has a Class A address network segment, for example: 140.0.0.0/8
, the network segment can host the maximum number of 2^24-2=16777214, and this company staff may not have more than 1000 people, With such a tight network of resources, the company's use of this network segment can create a huge waste of resources.
So in this case, we need to apply the subnet partitioning technology to make full use of the resources of this situation.
Summary of the reasons for the net division:
- Meet the IP address needs of different networks
- Realizing the hierarchical nature of the network
- Save IP Address
The principle of sub-network division
The fact is that the network segment is re-divided by changing the subnet mask to the IP address.
VLSM variable eldest son netmask
VLSM (Variable Length Subnet mask, variable eldest subnet mask) is designed to effectively use Classless Inter-domain Routing (CIDR) and Route aggregation (route summary) to control the size of the routing table, and network administrators use advanced IP addressing techniques, VLSM is one of the most common ways in which the subnets can be hierarchically addressed to make the most efficient use of existing address space.
VLSM specifies how to use different subnet masks in a different part of a network that is divided into subnets. This is useful for situations where different network segments within networks need different big kid nets.
The function of VLSM is to make the network number by borrowing the corresponding bits from their host number in the IP address of the class, that is to say, increase the number of digits of the network number. Various types of networks can be used to re-draw the number of molecular nets: a class has 24 can borrow, B has 16 can borrow, C class has eight can borrow.
Sub-Network Division
Here continue to use the above 140.0.0.0/8, the network segment of the number of available hosts is 16777214, assuming this network segment is now being bought by China to use, but so many provinces in China, each province has a large number of IP needs, how should I allocate this resource?
For example:
140.0.0.1/8 - 140.0.0.255/8 北京140.0.1.0/8 - 140.0.1.255/8 上海140.0.2.0/8 - 140.0.2.255/8 广州140.0.3.0/8 - 140.0.3.255/8 深圳
Now that we use VLSM technology, we can divide it into some sub-network segments for a reasonable allocation of resources, let us look at the following two network segments:
140.1.0.0/16140.2.0.0/16
This and the above network segment looks different, the actual is that we use VLSM for subnetting after the result, we through the host bit borrow way, the first 16 bits as the new IP network segment (network number), in this way, we can be separated from the previous network segment 140.0.0.0/ 16 to 140.255.0.0/16, such as 256 new network segments, these network segments is a subnet segment of the previous network segment, in this form, we can re-partition the previous network, as follows:
140.0.0.0/16 北京140.1.0.0/16 上海140.2.0.0/16 广州140.3.0.0/16 深圳......
Above, we can make a better division of the previous network segment to meet the needs of different regions for the network
Now, the Beijing area has got its own IP network segment 140.0.0.0/16
, where the number of available hosts is 65534, so how to plan the network in China? Here we can continue to use VLSM further subnetting of the network segment in Beijing
140.0.0.0/24 朝阳区140.0.1.0/24 海淀区140.0.2.0/24 西城区140.0.3.0/24 东城区······
Can be seen, here we again on the host bit borrowed 8 bits as a network bit, the network segment in Beijing also divided into 256 subnets, to achieve the network needs of different urban areas in Beijing.
Here we through two times of the host borrow, to achieve a Class A network segment sub-network division, such a division, not only to meet the needs of different regions of the network, but also to make our sub-network division has a very good level.
Ideally, if the world's IP addresses are re-partitioned according to VLSM, international bandwidth can be greatly improved at the international level. For example, one of the above planning, the use of China through the division 140.0.0.0/16
, good use of the network segment, other countries also so, the routing rules between each other is much simpler. However, due to the premature release of IPv4, the network distribution around the world is relatively cluttered, which leads to the complexity of the core route writing.
Next we further request, when the Chaoyang district to get their own network segment, Chaoyang District also need to assign IP address to their own urban areas of different streets or communities, we look at the above network segment 140.0.0.0/24, the front of the three positions into a network bit, then how to borrow it?
Here we can't confine our thinking to the decimal representation of the IP address, the actual IP address is a 32-bit binary number
| ip|01001100.00000000.00000000.0000000|
|-|-|
| Subnet Mask |11111111.11111111.11111111.00000000|
So the address of the IP network segment in Chaoyang District is actually this:
01001100.00000000.00000000.0000000
(Red-and network-bit blue-to-host)
In the front we have been using the decimal means IP, every time borrowed eight bits, so here we have to do sub-network division, it is necessary to divide this network segment into binary system for borrow division.
However, it should be noted that when the IP address in decimal, we borrow a digital bit equivalent to borrow 8 bits, can be divided into a number of sub-network segments of 2^8=256, but when we change to binary number expression, we borrow a bits can only be divided into two sub-network segments.
As a result, the IP in Chaoyang District has the last 8 locations belonging to the host, and then we borrow 4 bits for subnetting:
A社区:01001100.00000000.00000000.0000 0000 /11111111.11111111.11111111.1111 0000B社区:01001100.00000000.00000000.0001 0000 /11111111.11111111.11111111.1111 0000C社区:01001100.00000000.00000000.0010 0000 /11111111.11111111.11111111.1111 0000D社区:01001100.00000000.00000000.0011 0000 /11111111.11111111.11111111.1111 0000·······转为十进制表示:A社区:140.0.0.0/28B社区:140.0.0.16/28C社区:140.0.0.32/28D社区:140.0.0.48/28
In this way, the network segment of Chaoyang District can be divided into sub-network. However, it is important to note that the network segment for each community is divided into 4 primary seats, so the number of hosts available for each community is: 2^4-2=14
It can be seen that each time the subnet division of the network segment, the divided subnet has two addresses are unusable (network segment address and broadcast address), so the use of subnetting, will reduce the number of available hosts in a network segment.
Here is a summary of the above content:
- When subnetting, we can only move the host bit
- When dividing a decimal subnet, each number of digits is borrowed by 8 bits
- In each subnet, be aware that the network segment address and broadcast address are unavailable addresses
- Number of segments in a network segment: 2^n (number of host bits borrowed when n= divided)
- Compute the number of available hosts for subnets: 2^n-2 (n= subnet host bits)
The idea of developing a variable-length subnet mask is that there is more flexibility in dividing a network into multiple subnets while keeping enough hosts on each subnet. If there is no vlsm, a subnet mask can be provided to only one network. This limits the number of hosts on the required number of subnets.
A subnet partitioning exercise
Q: Divide 20.1.1.0/24 into four subnets, each subnet segment, broadcast address, number of available IPs
这里为了简写,我们将前24位以十进制位形式书写20.1.1.00 00000020.1.1.00 111111子网网段:20.1.1.0/26 广播地址:20.1.1.63/2620.1.1. 01 00000020.1.1. 01 111111 //64-127网段:20.1.1.64/26 广播地址:20.1.1.127/2620.1.1. 10 00000020.1.1. 10 111111 //128-191网段:20.1.1.128/26 广播地址:20.1.1.191/2620.1.1. 11 00000020.1.1. 11 111111 //192-255网段:20.1.1.192/26 广播地址:20.1.1.255/26每个子网可用的ip数量都为62(2^6 - 2)/*主机位全置0为网段,主机位全置1为广播地址,除了网段和广播地址,其他皆为可用IP地址*/