The most complete version: Introduction to IPv4 addresses

1. What is an IP address ?

An IP address is used to identify a node (or interface of a network device) in the network.

IP addresses are used to address IP packets in the network.

2. IP address representation

An IPv4 address has 32 bits.

IPv4 addresses are usually expressed in dotted decimal notation.

IPv4 address range: 0.0.0.0~255.255.255.255.

3. IP address composition

Network part: used to identify a network.

Host part: used to distinguish different hosts within a network.

network part

Host part

Network mask: distinguishes the network part and the host part of an IP address.

    

4. IP address addressing

Network part: used to identify a network and represents the network to which the IP address belongs.

Host part: used to distinguish different hosts within a network and can uniquely identify a device on the network segment.

  • The network number is used to indicate the network where the host is located, similar to the role of "XX community in XX district in XX province XX city".
  • The host number is used to represent a specific host interface within the network range defined by the network number, similar to the role of the house number "XX Building No. XX".
  • Network addressing:
    • Layer 2 network addressing: The corresponding host interface can be found directly through the IP address.
    • Layer 3 network addressing: Use gateways to forward data packets from different network segments.
  • Gateway:
    • During packet forwarding, you first need to determine the forwarding path and the interface leading to the destination network segment. If the destination host and the source host are not in the same network segment, the packet needs to be forwarded to the gateway first, and then the packet is forwarded to the destination network segment through the gateway.
    • A gateway refers to a device that receives and processes packets sent by hosts in the local network segment and forwards them to the destination network segment. To achieve this function, the gateway must know the route of the destination network segment. The interface address on the gateway device connected to the local network segment is the gateway address of the network segment.

5. IP address classification ( classful addressing )

In order to facilitate the management and networking of IP addresses, IP addresses are divided into five categories:

Class A/B/C default netmask

Class A: 8 bit, 0.0.0.0~127.255.255.255/8

Class B: 16 bit, 128.0.0.0~191.255.255.255/16

Class C: 24 bit, 192.0.0.0~223.255.255.255/24

  • In order to facilitate the management and networking of IP addresses, IP addresses are divided into five categories:
    • The category fields of categories A, B, C, D, and E are binary numbers 0, 10, 110, 1110, and 1111 respectively. The first few bits of the network number field can be used to determine which category the IP address belongs to. This is to distinguish each category. Class address is the simplest way.
    • The three types of addresses A, B, and C are unicast IP addresses (except for some special addresses). Only these three types of addresses can be assigned to host interfaces.
    • Class D addresses are multicast IP addresses.
    • Class E addresses are reserved for special experimental purposes.
    • This section only focuses on three types of addresses: A, B, and C.
  • Comparison of Class A, B, and C addresses:
    • A network using Class A addresses is called a Class A network; a network using Class B addresses is called a Class B network; and a network using Class C addresses is called a Class C network.
    • The network number of Class A network is 8 bits, which is very small, but the number of allowed host interfaces is large; the first bit is always 0, and the address space is: 0.0.0.0~127.255.255.255.
    • The network number of Class B network is 16 bits, which is between Class A and Class C networks; the first two bits are constant 10, and the address space is: 128.0.0.0~191.255.255.255.
    • The network number of Class C network is 24 bits, which is a large number, but the number of allowed host interfaces is very small; the first three digits are always 110, and the address space is: 192.0.0.0~223.255.255.255.
  • Note:
    • Host usually refers to the collective name of router and computer. And the IP address of a certain interface of the host is often referred to as the host IP address.
    • Multicast address: Multicast can realize one-to-many delivery of messages.

6. IP address type

We usually call the network range defined by a network number a network segment.

Network address: Used to identify a network.

For example: 192.168.10.0/24

192.

168.

10.

00000000

Broadcast address : A special address used to send data to all hosts on the network.

For example: 192.168.10.255/24

192.

168.

10.

11111111

Available addresses : Addresses that can be assigned to nodes or network device interfaces in the network.

For example: 192.168.10.1/24

192.

168.

10.

00000001

  • website address
    • The network number is X, and every bit of the host number is 0.
    • It cannot be assigned to a specific host interface for use.
  • broadcast address
    • The network number is X, and each bit of the host number is 1.
    • It cannot be assigned to a specific host interface for use.
  • Available addresses
    • Also called a host address, it can be assigned to a specific host interface.
  • Calculation of the number of available addresses in a network segment:

If the host bits of a network segment are n bits, the number of IP addresses is: 2ⁿ, and the number of available IP addresses is: 2ⁿ-2 (minus the network address and broadcast address).

7. Private IP address

Public IP address: IP addresses are uniformly assigned by IANA to ensure the uniqueness of any IP address on the Internet. The IP address here refers to the public IP address.

Private network IP address: In fact, some networks do not need to be connected to the Internet, such as the network in a closed laboratory of a university, as long as the IP addresses of network devices in the same network do not conflict. In the IP address space, some addresses in the three types of addresses A, B, and C are reserved specifically for the above situations, which are called private IP addresses.

  • In order to solve the problem of IP address shortage, the concept of private address was proposed. Private addresses refer to internal network or host addresses. These addresses can only be used on a certain internal network and cannot be used on public networks.
    • Public IP address: Network devices connected to the Internet must have a public IP address assigned by ICANN.
    • Private IP address: The use of private IP addresses allows the network to expand more freely, because the same private IP address can be reused in different private networks.

Private network connected to the Internet: The private network is not allowed to connect to the Internet because it uses a private IP address. Later, driven by actual needs, many private networks also hoped to be connected to the Internet to realize communication between private networks and the Internet, and between private networks and private networks through the Internet. The interconnection between the private network and the Internet must be achieved using Network Address Translation (NAT) technology.

    • NAT (Network Address Translation), network address translation, its basic function is to realize the conversion between private network IP address and public network IP address.
    • IANA (Internet Assigned Numbers Authority), Internet address allocation organization.

8. Special IP address

There are some special IP addresses in the IP address space. These IP addresses have special meanings and functions. Examples are as follows.

Guess you like

Origin blog.csdn.net/yuyeconglong/article/details/132863153