User Tools

Networking

Networking is the concept of connection two or more computers together so that they can exchange data trough some kind of transport medium.

The ISO/OSI model describe networking as a stack of protocols which spans from the physical level to the most abstract high-level logical layer. At the physical level for home usage we usually refer to wired ethernet or wireless WiFi protocols, while at network level we usually refer to IP (either v4 or v6).

More details on the physical layers can be found Wired Backbone|here and here, but before heading down trough that rabbit hole, i prefer to brush up some core concepts of IP networking.

Addresses

If you have a network of computers, also referred as hosts, you need a way address each one, like for a home address which you need to receive your mail or your services (power, water, garbage…). Each host in a network must have it's own address, which means that the network itself needs to have an address configuration.

I am referring to IP neworks, and for clarity i will always use IPv4 addressing examples. IPv6 is more evolved, but also somehow still far away. Maybe i will bother in the future to adapt all these pages to IPv6 examples as well.

The way IPv4 define an address is by using four bytes, and it is displayed as a sequence of four numbers (between 0 and 255) separated by dots, like:

192.168.0.1

This sequence of numbers identifies one host in a subnetwork. You can see the 4 bytes as a sequence of 32bits and those bits are separated between the subnet part and the host part and is represented like:

192.168.0.1/24 -> 192.168.0 (subnet) + 1 (host)

in this example, we have a 24-bit subnet which defines:

  • The left-most (always!) 24bit are the subnet address: 192.168.0.0
  • The right-most 8bit are the host address: 192.168.0.1

Please note that no matter how many bits the subnet mask is, we always refer to a subnet or host address with 4 full bytes. Maybe it's stupid, but this is customary.

Address assignment

the IP addresses are subdivided into private and public addresses. When assigning IP addresses to your home network you want always to use a private block because using a public one will cause a mess on the overall routing and is better avoided.

This page summarize quite well what are the private subnets that you should use. This page will get in more details on the subject.

Well, first of all let's assume you have planned your network and defined your subnet address, now how can those addresses be assigned to your hosts? You have two ways:

  • Static assignment, by manually setting a different IP to each device on the network
  • Dynamically, by using the DHCP protocol to let devices obtain their address
  • Mixed, by using a DHCP but at the same time assigning some hosts address statically

While running a fully static network is simple enough, today's WiFi networking where devices like phones, tablets and laptops come and go make a fully static network outdated and limited.

At the same time, a fully dynamic network might be overkill as at least some devices are not mobile and will most probably never need to change address. Good examples are IoT devices, smart appliances, TV boxes, webcams and such.

The protocol behind a dynamic or mixed network is a DHCP server, see Dynamic Host Configuration Protocol, which is how your devices can automatically get an IP address when they connect to your home network. Additional information will be passed to the device, like gateway address and DNS server, using DHCP.

I will show you how to setup a DHCP server for your home.

Names resolution

Nobody wants to remember a numeric sequence of four bytes (even worse in IPv6), even less thousand of those sequences. It's much better to assign a human-readable name to a host and use that to reach it. In order for this to work, we need a specific protocol to translate a name to an IP address, otherwise you would not be able to navigate or actually do anything meaningful on the internet.

The protocol behind names resolution it a DNS srver, see here.

The DNS (Domain Name System) is how names are converted to addresses on the internet. Historically one of the oldest Internet Services still in use today, it suffers from a lot of drawbacks and issues, specially on the privacy side of things. The original plain-text protocol (on port 53, UDP) has been extended over the years with a few improvements like DNS over TLS (DoT) and DNS over HTTPS (DoH). Both the new extensions provide more privacy, as the requests are encrypted your ISP and middleman cannot snoop every website you visit, and more robustness as, paired with DNSSEC, it is now more difficult to feed you malicious DNS responses and redirect your traffic to bad websites (think of malaware and such).

I will show you how to setup a forwarding DNS server for your home.

Internet Routing

Now that a device in your network has an address and knows how to translate a name to the address of a destination server, all you need is a proper network routing to allow your devices to connect to those servers: in other words, there must be a way for your network data packets to go from your computer to the destination. On the way it will need to go trough a lot of intermediate devices like firewalls, routers, gateways… This process is called routing.

The basic concept behind routing is that every host is assigned a default gateway where all the traffic which goes outside the local subnet must be directed. This gateway will then take care of those packets and send them away.

The first step of the routing is to get your data packet from your computer out to the internet, trough your ISP (Internet Service Provider). This is the process:

  • You type the destination name (let's assume this name is a server on the internet)
  • The name is translated to it's IP address using the DNS
  • The IP is compared with your computer subnet address
  • Since it doesn't match (different subnet), it's sent to the default gateway
  • The gateway (usually the home router connected to your ISP) will forward the packet upstream to the internet

What happens next is complex and outside the scope of all this, you can learn more looking for the BGP protocol and the likes.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information