Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[popular science] IP address details-you, who are you? (2)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

I heard your voice.

There is also a heart that I dare not see.

Xue Zhiqian-- "I seem to have seen you somewhere"

The word IP has been known by people with the development of the Internet, but there is still a lot of content that is not well known, so let's go on with what we explained last time. At the same time, I would also like to express my sincere thanks to the friends who have made comments and encouragement for this article, thank you for your support and encouragement, and wish you well.

1. IP addresses are classified as classful and classless.

1.1 introduction

In our implementation life, IP addresses are divided into classful and classless.

Classful (main class) IP address: mainly divided into A, B, C categories, each type of fixed mask.

Classless IP address: no matter which type of IP address there is no fixed mask.

1.2 what is a mask (subnet mask)?

The subnet mask cannot exist alone and must be used in conjunction with the IP address. The subnet mask has only one function, which is to divide an IP address into two parts: the network address and the host address.

To put it simply, it is like a wall across a room, dividing a large room into small rooms.

two。 Classless IP address Planning

For example, class: class B network segment 172.16.0.0, using a natural mask of 255.255.0.0

2.1 distinguish between main class and classless usage

When using 172.16.0.0 main class method to divide the network segment. The following network address planning is incorrect (incorrect without using NAT, which is described in later chapters by NAT)

Because:

172.16.4.1Compact 16 has a network address of 172.16.0.0

172.16.8.1Compact 16 has a network address of 172.16.0.0

The network address is the same as 172.16.0.0172.16.0.0

So 172.16.4.1 Compact 16 and 172.16.8.1 Universe 16 are on the same network segment, and the two computers are separated by the router and need to be on different network segments.

Incorrect address planning:

For example, classless: 172.16.0.0 classless division of network segments. The following network address planning is correct

Because:

172.16.4.1Compact 24 has a network address of 172.16.4.0

172.16.8.1Compact 24 has a network address of 172.16.8.0

Network address is different 172.16.4.0 ≠ 172.16.8.0

So 172.16.4.1 Compact 24 and 172.16.8.1 Compact 24 are different network segments, and the two computers are separated by the router and need to be on different network segments.

Correct address planning:

2.2 representation of the mask

192.168.1.7Comp28 is represented in the following way

Calculation formula of mask

Variable

A: mask

The maximum multiple of bRV 8 (b determines how many 255 there are)

C: Mantissa (the following mind map content)

Calculation formula

A-8*b=c

Representation of mask, corresponding transformation, other masks, and so on

Examples

For example, the mask / 20 cages 20-8 "2" 4.

Axi20

Bread2

Cymbal 4

There are two 255 ways to represent bread2.

The Mantissa of cantis4 is 240; the last group is filled with 0, 255.255.240.0

2.3 Network address calculation method

In classless addresses, network address translation

Calculation method 1

Calculate the network address from the IP address through the subnet mask, first convert the decimal IP address and subnet mask to binary

Perform the and operation on IP and subnet mask. If both are 1, it is 1, and if either is 0, the result is 0.

For example: 192.168.1.7Compact 28 calculation

Calculation method 2

Variable

A = subnet mask-8 * multiple (a less than or equal to 8)

B = number of addresses

C = network address

Formula

B = 2 ^ (8mura)

Croomb* integer multiple (c is the network address closest to the host address)

C ≤ host address (b is the nearest host address)

For example, 1:

192.168.1.7/28

Astatine 28-244

Bust 16

C ≤ 0

So the network address is 192.168.1.0.

For example, 2:

192.168.1.101/22

Asides 22-16-6

B = 2 ^ (8-6) = 4

C ≤ 1 (the third group of 192.168.1.0 is 1)

Centering 0,460,0

So the network address is 192.168.0.0.

2.4 calculation of the number of hosts

How many hosts can be used in a network segment? Let's calculate the number of hosts. In the calculation of the number of hosts, we should pay attention to subtract 2 addresses, which are the network address and the broadcast address.

Number of hosts is:

The number of available hosts is:

For example, how many hosts can 192.168.1.0 Compact 24 support?

2 ^ 8-2254

So it can support 254IP addresses.

For example, how many hosts can 192.168.0.0 Universe 22 support?

2 ^ 10-2 × 1022

