Networking
Beginner 12 min read Networking

Networking Fundamentals

Networks move data between devices using packet switching. Learn the essentials of addressing, routing and the tools every DevOps engineer uses to inspect them.

packet switchingIP addressLANWANroutergatewayping
Introduction

What is this?

A computer network connects devices so they can share data and services. Data travels in small units called packets, each carrying a source and destination address. Hosts on the same local network talk directly over their shared link, while routers forward packets hop by hop between networks.

Motivation

Why do you need it?

  • Every cloud service, container and CI pipeline runs on top of a network — networking knowledge underpins all of DevOps.
  • You cannot debug connectivity, latency or security issues without understanding how packets get from A to B.
  • Designing VPCs, subnets, load balancers and service meshes assumes core networking concepts.
  • Network tools such as ping, traceroute, curl and ss are the first stop in most production incidents.
Think about it

Mental model

Imagine

The postal service

Think of

Packet-switched networking

You drop a letter in a box with a destination address. It travels through sorting offices (routers) hop by hop until it reaches the mailbox that matches the address. Packets do the same, but in milliseconds and without reserving a fixed route.

Mechanics

How it works

  • Each device gets a unique IP address so senders and receivers can be identified.
  • Data is broken into packets; every packet carries the source and destination IP plus metadata.
  • Hosts on the same LAN deliver packets directly; anything outside the LAN is handed to the default gateway (router).
  • Routers inspect each packet's destination address and forward it to the next hop, one link at a time.
  • The destination reassembles the packets into the original data and delivers it to the application.

A packet's journey from one host to another across routers.

Application
Encapsulation
Router hop
Local or remote?
Local delivery
Destination host
Reference

Key commands

ip addr show

List all network interfaces and their assigned IP addresses.

ip route

Show the routing table, including the default gateway.

ping -c 4 8.8.8.8

Send 4 ICMP echo requests to verify reachability and measure latency.

traceroute example.com

Show every router hop between you and the destination.

ss -tulpn

List listening TCP/UDP sockets and the processes behind them.

Hands-on

Examples

Verify connectivity with ping

Verify connectivity with ping
$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=12.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=12.3 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms

ping sends ICMP echo requests (RFC 792). Replies prove the host is reachable; the TTL shows how many router hops the packet survived and the round-trip time is latency. Use ping first whenever anything feels slow or unreachable.

Real world

In production

  • Latency and packet loss between regions drive topology decisions in multi-region deployments.
  • Round-trip time from ping becomes the baseline for detecting network saturation or DDoS.
  • ip addr and ip route are the standard first checks when a container, VM or host has no connectivity.
  • Understanding LAN versus routed traffic explains why two services in one VPC talk directly while cross-VPC traffic traverses gateways.
Guidelines

Best practices

  • Work top-down: ping the loopback, then the gateway, then the public internet.
  • Use hostnames in tooling but confirm the resolved IP matches the expected endpoint.
  • Check both directions — outbound from a host and inbound to it — before blaming the network.
  • Document your network layout (subnets, gateways, firewalls) so incidents are faster to triage.
Watch out

Common mistakes

  • Pinging a hostname and getting a cached or wrong IP from a broken DNS setup.
  • Assuming packet loss means the network — switches, firewalls and rate limiting can all drop packets.
  • Forgetting that ICMP is often blocked by firewalls, so ping fails while TCP works fine.
  • Checking connectivity only from your workstation instead of from the affected server itself.
Root cause analysis

Common issues

Error
ping: connect: Network is unreachable
Root cause

No route to the destination — usually a missing or wrong default gateway.

Fix

Run ip route and confirm a default route exists; add one with ip route add default via <gateway-ip> dev eth0.

Error
Destination Host Unreachable
Root cause

The gateway has no path to the host, or the host's firewall drops ARP or ICMP.

Fix

Verify the gateway is up (ip route) and that the target host's firewall permits the traffic.

Error
100% packet loss but the host still answers curl
Root cause

ICMP echo is blocked by a firewall while TCP is allowed.

Fix

Test reachability with a TCP tool instead, e.g. nc -vz host 443 or curl -sI https://host.

When things break

Debugging tips

  • Start with ip addr and ip route on the affected host before touching anything else.
  • Use ping with a packet count and interpret loss together with latency.
  • Compare traceroute results from two vantage points to isolate the failing hop.
  • Use ss -tulpn to confirm a service is actually listening on the expected port.
Interviews

Interview checkpoint

Practice

Hands-on lab

Inspect Your Network and Verify Connectivity
20 min · beginner
In progress
Objectives
  • List network interfaces and their IP addresses
  • Read the routing table and find the default gateway
  • Verify reachability with ping
  • Distinguish name resolution from network failure

Inspect Your Network and Verify Connectivity

20 min · beginner

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/3
1

Which device forwards packets between different networks?

2

What does the destination IP address in a packet identify?

3

A router can deliver a packet directly to any host on the internet without intermediate hops.

Quick reference

Cheat sheet

Inspect the network
ip addr showInterfaces and IP addresses
ip routeRouting table and default gateway
ping -c 4 <host>ICMP reachability + latency
traceroute <host>Every hop along the path
ss -tulpnListening sockets and processes
Golden path to debug connectivity
ping 127.0.0.1Is my own stack alive?
ping <gateway>Can I reach my router?
ping <public-ip>Do I have internet?
ping <hostname>Does DNS resolve?
Go deeper

Official documentation