Subnet mask introduction

xiaoxiao2021-03-06  17

What is an IP address? In order to facilitate communication, each computer is allocated as an identification address similar to a phone number in advance, an IP address.

According to the TCP / IP protocol, the IP address consists of 32-bit binary numbers and is unique within the Internet.

Such as: an IP address is 11000000 10101000 00001010 00000010

In order to facilitate memory, people divide 32-bit IP addresses into four sections, 8 digits per segment, with a decimal point in the middle. "Said, and then replace each 8 binary to decrease, 192.168.10.2

Classification of IP addresses

Like the area code and the specific number like the phone number, we divide the IP address into two parts: web identity and host identity.

Network logo

All hosts on the same physical network are identified by the same network, and each host on the network has a host identity corresponding to it.

Host logo

That is, it is a specific computer number in a network.

Example: The IP address of a host server is 192.168.10.2, of which

Network logo is 192.168.10.0

Host logo is 2

The IP address accounts for 4 bytes of 32 bits, and part is part of the network ID, and the other is the host ID. Since the number of computers contained in the network may be different, people are divided by 3 ways according to the size of the network size, respectively:

1, class A IP address

In the 4th number of the IP address, paragraph 1 is the network identity, and the remaining 3 segments are the host ID. That is, the Class A IP address consists of 1 byte of network identity and 3-byte host identity.

The highest bit of the network address must be 0, the length of the network identification is 7 bits, and the length identifier is 24 bits.

The number of IP network addresses are more, suitable for large networks, with more than 16 million hosts available.

2, class B IP address

In the 4th number of the IP address, the first 2 segments are the network identity, and the last 2 segments are host ID. That is, the class B IP address consists of 2 bytes of network identity and 2 bytes of host identity.

The highest bit of the network address must be 10. The length of the network identification is 14 bits, and the length identifier is 16 bits.

Class B IP network address is available for medium-size networks, with more than 6,000 hosts.

3. Class C IP address

In the 4th number of the IP address, the first 3 segments are the network identity, and finally 1 is the host ID. That is, the C class IP address consists of 3-byte network identity and 1 byte host identity.

The highest bit of the network address must be 110. The length of the network identification is 21 bits, and the length of the host identifier is 8 bits.

There is fewer number of Class C network addresses, suitable for small local area networks, available in up to 254 hosts.

In addition, the TCP / IP protocol specifies that the first byte in the IP address is multipoint by 11110. Therefore, any of the first bytes greater than 223 less than 240 is a multipoint broadcast address; the address of the IP address will remain as special use with the address of 11110.

IP address addressing rules

1. Network addressing rules

A, the network address must be unique.

B. The network identification cannot be started with a number 127. In the Class A address, the number 127 remains to the internal return function (127.1.1.1 for loop test).

C. The first byte of the network identification cannot be 255. Number 255 as a broadcast address.

D, the first byte of the network identification cannot be "0", "0" indicates that the address is a local host and cannot be transmitted.

2. Host addressing rules

A. The host identifies must be unique within the same network.

B, the host identified by the host cannot be "1", if all bits are "1", the server address is a broadcast address, not the host's address.

C, the host identified by the host cannot be "0". If each bit is "0", it means "only this network", and there is no host on this network. Subnet mask

The subnet mask is also a 32-bit address, its role is:

A portion of the IP address is used to distinguish between network identity and host identity, and indicate that the IP address is on a local area network or on a remote network.

Only the host in one subnet can communicate with each other, otherwise it is necessary to pass the special means.

Example 1: Set the IP address of 192.168.10.2, the subnet mask is 255.255.255.240, then the subnet mask is to distinguish between network identity and host identity.

answer:

Use "with" operations. Conversion of decimal conversion into binary and calculations

IP address: 11000000 10101000 00001010 00000010

Subnet mask: 11111111 11111111 11111111 11110000

And operations:

----------------------------

11000000 10101000 00001010 00000000

Then, its network identification is 192.168.10.0, and the host identifies is 2.

Example 2: Set the IP address of 192.168.10.5, the subnet mask is 255.255.255.240

Use "with" operations. Conversion of decimal conversion into binary and calculations

IP address: 11000000 10101000 00001010 00000101

Subnet mask: 11111111 11111111 11111111 11110000

And operations:

----------------------------

11000000 10101000 00001010 00000000

Then, its network identification is 192.168.10.0, and the host identifies 5.

From the above two examples, it can be obtained, as long as there is an IP address and the above subnet mask operation, 192.168.10.0, then these IP addresses are in the same subnet.

If you are more familiar with binary friends, you will find that because the last paragraph of the mask is 11110000,, in the case of the first three paragraphs, as long as the top four of the host identification is 0, the IP address obtained must be in the same child. In the network. It is also not difficult to calculate, at a subnet mask such as 255.255.255.240, only 16 hosts are in the same subnet.

This can be obtained, and the subnet mask 2555.255.255.0 often seen in the local area network, and only 255 hosts can be in the same subnet.

VLSM (variable long mask)

The 3-class IP address default subnet mask is 255.0.0.0, 255.255.0.0 and 255.255.255.0, respectively. But this will inevitably waste some IP addresses.

In terms of the default mask of Class C IP addresses, 253 hosts can be in one subnet (in addition to 1 and 0, see the address rule of the IP address). Suppose is a Class C IP address: 192.168.10. *, The IP address is in one subnet from 192.168.10.1 to 192.168.10.254, suppose now there is only 13 hosts, then 240 hosts will be wasted.

But if there is VLSM. 255.255.255.240 in the above example is this, according to our operation, it will only have 14 available hosts (removed all 0 and 1).

When using this subnet mask 255.255.255.240:

The IP address is from 192.168.10.1 to 192.168.10.15 in the same subnet, its network identification is 192.168.10.0;

The IP address is from 192.168.10.16 or 1923168.10.18, the network identifier is 192.168.10.16.

Provide a table reference

转载请注明原文地址:https://www.9cbs.com/read-63455.html

New Post(0)