Give an IP address, how to divide into several subnets?

Source: Internet
Author: User
Tags bitwise

1, Introduction to basic knowledge

1. 1 each host or router in the network has at least one IP address;

Two devices are not allowed to have the same IP address on the Internet;

1. 2IP address using a layered structure;

The IP address consists of a network number (NET ID) and a host number (host ID).


1. 3 Classification of IP addresses

IP address length is 32 bits, dotted decimal (dotted decimal) address;

In x.x.x.x format, each x is 8 bits, and the value of each x is 0~255 (for example, 202.113.29.119);

According to different range of values, IP address can be divided into five categories;

The first 5 bits of the IP address are used to identify the categories of IP addresses:

The first digit of the Class A address is 0;

The first two digits of Class B address are 10;

The first three digits of the class C address are 110;

The first four digits of Class D address are 1110;

The first five digits of the class E address are 11110.


2 , a C class addresses are divided into several subnets

A Class C address is made up of 24-bit network numbers and 8-bit host numbers. If a unit gets a class C IP address, it can assign IP addresses to 254 hosts and routers in a separate network. However, if the organization wants more subnets, they also need to work with subnet address partitioning.

For example: The administrator of an agency network obtains a class C IP address from the Network Management Center: 212.26.220.0, the network of this Organization is composed of 5 subnets.

The network needs 5 subnets, and if you take into account the 2 special addresses that are reserved, the total number of subnets required is 7. Obviously, select the subnet number bit length is 3 can satisfy the user request.

The address structure after the subnet is divided as shown below. We chose to use the subnet mask 255.255.255.224, then subnet division of the IP address of the subnet number is 3 digits, the host number is 5 bits, its structure should be: 3-bit subnet number indicates that the network of the authority to allow 6 subnets, 5-bit host number means that each subnet can have 30 hosts.


Subnet Mask: 255. 255. 255. 0


Class C Address:

←netid→

←hostid→

11111111

11111111

11111111

00000000

(a) Subnets not divided

Subnet Mask: 255.255.255.224

Class C Masks:

←netid→

←subnetid→

←hostid→

11111111

11111111

11111111

11100000

(b) Dividing the subnet

In a scenario that is divided by the subnet above, the IP address available to the network of the Organization is:

Sub-network 1:212.26.220.33~212.26.220.62

Sub-network 2:212.26.220.65~212.26.220.94

Sub-network 3:212.26.220.97~212.26.220.126

Sub-network 4:212.26.220.129~212.26.220.158

Sub-network 5:212.26.220.161~212.26.220.190

Sub-network 6:212.26.220.193~212.26.220.222

Understanding: Subnet ID changes are: 001 010 011 100 101 1106 (except 000 and a)

The subnet host ID changes to: 00001 00010 00011 00100 00101 00110 00111 01000 ... 11110 30 species (excluding 00000 and 11111)

then: The scope of each subnet is the subnet ID + subnet host ID minimum----subnet ID + Subnet host ID maximum value.

3 , how to determine whether it belongs to the same subnet based on the IP address of the host

In many cases, it is necessary to determine whether the same subnet is based on the IP address of two hosts. To determine whether two hosts are in the same subnet, the standard is to see if their subnet addresses are the same. In the comparison, their addresses need to be represented in binary form.

For example, Host 1 and host 2 IP addresses are 156.26.27.71, 156.26.27.110 hosts, and subnet masks are 255.255.255.192 to determine whether they are on the same subnet.

The solution is to first write out their IP addresses in binary form:

Host 1:10010010.00011010.00011011.01000111

Host 2:10010010.00011010.00011011.01101110

in a subnet, all hosts have the same subnet mask. when we know the IP address and subnet mask of a host in a subnet, the IP address and subnet mask are bitwise AND (and) operations, and the result is the subnet number of the subnet on which the host resides. You can use the IP address and subnet mask of host 1 as a bitwise operation:

Host 1 IP address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.