Networks v2
Networks v2
Currently, many of the devices around us are connected to the Internet or at least
to our home or office network. Our SmartTV, mobile phones, smartwatches, tablets,
PC, coffee maker (?),...
For this reason, it is important to know in broad terms how our networks work,
which means all those acronyms and words that ask us when we have to configure our
devices.
IP Address
All systems that need to communicate with each other must have an IP address. This
address must be unique and cannot be repeated on the same network. If this happens,
both devices will be cancelled until the dispute is resolved.
Examples:
* 192.168.0.1
* 1.2.3.4
* 195.255.1.37
I will give an example to try to explain this (the data is invented and I will put
it only as an example). Let's say our home router, our PC, a printer and our
favorite internet page.
PC, printer, router: Private ip are available (belonging to our home network)
Router, WEB Page: They have public ip (need a public ip to communicate)
You can see that the router maintains two IP addresses: a public one to access the
external services provided by the Internet, and a private one to interconnect with
the systems of our home network.
Public IP
----------------------------------
WEB page: 104.24.124.114
Router: 85.83.4.127
Private IP
----------------------------------
Router: 192.168.0.1
PC: 192.168.0.10
Printer: 192.168.0.12
We could make an analogy between what was shown above and the telephone system. All
phone numbers are different (public IP), but we have switchboards (routers) that
are capable of routing a call (routing) to different extensions (private IP). These
extensions, looking only at them, can be repeated in different companies or
households.
Netmask
The network mask is used on private networks to indicate the range of a subnet.
169.254.0.0 a 169.254.255.255
224.0.0.0 to 224.0.0.255
224.0.1.0 to 224.0.1.255
224.0.2.0 to 224.0.255.255
224.3.0.0 to 224.4.255.255
232.0.0.0 to 232.255.255.255
233.0.0.0 to 233.255.255.255
233.252.0.0 to 233.255.255.255
234.0.0.0 to 234.255.255.255
239.0.0.0 to 239.255.255.255
Any other IP address will be considered Public. Public IP addresses will generally
be assigned by our Internet service provider, so we won't have to worry about them
(at least not at the moment).
Look again at the range of private IP addresses. As we have indicated, the network
mask specifies the subnet to which a system belongs. In other words, with this
value we indicate to our team if it should send a data (package) to a device of our
subnet or not. In other words, given an IP address and a network mask, we know that
part of that IP address is the value of the subnet and what the host number is.
With the mask we also indicate the maximum number of hosts that can be configured
in a subnet. Another way to indicate the mask is with your CIDR
In this way, and continuing with our example, the most logical thing is that our PC
has:
IP: 192.168.0.10
Netmask: 255.255.255.255.0
192.168.0.10/24
This way our device could communicate directly with any system in our network whose
IP address started at 192.168.0.
On the other hand, if we want 192.168.0 and 192.168.1 networks to see each other
directly, we could use the 255.255.0.0.0 network mask. In this case, you would
really be looking at all the systems whose IPs start with 192.168, regardless of
the next two blocks of numbers.
Gateway
When a system must send a data (package) to a network to which it does not belong,
which it knows from its previously viewed network mask, it will search in its
routing table for the ip address to which it must indicate this data so that it can
be sent to the "outside". That is, if our PC wants to communicate with a system
that is not in your network, you must know an IP to send this data, leaving the
shipping control to that system.
In our example we know that the router has an IP address 192.168.0.1 for our
internal network. We only have this network at home. Therefore, our default route
or gateway should be the router address. Spoken in a colloquial way, if we send a
packet to a system that is not on our network, let's send it to the router that he
will know what to do with it. Internally the router when it receives the packet and
sees the address to which it is destined, it will activate its mechanisms to send
it through its public address abroad, contacting the external system.
Let's take as an example the navigation to a web page. When we write the name of a
page in our browser, the system will first ask our DNS what is the IP address of
the address we are requesting. Our DNS will return to our system an IP address that
will correspond to the page we are requesting.
The "dig" tool allows us to check the ips addresses of a domain name.
┌─[user@parrot]─[~]
└──╼ $dig parrotsec.org
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;parrotsec.org. IN A
;; ANSWER SECTION:
parrotsec.org. 300 IN A 104.24.125.114
parrotsec.org. 300 IN A 104.24.124.114
You can see two important things in this example. The "ANSWER SECTION" section
tells us the IP addresses of parrotsec.org and the SERVER line tells us which DNS
server we asked for.
We can configure our systems with more than one DNS server, in case the main one
fails.
In the previous points we have defined several data that will be essential to
configure our systems and that can be connected:
* IP Address
* Net Mask
* Gateway
* DNS
These values can be configured manually, but can also be set automatically when the
system is connected to the network. These values can be supplied to us and
configured by a DHCP server. Generally, routers come with this feature turned on so
we don't have to worry about anything.
Final Note
Just as we have indicated at the beggining, this document is a brief (very brief)
introduction to networks, and once you understand the basic operation of a network
you should investigate and study its operation more extensively.
* https://rfc-es.org/
* https://www.rfc-editor.org/rfc-index.html
* http://www.tldp.org/HOWTO/Networking-Overview-HOWTO.html