Home  >  Article  >  Operation and Maintenance  >  How to classify IP addresses and divide subnets

How to classify IP addresses and divide subnets

PHPz
PHPzforward
2023-05-17 19:01:321972browse

ip is a 32-bit unsigned integer, its range is 0.0.0.0 - 255.255.255.255. Specifically, an IP consists of two parts: the network number and the host number. If the network numbers are the same, it means that they are in the same network segment. , you can use mac data frame to communicate directly
Given a network number
IP with host number all 0 represents the network address
IP with all host number 1 represents broadcast address
Representation of ip address:
xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx
|--net--|---------host------------|
Class A address network The beginning of the network number is 0, the beginning of the network number of class B address is 10, the beginning of the network number of class C address is 110

The representation range of class A address is: 0.0.0.0~126.255.255.255, the default network mask The code is: 255.0.0.0; Class A addresses are allocated to particularly large-scale networks. Class A networks use the first set of numbers to represent the address of the network itself, and the next three sets of numbers as the addresses of hosts connected to the network. Assigned to large networks with a large number of hosts (direct individual users) and a small number of LANs. For example, IBM's network.

The representation range of Class B addresses is: 128.0.0.0~191.255.255.255, and the default network mask is: 255.255.0.0; Class B addresses are allocated to general medium-sized networks. Class B networks use the first and second sets of numbers to represent the network address, and the last two sets of numbers represent the host address on the network.

The representation range of Class C address is: 192.0.0.0~223.255.255.255, and the default network mask is: 255.255.255.0; Class C address is allocated to small networks, such as general LAN and campus network, it can The number of connected hosts is the minimum, and the users are divided into several network segments for management. Class C networks use the first three sets of numbers to represent the network address, and the last set of numbers as the host address on the network.

In fact, there are also Class D addresses and Class E addresses. However, these two types of addresses have special uses. Here is a brief introduction: Class D addresses are called broadcast addresses and are used by special protocols to send information to selected nodes. Class E addresses are reserved for future use.

The definition of netmark is very simple. Netmask is also 32 bits. Numerically, the Net-ID is 1 and the Host-ID is 0

For example, a common Class C IP address

Net-id=24 bits, host-id=8 bits, with 2**8-2=254 ips

A traditional Class C network, such as 192.168.10.0, its netmark It must be 255.255.255.0. If you divide this network into two sub-networks, it is very simple. Set the net-id to use 25 digits, and the host-id will only have 7 digits. Then the netmark at this time = 255.255.255.1 0000000 = 255.255.255.128 , the two subnets obtained this time are
129.168.10.0/25
192.168.10.128/25
Obviously, /25 is the number of digits occupied by the net-id in this IP (these 2 The host-id of each IP is all 0, so these two IPs represent the subnetwork where they are located)

This representation method is easy to calculate the size of the subnetwork, for example

192.168 .0.0/27 means 2 raised to the power of 5 (32-27=5) -2 (the first and last addresses of each network segment are occupied by special purposes) = 62 ip
192.168.0.0/28 , indicating 2 to the power of 4 (32-28=4) -2=30 ip

, so 192.168.1.1/24 marks a subnetwork 192.168.1.0 (with 254 ip addresses: from 192.168 .1.1 to 192.168.1.254)

The above is the detailed content of How to classify IP addresses and divide subnets. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete