Networking fundamentals: a primer
Every service you use, from email to video calls, depends on a network delivering data between devices. You do not need to memorise every protocol to start, but a handful of core ideas explain most of what happens. This primer covers them.
Layers: a way to think about networks
Networking is usually described in layers. The OSI model has seven; the TCP/IP model used on the internet has four. The exact number matters less than the idea: each layer has one job and relies on the layer below it.
- The physical and data-link layers move bits over a cable or radio link between neighbouring devices. Ethernet and Wi-Fi live here, and devices are identified by MAC addresses.
- The network layer moves packets between networks. This is where IP addresses and routers work.
- The transport layer delivers data to the right application on a device, using TCP or UDP and port numbers.
- The application layer is what users see: web browsing, email, name resolution.
When something breaks, layers give you an order in which to check things.
IP addresses and subnets
An IPv4 address such as 192.168.1.20 is 32 bits written as four numbers. A subnet mask, often written as a prefix like /24, says how many of those bits identify the network. In 192.168.1.0/24, the first 24 bits are the network and the last 8 identify hosts. That gives 256 addresses, of which 254 can be assigned to devices: the first is the network address and the last is the broadcast address.
Devices on the same subnet talk to each other directly. To reach anything else they send traffic to their default gateway, usually a router, which forwards it onwards.
Some ranges are reserved for private networks and are not routed on the internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Home and office networks use them, and a router translates them to a public address with network address translation (NAT).
IPv6 uses 128-bit addresses written in hexadecimal, such as 2001:db8::1. It removes the shortage of addresses and is increasingly common, so it is worth learning alongside IPv4.
DHCP and DNS
Two services make networks usable. DHCP hands out IP addresses, subnet masks, default gateways and DNS servers to devices automatically when they join a network. DNS translates names such as example.com into IP addresses. When a website "does not load", the cause is often one of these two: the device has no valid address, or it cannot resolve names.
TCP, UDP and ports
TCP sets up a connection, numbers the data, and retransmits anything that is lost. It is used where every byte matters, such as web pages and file transfers. UDP simply sends datagrams without a connection; it is used where speed matters more than perfection, such as voice and video, and for short queries such as DNS.
Ports identify the application. Some well-known examples: 22 for SSH, 53 for DNS, 80 for HTTP and 443 for HTTPS. A firewall rule usually combines an address, a protocol and a port.
Switches and routers
A switch connects devices within a local network and forwards frames based on MAC addresses. Switches can also split one physical network into several virtual LANs (VLANs). A router connects different networks and forwards packets based on IP addresses, using a routing table built from static routes or routing protocols such as OSPF.
A simple troubleshooting method
When a device cannot reach a service, work from the bottom up:
- Is the link up? Check the cable or Wi-Fi connection.
- Does the device have a valid address? Use
ipconfigon Windows orip aon Linux. - Can it reach its default gateway? Use
pingwith the gateway address. - Can it reach a remote address? Ping a known IP address outside the network.
- Can it resolve names? Use
nslookupordigwith a domain name. - Where does the path stop? Use
tracerton Windows ortracerouteon Linux.
Each answer narrows the problem to one layer, and that is half the solution.
Where to go next
These ideas are the foundation of the CompTIA Network+ course, which is the first step of the network engineer path and part of the IT support foundations path. Build a small lab, even with two virtual machines, and try each command above. Seeing addresses, routes and name lookups for yourself is the fastest way to make them stick.