📜 ⬆️ ⬇️

Everything about IP addresses and how to work with them

Good day, dear readers of Habr!

Not so long ago I wrote my first article on Habr. In my article there was one unpleasant roughness that was instantly discovered, users who understood in network administration. The roughness lies in the fact that I entered the wrong IP addresses in the lab. I did this intentionally, since I thought it would be easier for an inexperienced user to understand the VLAN topic on a simpler IP example, but, as it was, quite rightly, noticed by users, you can’t post material with a key error.

In the article itself, I did not correct this mistake, since removing our entire discussion would be meaningless in 2 days, but decided to correct it in a separate article indicating problems and explaining the whole topic.
')
To begin with, it is worth saying what an IP address is .

IP address is a unique network address of a node in a computer network built on the basis of the TCP / IP protocol stack (TCP / IP is a set of Internet protocols, which we will discuss in further articles). An IP address is a series of 32 binary bits (ones and zeros). Since a person is immune to a large homogeneous series of numbers, such as this 11100010101000100010101110011110 (here, by the way, 32 bits of information, since there are 32 numbers in the binary system), it was decided to divide the series into four 8-bit bytes and get the following sequence: 11100010.10100010. 00101011.10011110. It didn’t make life much easier and there was a decision to translate this sequence into the usual four-digit sequence in the decimal system, that is, 226.162.43.158. 4 digits are also called octets . This IP address is determined by IPv4 . With this addressing scheme, you can create more than 4 billion IP addresses .

The maximum possible number in any octet will be 255 (since it is 8 units in the binary system), and the minimum is 0 .

Next, let's deal with what is called the class IP (it was at this point in the laboratory work there was an inaccuracy).

IP addresses are divided into 5 classes (A, B, C, D, E). A, B and C are commercial addressing classes. D is for multicast, and class E is for experimentation.

Class A: 1.0.0.0 - 126.0.0.0, mask 255.0.0.0
Class B: 128.0.0.0 - 191.255.0.0, mask 255.255.0.0
Class C: 192.0.0.0 - 223.255.255.0, mask 255.255.255.0
Class D: 224.0.0.0 - 239.255.255.255, mask 255.255.255.255
Class E: 240.0.0.0 - 247.255.255.255, mask 255.255.255.255

Now about the "color" IP. IP are white and gray (or public and private ). A public IP address is an IP address that is used to access the Internet . Addresses used in local area networks are classified as private . Private IPs are not routed on the Internet.

Public addresses are assigned to public web servers so that a person can get to this server, regardless of its location, that is, via the Internet. For example, game servers are public, as well as the north of Habr and many other web resources.
The big difference between private and public IP addresses is that using a private IP address, we can assign any number to a computer (the main thing is that there are no matching numbers ), and with public addresses everything is not so simple. The issuance of public addresses is controlled by various organizations.

Suppose you are a young network engineer and want to give access to your server to all Internet users. For this you need to get a public IP address. To get it, you contact your Internet provider , and he gives you a public IP address, but he cannot take it from the sleeve, so he contacts the local Internet registrar (LIR), which issues a packet of IP addresses to your provider, And the provider from this pack gives you one address. The local Internet registrar cannot issue a packet of addresses from nowhere, so he contacts the regional Internet registrar (RIR). In turn, the regional Internet registrar addresses the international non-profit organization IANA (Internet Assigned Numbers Authority). ICANN (Internet Corporation for Assigned Names and Numbers) controls the operation of the IANA organization. Such a complex process is necessary in order to avoid confusion in public IP addresses.



Since we are engaged in the creation of local area networks (LAN - Local Area Network), we will use private IP addresses. To work with them, it is necessary to understand which addresses are private and which are not. The table below lists private IP addresses that we will use when building networks.



From the above, we conclude that to use when creating a local network follows the addresses from the range in the table. When using any other network addresses, such as 20. *. *. * Or 30. *. *. * (For example, I took these addresses, as they were used in the lab), there will be big problems with setting up a real network.

From the table of private IP addresses you can see the third column in which the subnet mask is written. The subnet mask is a bitmask that determines which part of the IP address of a network node refers to the network address, and which part refers to the address of the node itself on that network.

All IP addresses have two parts a network and a node .
The network is the part of the IP that does not change throughout the network and all device addresses begin with the network number.
A node is a changing part of IP. Each device has its own unique address on the network; it is called a node.

Mask can be written in two ways: prefix and decimal . For example, the mask of a private subnet A looks in decimal notation as 255.0.0.0, but it is not always convenient to use a decimal notation when plotting a network. It is easier to write the mask as a prefix, i.e. / 8.

Since the mask is formed by adding to the left a unit from the first octet and nothing else, but to recognize the mask we only need to know the number of units set.

Subnet Mask Table



Let us calculate how many devices (in the IP addresses of the nodes) can be in the network, where one computer has the address 172.16.13.98 / 24.

172.16.13.0 - network address
172.16.13.1 - the address of the first device in the network
172.16.13.254 - the address of the last device on the network
172.16.13.255 - broadcast IP address
172.16.14.0 - the address of the next network

Total 254 devices on the network

Now let's calculate how many devices can be on the network, where one computer has the address 172.16.13.98 / 16.
172.16.0.0 - network address
172.16.0.1 - the address of the first device in the network
172.16.255.254 - the address of the last device on the network
172.16.255.255 - broadcast IP address
172.17.0.0 - the address of the next network

Total 65534 devices on the network

In the first case, we got 254 devices, in the second one 65534, and we replaced only the mask number.

You can view various options for working with masks in any IP calculator. I recommend this one .

Before the technology of subnet masks (VLSM - Variable Langhe Subnet Mask) was invented, the class networks we talked about earlier were used.

Now it is worth mentioning about such IP addresses that are used for specific needs.

Address 127.0.0.0 - 127.255.255.255 (loopback - loop on itself). This network is needed for diagnostics.
169.254.0.0 - 169.254.255.255 (APIPA - Automatic Private IP Addressing). The mechanism of "inventing" the IP address. APIPA service generates IP addresses to start working with the network.

Now that I have explained the topic of IP, it becomes clear why the network represented in the lab will not work without problems. This should be avoided, so correct the errors based on the information in this article.

Link to the lab

Source: https://habr.com/ru/post/350878/


All Articles