Study guide · Networking Fundamentals
Networking Fundamentals: How data finds its way and where it is vulnerable
This page explains how networks are built and how data travels from one device to another. You will learn the layer models, addresses, ports and the most important helper services. After that, it covers typical attacks on networks, wireless networks and connected devices all the way to industrial plants. The running example is once again the small online shop with an office, a warehouse and a web server.
Layer models: OSI and TCP/IP
Network communication is complicated. That is why it is split into layers. Each layer does one job and uses the services of the layer below. The best known model is the OSI reference model with seven layers.
- Layer 1, the physical layer, transmits signals over cables or radio.
- Layer 2, the data link layer, delivers frames in the local network based on MAC addresses.
- Layer 3, the network layer, forwards packets between networks based on IP addresses.
- Layer 4, the transport layer, handles transport between programs with TCP or UDP.
- Layers 5 to 7 are called session, presentation and application. Protocols like HTTP work at the very top.
The TCP/IP model describes the protocol family the internet is built on. It has only four layers: network access, internet, transport and application. OSI layers 5 to 7 are combined into its application layer.
These models help you place devices and protocols. A router connects networks and works mainly at layer 3. A classic switch connects devices in the local network and forwards frames to the right port based on MAC addresses, so it works at layer 2. So-called layer 3 switches can also route. TCP and UDP belong to layer 4, IP to layer 3 and HTTP to layer 7. Ethernet sits at layers 1 and 2.
When sending, each layer adds its own control information to the data, a so-called header. This is called encapsulation. The transport layer adds the ports, for example, the network layer the IP addresses and the data link layer the MAC addresses. At the receiver, the headers are removed again layer by layer. Encapsulation has nothing to do with encryption.
Addresses and subnets
Every network card carries a MAC address from the factory. This is its hardware address, 48 bits long. It is used to deliver frames in the local network. Because it can be changed in software, it is not a reliable feature for authentication.
To travel between networks, a device needs an IP address. An IPv4 address is 32 bits long. It is usually written as four decimal numbers separated by dots, such as 192.168.1.10. That gives about 4.3 billion addresses, and they ran short long ago. An IPv6 address is therefore 128 bits long. It is written in eight groups of hexadecimal numbers separated by colons. Many networks today run both protocols side by side.
Home and company networks use private address ranges. These are all addresses starting with 10, the addresses from 172.16 to 172.31 and all addresses starting with 192.168. So 192.168.10.5 is private, while 8.8.8.8 is public. Private addresses are not routed on the internet.
So that the shop's devices can still reach the internet, the router translates private into public addresses. This is called Network Address Translation, or NAT. Many devices share one or a few public addresses this way. As a side effect, internal devices cannot be addressed directly from outside. Still, NAT does not replace a firewall, because it is not a security mechanism in the real sense.
With IPv6 there are enough addresses for every device to have a public one. NAT is usually no longer necessary there. That makes separate firewall rules for IPv6 all the more important. Rules only apply to the protocol they were written for. Suppose the shop filters inbound IPv4 traffic carefully, but its servers also have public IPv6 addresses without rules. Then they are reachable unfiltered from the internet via IPv6. You either secure IPv6 just as well or switch it off where it is not needed. By the way, IPv6 is not automatically encrypted. IPsec was originally planned, but it is not mandatory.
A network is divided into subnets. The prefix length says how many bits of the address belong to the network. It is written after the address with a slash. In the network 192.168.1.0 with prefix 24, 24 bits belong to the network. That leaves 8 bits for devices, so 256 addresses. The first is the network address and the last is the broadcast address. That leaves 254 usable addresses.
Subnets are the basis for segmentation. The shop wants to separate its camera, office and server networks. Each network gets its own subnet. A firewall between the subnets controls which traffic is allowed. Without rules, a router would simply forward everything. The cameras, for example, only need a connection to the recording server, not to the office PCs.
Transport: TCP, UDP and ports
The transport layer has two important protocols. TCP is connection-oriented. It sets up a connection, numbers the data, acknowledges receipt and requests lost packets again. UDP sends packets without setting up a connection and without acknowledgement. In return, it is faster and suits DNS, streaming or voice calls. Neither of them is encrypted; that is the job of higher layers.
A TCP connection begins with the three-way handshake.
- The client sends a SYN packet and asks for a connection.
- The server replies with SYN-ACK and confirms the request.
- The client confirms with ACK. Now the connection is established.
Ports distinguish the services on a device. Firewalls use them to allow or block specific services. Ports from 0 to 1023 are called well-known ports. You should know these standard ports.
- HTTP uses port 80, HTTPS port 443.
- SSH uses port 22, Telnet port 23.
- FTP uses port 21, SMTP for sending mail port 25.
- DNS uses port 53, mostly over UDP and over TCP for larger responses.
- POP3 uses port 110, the Remote Desktop Protocol RDP port 3389.
Some old protocols send credentials unencrypted. Telnet and FTP send user names and passwords in plain text. Anyone listening on the network can simply grab them. SSH replaces Telnet, and SFTP or FTPS replace FTP. The same applies to HTTP compared with HTTPS.
A port scan shows open ports 22, 23, 80, 443 and 3389 on the shop's web server, all reachable from the internet. Port 23 is the most worrying, because Telnet is unencrypted and should not be open anywhere. Port 3389 is just as worrying. RDP from the internet is attacked on a massive scale and belongs behind a VPN or a gateway with multi-factor authentication. SSH should be restricted as well. Ports 80 and 443 are normal for a web server, and port 80 ideally redirects to HTTPS.