So it can support 1022 IP addresses.

2.5 calculation of subnet number

A can support the subnet mask of the largest host

B can support the subnet mask of the smallest host

2 ^ (bmura) = number of subnets

For example, how many / 27 subnet masks can be assigned to the network segment 192.168.1.0 Compact 24?

2 ^ (27-24) = 8

It can support 8 subnets.

2.6 case

A company is assigned a class C address 201.222.5.0. Suppose you need 20 subnets, each with 5 hosts, how should we divide them?

1. First of all, five hosts are needed.

2 ^ n-2 > 5

So the minimum value of n is 3 and the mask is 29.

two。 How many subnets can be supported?

First, the mask of the class C address is / 24 bits, then use the classless mask / 29 bits, and calculate 2 ^ (29-24) = 32.

It can support 32 subnets.

2.7 classless address division

Example: class B address subnet becomes longer

Class B address changed from / 16 to / 24, and the mask became longer, using VLSM (variable length subnet mask).

The mask side length reduces the number of hosts in the network segment, but increases the number of subnets.

For example, when buying a house of 100 square meters in real life, most people will divide the house into functional area rooms, dining rooms, kitchens, etc., although the area of each room becomes smaller, but the functional area is clearly divided. This is the same as our IP address for VLSM. At / 16, the address space is very large, but it is impossible to subdivide each network segment.

Number of mask hosts number of subnets

/ 16 65534 1

/ 24 254 256

For example, when 172.16.0.0amp 16 becomes / 24, the address range, network address, and broadcast address change, which can accommodate more network segments, but reduce the number of hosts carried by each network segment.

Example: class C address subnet becomes longer

The class C address changed from / 24 to / 29, and the mask became longer, using VLSM (variable length subnet mask).

The mask side length reduces the number of hosts in the network segment, but increases the number of subnets.

For example, in real life to buy a house of 50 square meters, although the house is small, it will still be divided into functional area rooms, dining rooms, kitchens, etc., although the area of each room becomes smaller, but the functional area is clearly divided. At / 24, although the address space is small, it is impossible to subdivide each network segment.

Number of mask hosts number of subnets

/ 24 254 1

/ 29 6 32

For example, when 192.168.5.0Compact 24 becomes / 29, the address range, network address, and broadcast address change, which can accommodate more network segments, but reduce the number of hosts carried by each network segment.

2.8 Subnet mask variable length route summary

The longer subnet mask makes it easier to summarize routes. For example, there are multiple 192.168.1.x network segments on the right. At this time, you only need to publish a 192.168.1.0pm 24 route for summary, and the waste of addresses is greatly reduced. The importance of summarization can be seen later on when we talk about routing and existing network address planning.

2.9 use of CIDR

In the real network, the number of routing entries determines the running efficiency of the device, just like the computer to open applications, too many applications occupy a lot of content, making the machine slow. Routing also takes up the memory of the device, and the more routing entries, the slower the device runs. Therefore, effective route summarization can greatly reduce the running pressure of the equipment.

For example, there are three Class C routes on the right below, which normally requires three routes when advertising neighbors around them. At this time, if you use CIDR to summarize three routes into one route to publish, you can reduce the pressure on the device.

2.10 Life small experiment, network segment test

Lab 1:

1. Equipment

Two computers An and B. (the computer should turn off the firewall)

two。 Configuration

IP address of configuration A: 192.168.1.1 Universe 24

IP address of configuration B: 192.168.1.130 Universe 24

3. Steps

Then run on computer An and enter cmd.

Under the window ping 192.168.1.130

It can be made sense at this time.

Lab 2:

1. Equipment:

Two computers An and B. (the computer should turn off the firewall)

two。 Configuration

IP address of configuration A: 192.168.1.1 Universe 25

IP address of configuration B: 192.168.1.130 Universe 25

3. Steps

Then run on computer An and enter cmd.

Under the window ping 192.168.1.130

It is impossible to get through at this time.

Summary: under normal circumstances, devices in the same network segment can communicate, but devices in different network segments can not communicate (through layer 3 device gateways)

IP address first talk about this, there are many places have not been said, a lot of content related to the network address design, the network address is not so simple, a variety of uses, such as business address, physical address, logical address and so on.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report