IP address learning and analysis

Table of contents

1. What is an IP address?

2. Classification and configuration of IP addresses

2.1 The difference between IPv4 address and IPv6 address

2.2 Classification of IPv4 addresses

3. Local private address 

3.1 169.254.xx/16 local private address


1. What is an IP address?

IP address (Internet Protocol Address) refers to the Internet Protocol address, also known as the Internet Protocol address. The IP address is a unified address format provided by the IP protocol. It assigns a logical address to each network and each host on the Internet to shield the differences in physical addresses. Therefore, the IP address is a logical address, and the MAC address on the network card of each host is the physical address. The
IP address is actually a string of 32-bit binary numbers. In order to facilitate our memory, we divide it into groups of 8 bits, separated by decimal points. , similar to: 172.20.5.6 (10110110.00010100.00000101.00000110)

2. Classification and configuration of IP addresses

2.1 The difference between IPv4 address and IPv6 address

IPv4 and IPv6 are different types of IP addresses. Their main purpose is the same, to mark different users and enable users to communicate over IP. The main difference is that IPv6 is the latest generation of IP addresses. Because the number of IPv4 address combinations is limited, it will eventually be exhausted. Therefore, the development of IPV6 is designed to prevent the complete exhaustion of IPV4.

IPv4 address - a 32-bit binary number, expressed in dotted decimal notation

Teach you how to easily convert IP addresses between binary and decimal

Example: (1) Convert the address 192.168.1.1 into binary representation

The following is a string of 32-bit binary numbers. In order to facilitate our memory, we divide it into groups of 8 bits and use decimal points in the middle.

Each 8-bit binary number can be represented by 2^n, which corresponds to 2^7 ---2^0 respectively.

10101000.00000000.00000000.00000000

 128 64 32 16 8 4 2 1 (2^7 --- the decimal number of 2^0)

10101000=128*1+64*0+32*1+16*0+8*1+0*(4+2+1)=168

10101000.00000000.00000000.00000000=168.0.0.0

Same reason

128*1+64*1+0*(32+16+8+4+2+1) =11000000=192

So 192.168.1.1=11000000.10101000.00000001.00000001

A full IP address requires a subnet mask/netmask (mask/netmask)

When configuring the address, the subnet mask is essential

So what is the "subnet mask" in the IP address used for?

Give a familiar example

Xiao Ming is a freshman, and his student number is 05510050433 20212194

When Xiao Ming sees another student ID, he can immediately know whether the other student is in the same class as him.

For example, the good-looking girl Xiaohong 20212133 is a classmate

The good-looking boy Xiaolan 20221144 is not a classmate

How can you tell? If the numbers in the front of the student ID are the same, they are classmates.

The student number is roughly divided into two parts, the first part is the class number, and the second part is the individual number.

Now back to ip address and subnet mask

Computers and mobile phones must be connected to the Internet, and there will be an IP address when connected to the Internet. The IP address is usually obtained automatically, but if you configure it manually, you will find that you must fill in the subnet mask, otherwise it will not be confirmed.

The function of the subnet mask is to determine the network segment where the IP address is located.

Xiao Ming must know his class, and the computer must know its network segment.

The first 4 digits of Xiao Ming’s student number represent the class number, which is set by the school.

So how many first digits of the IP address represent the network segment? This depends on the subnet mask.

The IP address is divided into two parts. The first part is called the "network bit", which is similar to the class number in the student ID. As long as the network bits of two IPs are the same, they are on the same network segment.

The part after the IP address is called the "host bit", which represents the individual number of the host, similar to the number in the student ID number that the teacher calls out every time.

So whether two IPs are in the same network segment depends on whether their network bits are the same.

The role of network mask

Distinguish between network bits and host bits

Network bit: identifies which broadcast domain this IP address is in

Host bit: IP address that can be assigned to the host

A 1 in the subnet mask represents the network bit

0 in the subnet mask represents the host bit

For example:

The IP address: 192.168.1.1

Its subnet mask: 255.255.255.0

After conversion into binary system, it is as follows

11111111.11111111.11111111.00000000

So the first 24 bits are its network bits and the remaining 8 bits are the host bits

