109.1 Lesson 1
Certificate: |
LPIC-1 |
---|---|
Version: |
5.0 |
Topic: |
109 Networking Fundamentals |
Objective: |
109.1 Fundamentals of internet protocols |
Lesson: |
1 of 2 |
Introduction
The TCP/IP (Transmission Control Protocol/Internet Protocol) is a stack of protocols used to enable communication between computers. Despite the name, the stack consists of several protocols such as IP, TCP, UDP, ICMP, DNS, SMTP, ARP and others.
IP (Internet Protocol)
The IP is the protocol responsible for the logical addressing of a host, enabling the packet to be sent from one host to another. For this each device on the network is assigned a unique IP address, and it is possible to assign more than one address to the same device.
In the version 4 of the IP protocol, usually called IPv4, the address is formed by a set of 32 bits separated into 4 groups of 8 bits, represented in decimal form, called “dotted quad”. For example:
- Binary format (4 groups of 8 bits)
-
11000000.10101000.00001010.00010100
- Decimal format
-
192.168.10.20
In IPv4, the values for each octet can range from 0 to 255, which is the equivalent of 11111111 in binary format.
Address Classes
Theoretically, IP addresses are separated by classes, which are defined by the range of the first octet as shown in the table below:
Class | First Octect | Range | Example |
---|---|---|---|
A |
1-126 |
|
|
B |
128-191 |
|
|
C |
192-223 |
|
|
Public and Private IPs
As mentioned earlier, for communication to occur each device on the network must be associated with at least one unique IP address. However, if each device connected to the Internet in the world had a unique IP address, there would not be enough IPs (v4) for everyone. For this, private IP addresses were defined.
Private IPs are ranges of IP addresses that have been reserved for use in the internal (private) networks of companies, institutions, homes, etc. Within the same network, the use of an IP address remains unique. However, the same private IP address can be used within any private network.
Thus, on the Internet we have data traffic using public IP addresses, which are recognizable and routed over the Internet, while within private networks these reserved IP ranges are used. The router is responsible for converting traffic from the private network to the public network and vice versa.
The ranges of Private IPs, separated by classes, can be seen in the table below:
Class | First Octet | Range | Private IPs |
---|---|---|---|
A |
1-126 |
|
|
B |
128-191 |
|
|
C |
192-223 |
|
|
Converting from Decimal Format to Binary
For the subjects of this topic, it is important to know how to convert IP addresses between binary and decimal formats.
The conversion from decimal format to binary is done through consecutive divisions by 2. As an example, let’s convert the value 105 by the following steps:
-
Dividing the value 105 by 2 we have:
105/2 Quotient = 52 Rest = 1
-
Divide the quotient sequentially by 2, until the quotient is equal to 1:
52/2 Rest = 0 Quotient = 26
26/2 Rest = 0 Quotient = 13
13/2 Rest = 1 Quotient = 6
6/2 Rest = 0 Quotient = 3
3/2 Rest = 1 Quotient = 1
-
Group the last quotient followed by the remainder of all divisions:
1101001
-
Fill in 0s to the left until 8 bits are completed:
01101001
-
In the end, we have that the value 105 in decimal is equal to 01101001 in binary.
Converting from Binary Format to Decimal
In this example, we will use the binary value 10110000
.
-
Each bit is associated with a value with a base power of two. The powers are started at 0, and are incremented from right to left. In this example we will have:
1
0
1
1
0
0
0
0
27
26
25
24
23
22
21
20
-
When the bit is 1, we assign the value of the respective power, when the bit is 0 the result is 0.
1
0
1
1
0
0
0
0
27
26
25
24
23
22
21
20
128
0
32
16
0
0
0
0
-
Add up all values:
128 + 32 + 16 = 176
-
Thus, 10110000 in binary is equal to 176 in decimal.
Netmask
The network mask (or netmask) is used in conjunction with the IP address to determine which part of the IP represents the network and which represents the hosts. It has the same format as the IP address, that is, there are 32 bits in 4 groups of 8. For example:
Decimal | Binary | CIDR |
---|---|---|
|
|
|
|
|
|
|
|
|
Using the 255.255.0.0
mask as an example, it indicates that in the IP associated with it, the first 16 bits (2 first decimals) identify the network/subnet and the last 16 bits are used to uniquely identify the hosts within the network.
The CIDR (Classless Inter-Domain Routing) mentioned above is related to a simplified mask notation, which indicates the number of bits (1) associated with the network/subnet. This notation is commonly used to replace the decimal format, for example /24
instead of 255.255.255.0
.
It is interesting to note that each class of IP has a standard mask, as follows:
Class | First Octet | Range | Default Mask |
---|---|---|---|
A |
1-126 |
|
|
B |
128-191 |
|
|
C |
192-223 |
|
|
However, this pattern does not mean that this is the mask that will always be used. It is possible to use any mask with any IP address, as we will see below.
Here are some examples of using IPs and Masks:
192.168.8.12 / 255.255.255.0 / 24
- Range
-
192.168.8.0
-192.168.8.255
- Network Address
-
192.168.8.0
- Broadcast Address
-
192.168.8.255
- Hosts
-
192.168.8.1
-192.168.8.254
In this case we have the first 3 digits (first 24 bits) of the IP address define the network and the final digit identifies the addresses of the hosts, that is, the range of this network goes from 192.168.8.0
to 192.168.8.255
.
We now have two important concepts: Every network/subnet has 2 reserved addresses, the first address in the range is called the network address. In this case 192.168.8.0
, which is used to identify the network/subnet itself. The last address in the range is called the broadcast address, in this case 192.168.8.255
. This destination address is used to send the same message (packet) to all IP hosts on that network/subnet.
The network and broadcast addresses cannot be used by the machines on the network. Therefore, the list of IPs that can be effectively configured ranges from 192.168.8.1
to 192.168.8.254
.
Now the example of the same IP, but with a different mask:
192.168.8.12 / 255.255.0.0 / 16
- Range
-
192.168.0.0
-192.168.255.255
- Network Address
-
192.168.0.0
- Broadcast Address
-
192.168.255.255
- Hosts
-
192.168.0.1
–192.168.255.254
See how the different mask changes the range of IPs that are within the same network/subnet.
The division of networks by masks is not restricted to the default values (8, 16, 24). We can create subdivisions as desired, adding or removing bits in the network identification, creating the new subnets.
For example:
11111111.11111111.11111111.00000000 = 255.255.255.0 = 24
If we want to subdivide the network above into 2, just add another bit to the network identification in the mask, like this:
11111111.11111111.11111111.10000000 = 255.255.255.128 = 25
We have then the following subnets:
192.168.8.0 - 192.168.8.127 192.168.8.128 - 192.168.8.255
If we further increase the subdivision of the network:
11111111.11111111.11111111.11000000 = 255.255.255.192 = 26
We will have:
192.168.8.0 - 192.168.8.63 192.168.8.64 - 192.168.8.127 192.168.8.128 - 192.168.8.191 192.168.8.192 - 192.168.8.255
Note that in each subnet we will have the reserved network (the first in the range) and broadcast (the last in the range) addresses, so the more the network is subdivided, the fewer IPs can be effectively used by the hosts.
Identifying the Network and Broadcast Addresses
Through an IP Address and a Mask, we can identify the network address and the broadcast address, and thus define the range of IPs for the network/subnet.
The network address is obtained by using a “Logical AND” between the IP address and the mask in their binary formats. Let’s take the example using IP 192.168.8.12
and mask 255.255.255.192
.
Converting from decimal to binary format, as we saw earlier, we have:
11000000.10101000.00001000.00001100 (192.168.8.12) 11111111.11111111.11111111.11000000 (255.255.255.192)
With “Logical AND”, we have 1 and 1 = 1, 0 and 0 = 0, 1 and 0 = 0, so:
11000000.10101000.00001000.00001100 (192.168.8.12) 11111111.11111111.11111111.11000000 (255.255.255.192) 11000000.10101000.00001000.00000000
So the network address for that subnet is 192.168.8.0
.
Now to obtain the broadcast address, we must use the network address where all bits related to the host address to 1:
11000000.10101000.00001000.00000000 (192.168.8.0) 11111111.11111111.11111111.11000000 (255.255.255.192) 11000000.10101000.00001000.00111111
The broadcast address is then 192.168.8.63
.
In conclusion, we have:
192.168.8.12 / 255.255.255.192 / 26
- Range
-
192.168.8.0
-192.168.8.63
- Network Address
-
192.168.8.0
- Broadcast Address
-
192.168.8.63
- Hosts
-
192.168.8.1
–192.168.8.62
Default Route
As we have seen so far, machines that are within the same logical network/subnet can communicate directly via the IP protocol.
But let’s consider the example below:
- Network 1
-
192.168.10.0/24
- Network 2
-
192.168.200.0/24
In this case, the 192.168.10.20
machine cannot directly send a packet to the 192.168.200.100
, as they are on different logical networks.
To enable this communication a router (or a set of routers) is used. A router in this configuration can also be called a gateway as it provides a gateway between two networks. This device has access to both networks as it is configured with IPs from both networks. For example 192.168.10.1
and 192.168.200.1
, and for this reason it manages to be the intermediary in this communication.
To enable this, each host on the network must have configured what is called the default route. The default route indicates the IP to which all packets whose destination is an IP that is not part of the host’s logical network must be sent.
In the example above, the default route for machines on the 192.168.10.0/24
network will be the IP 192.168.10.1
, which is the router/gateway IP, while the default route for machines on the 192.168.200.0/24
network will be 192.168.200.1
.
The default route is also used so that machines on the private network (LAN) have access to the Internet (WAN), through a router.
Guided Exercises
-
Using the IP
172.16.30.230
and netmask255.255.255.224
, identify:The CIDR notation for the netmask
Network address
Broadcast address
Number of IPs that can be used for hosts in this subnet
-
Which setting is required on a host to allow an IP communication with a host in a different logical network?
Explorational Exercises
-
Why are the IP ranges starting with
127
and the range after224
not included in the IP address classes A, B or C? -
One of the fields belonging to an IP packet that is very important is TTL (Time To Live). What is the function of this field and how does it work?
-
Explain the function of NAT and when it is used.
Summary
This lesson covered the main concepts for the IPv4 protocol, which is responsible for enabling communication between hosts on a network.
The main operations that the professional must know in order to convert the IPs in different formats, and to be able to analyze and perform the logical configurations on networks and subnets were also studied.
The following subjects were addressed:
-
IP addresses classes
-
Public and private IPs
-
How to convert IPs from decimal to binary format, and vice versa
-
The network mask (netmask)
-
How to identify the network and broadcast addresses from IP and netmask
-
Default route
Answers to Guided Exercises
-
Using the IP
172.16.30.230
and netmask255.255.255.224
, identify:The CIDR notation for the netmask
27
Network address
172.16.30.224
Broadcast address
172.16.30.255
Number of IPs that can be used for hosts in this subnet
30
-
Which setting is required on a host to allow an IP communication with a host in a different logical network?
Default route
Answers to Explorational Exercises
-
Why are the IP ranges starting with
127
and the range after224
not included in the IP address classes A, B or C?The range that starts with
127
is reserved for loopback addresses, used for tests and internal communication between processes, such as the address127.0.0.1
. In addition, addresses above224
are also not used as host addresses, but for multicast and other purposes. -
One of the fields belonging to an IP packet that is very important is TTL (Time To Live). What is the function of this field and how does it work?
TTL defines the lifetime of a packet. This is implemented through a counter in which the initial value defined at the source is decremented in each gateway/router through which the packet passes, which is also called a “hop”. If this counter reaches 0 the packet is discarded.
-
Explain the function of NAT and when it is used.
The NAT (Network Address Translation) feature allows hosts on an internal network, which uses private IPs, to have access to the Internet as if they were directly connected to it, with the Public IP used on the gateway.