The representation method is: 192.168.1.1/24

2.2 Classification of IPv4 addresses

According to usage scenario (scope)

IPv4 address limited address 2^32 -- about 4.2 billion

Private address -- free to use, local uniqueness

Public address - paid for use, globally unique

IPv4 addresses are divided into five types according to different network IDs: Class A addresses, Class B addresses, Class C addresses, Class D addresses and Class E addresses.

1. Class A IP address : A Class A IP address consists of a 1-byte (8-bit) network address and a 3-byte host address. The highest bit of the network address must be "0", and the address range is from 1.0.0.0 ~126.0 .0.0. There are 126 (2^7-2) Class A networks available, and each network can accommodate more than 100 million (2^24-2) hosts.

2. Class B IP address : A Class B IP address consists of a 2-byte network address and a 2-byte host address. The highest bit of the network address must be "10", and the address range is from 128.0.0.0~191.255. 255.255. There are 16,382 (2^14-1) Class B networks available, and each network can accommodate more than 60,000 (2^16-2) hosts.

3. Class C IP address : A Class C IP address consists of a 3-byte network address and a 1-byte host address. The highest bit of the network address must be "110". The range is from 192.0.0.0~223.255.255.255 . Class C networks can reach more than 2.09 million (2^21-1), and each network can accommodate 254 (2^8-2) hosts.

4. Class D address : The first byte of the Class D IP address starts with "lll0", which is a specially reserved address. it does not point to a specific network

5. Class E IP address : starts with "llll0" and is reserved for future use. An all-zero ("0.0.0.0") address corresponds to the current host. The IP address with all "1"s ("255.255.255.255") is the broadcast address of the current subnet.

Among them, the ABC three-category address is a unicast address, the D-category address is a multicast address, and the E-category address is used for scientific research and is reserved.

Unicast address: can be used as both a source address and a destination address

Multicast address: can only be used as a destination address

Main class network: By default, the network bits of ABC class three addresses have the default subnet mask length.

A  /8    255.0.0.0

B  /16   255.255.0.0

C  /24   255.255.255.0

Private address range:

A:10.0.0.0/8

B:172.16.0.0/16-172.31.0.0/16

C:192.168.0.0/24-192.168.255.0/24

Special IP address:

0.0.0.0/0 invalid address/default address/default address

Function: Represents all IP addresses in the network

255.255.255.255 restricted broadcast address

Function: broadcast address, can only be used as a target address, indicating that the target is all IP addresses

127.0.0.1 local loopback address

Function: Used to detect whether the TCP/IP protocol stack can properly encapsulate and decapsulate data. It exists by default on the PC after the system installation is completed.

Used to detect the quality of the network card --- use the test connectivity command PING

Ping 127.0.0.1

3. Local private address 

3.1 169.254.xx/16 local private address

Function: When the PC cannot obtain an IP address by automatically obtaining an IP address, the PC will automatically generate an IP address, namely 169.254.xx/16

192. 168. 1. 0/24 host bits     all 0 address - network address

An address with all 0 host bits represents a network segment and represents all IP addresses in this network segment --- All students in class xxx

Representative address range: 192.168.1.1/24-192.168.1.255/24

This address cannot be used by the host

192. 168. 1. 255/24   address with all 1 host bits - broadcast address

The address with all 1's in the host bit represents the broadcast address in this network segment and can only be used as a target address; it cannot be used by the host ---@everyone in the xx class group

Within a network segment, except for the addresses with all host bits all 0 and host bits all 1, the remaining addresses can be used by the host.

Example 1. Write the available address range, number of available hosts, broadcast address and network address of 192.168.1.0/24

Number of available hosts:

254 =2^host bit-2= 2^8-2

Available address ranges:

192.168.1.1/24-192.168.1.254/24

Network address 192.168.1.0/24

Broadcast address 192.168.1.255

Example 2. Write the available address range, number of available hosts, broadcast address and network address of 172.16.3.0/16

172.16.3.0/16、

Number of available hosts:

65534=2^16-2

Available address ranges:

172.16.0.1/16-172.16.255.254/16

2^Host bit-2

Network address 172.16.0.0/16

Broadcast address 172.16.255.255/16

In order to solve the needs of few private addresses and flexible applications

 VLSM variable length subnet mask -- subnetting

Logically divide the original large broadcast domain into several small broadcast domains

Method: By borrowing the host bit to act as the network bit, achieve

Example 1. Borrow 1 bit to divide 2 broadcast domains - 2 network segments

192.168.1.0/24

192.168.1.00000000/24+1=25

192.168.1.10000000/24+1=25

192.168.1.0/25

Available address range : 192.168.1.1/25-192.168.1.126/25

Number of available hosts: 126=2^25-2

Network address : 192.168.1.0/25

Broadcast address :192.168.1.127/25

192.168.1.128/25

Available address range : 192.168.1.129/25-192.168.1.254/25

Number of available hosts : 126

Network address : 192.168.1.128/25

Broadcast address :192.168.1.255/25

Example 2. Borrow 2 bits to divide 4 broadcast domains--4 network segments

192.168.1.0/24

192.168.1.00000000/24+2=26

192.168.1.01000000/24+2=26

192.168.1.10000000/24+2=26

192.168.1.11000000/24+2=26

192.168.1.0/26

Network address : 192. 168. 1. 0/26 _

Broadcast address : 192. 168. 1. 63/26 _

Available address range : 192. 168. 1. 1/26 - 192. 168. 1. 62/26 _

Number of available addresses : 62 = 2^6-2

192.168.1.64/26

Network address: 192.168.1.64/26

Broadcast address: 192.168.1.127/26

Available address range: 192.168.1.65/26 - 192.168.1.126/26

Number of available addresses: 62 = 2^6-2

192.168.1.128/26

Network address: 192.168.1.128/26

Broadcast address: 192.168.1.191/26

Available address range: 192.168.1.129/26 - 192.168.1.190/26

Number of available addresses: 62 = 2^6-2

192.168.1.192/26

Borrow 3 bits to divide 8 broadcast domains--8 network segments

192.168.1.0/24

192.168.1.00000000/24+3=27

192.168.1.00100000/24+3=27

192.168.1.01000000/24+3=27

192.168.1.01100000/24+3=27

192.168.1.10000000/24+3=27

192.168.1.10100000/24+3=27

192.168.1.11000000/24+3=27

192.168.1.11100000/24+3=27

192.168.1.0/27

Network address: 192.168.1.0/27

Broadcast address: 192.168.1.31/27

Available address range: 192.168.1.1/27 - 192.168.1.30/27

Number of available addresses: 30 = 2^5-2

192.168.1.32/27

192.168.1.64/27

192.168.1.96/27

192.168.1.128/27

192.168.1.160/27

192.168.1.192/27

192.168.1.224/27

Number of divided network segments = 2^ borrowed bits

Number of available hosts = 2^ host bits -2 ( network address , broadcast address )

Available address range = network address + 1 - broadcast address - 1

The relationship between divided network segments :

Simple algorithm :

First : you must find the first segment address , and then increment the network segment . The incremented value is the representative number of the lowest bit ( the rightmost bit ) of the borrowed bit ( that is, the mask : for example : /27 is the representative number of the 27th bit )

172. 16. 000000 01.0 0000000/22 borrow 3 bits --  8 network segments 172. 16. 0. 0/25 _ _ _

172.16.0.128/25

172.16.1.0/25

172.16.1.128/25

172.16.2.0/25

172.16.2.128/25
172.16.3.0/25

172.16.3.128/25

(2) CIDR Classless Inter-Domain Routing---Summary

Aggregate multiple small broadcast domains into one large broadcast domain

Method: The parent network number is the same, take the same bits, and remove the different bits

192.168.00000001.0/24

192.168.00000010.0/24

192.168.00000011.0/24

192.168.0.0/24

The first 22 digits are the same:

192.168.0.0/22  < 24

Supernet--The length of the summarized subnet mask is smaller than the length of the subnet mask of the main network

Main class network---Default subnet mask length

Category C/24

Guess you like

Origin blog.csdn.net/nuhao/article/details/131461902