Packet switching
The internet does not hold open a dedicated circuit between sender and receiver. Instead, it uses packet switching: data is broken into independent packets, each carrying source and destination addresses. Packets travel independently, may take different routes, and are reassembled in order by the receiver. This design is resilient — if a router fails, packets route around it — but it also means your data can transit through many different organizations and jurisdictions. A packet from Iceland to the US might pass through routers in several European countries. Each hop is a potential point of interception or analysis.The IP protocol offers best-effort delivery only. It guarantees none of the following: delivery, in-order arrival, timely delivery, bandwidth, or security. Higher-layer protocols like TCP add reliability on top of IP’s best-effort foundation.
IP addressing
Every device on a network is identified by an IP address at Layer 3. IPv4 uses 32-bit addresses written in dotted-decimal notation (e.g.,192.168.1.1); IPv6 uses 128-bit addresses to accommodate the growing number of connected devices.
Subnets and CIDR notation
IP addresses are divided into a network portion and a host portion. CIDR (Classless Inter-Domain Routing) notation uses a slash to show how many bits belong to the network. For example,198.0.1.130/24 means the first 24 bits (198.0.1) identify the network, and the last 8 bits (130) identify the host within it.
Reserved IPv4 ranges
Some address ranges are reserved and are not routable on the public internet:| Range | Purpose |
|---|---|
127.0.0.0/8 | Loopback (localhost) |
10.0.0.0/8 | Private network |
172.16.0.0/12 | Private network |
192.168.0.0/16 | Private network |
255.255.255.255/32 | Limited broadcast |
192.168.1.x — they are not directly reachable from the internet without NAT.
MAC addresses
While IP addresses route packets between networks, MAC (Media Access Control) addresses handle delivery within a single network segment at Layer 2. A MAC address is a 48-bit hardware identifier assigned by the manufacturer to a network interface card (NIC), written as six hexadecimal pairs (e.g.,00:1A:2B:3C:4D:5E).
When a packet arrives at a router destined for a device on the local network, ARP resolves the destination IP address to a MAC address so the frame can be delivered to the correct device on the LAN. MAC addresses do not cross router boundaries — each hop rewrites the frame’s MAC addresses while preserving the IP addresses.
MAC addresses can be spoofed in software on most operating systems. Do not rely on MAC address filtering alone as a security control — it provides only weak authentication.
NAT — Network Address Translation
IPv4 provides roughly 4.3 billion addresses, far fewer than the number of devices that need internet access. NAT solves this by letting multiple devices on a private network share a single public IP address. When a device on your LAN sends traffic to the internet, your router:- Records the mapping of (private IP, private port) → (public IP, public port) in a NAT translation table.
- Replaces the source IP and port with the router’s public IP and a chosen port.
- When the response arrives, it reverses the translation and forwards the packet to the correct internal device.
NAT: tradeoffs
Pros
Pros
- Natural firewall effect: Unsolicited inbound connections from the internet cannot reach devices behind a NAT unless port forwarding rules are configured.
- Topology hiding: External entities cannot see your internal network structure.
- IPv4 conservation: NAT is a key reason IPv4 has remained viable despite address exhaustion, and why the transition to IPv6 has been slow.
Cons
Cons
- Breaks end-to-end connectivity: Applications that require direct peer-to-peer connections (VoIP, gaming, file sharing) may not work without workarounds like STUN (Session Traversal Utilities for NAT) or TURN (Traversal Using Relays around NAT).
- Loss of attribution: Multiple internal devices appear as one external IP, complicating logging and forensic investigation.
- Port limit: Only 65,535 port numbers are available, limiting simultaneous outbound connections from the NATed network.
Autonomous Systems and internet routing
The internet is not managed by a single organization. It is a federation of independently operated networks called Autonomous Systems (ASes). An Autonomous System (AS) is a collection of IP networks and routers under the control of a single organization — an ISP, a university, a large company — that presents a common routing policy to the internet. Each AS is assigned a unique Autonomous System Number (ASN) by regional internet registries. Routing works at two levels:- Interior Gateway Protocols (IGPs): Used within an AS. Protocols like OSPF (Open Shortest Path First) use Dijkstra’s algorithm to find shortest paths, with complete knowledge of the AS’s internal topology.
- Exterior Gateway Protocols (EGPs): Used between ASes. BGP is the only EGP in widespread use on the internet today.
BGP — Border Gateway Protocol
BGP is the routing protocol that holds the internet together. It allows ASes to advertise which IP prefixes they can reach and to learn routes from neighboring ASes. Key characteristics of BGP:- Policy-based, not shortest-path: Routes are chosen based on local criteria — peering agreements, cost, politics, route length — not necessarily the fastest path.
- Manual configuration: Network administrators configure routing policies by hand, introducing the potential for human error.
- Trust-based: BGP was designed in an era of trusted peers. It has no built-in mechanism to verify that an AS actually owns the prefix it is advertising.
Routing table mechanics
Every router maintains a routing table that maps destination IP prefixes to next-hop addresses. Building and using this table are separate processes: Building the table:- Routers exchange prefix reachability information with neighbors.
- BGP uses a path-vector algorithm (related to Bellman-Ford) because Dijkstra’s requires complete network knowledge, which is infeasible in the decentralized internet.
- The result is a forwarding table with next-hop information for each known prefix.
- When a packet arrives, the router looks up the destination IP using longest prefix match — the most specific matching prefix wins.
- The packet is forwarded out the interface toward the next hop, or dropped if no match is found.
BGP hijacking
BGP’s trust model is its most significant security weakness. Mitigation — RPKI (Resource Public Key Infrastructure): RPKI cryptographically binds IP prefixes to their legitimate AS owners. Routers that support RPKI can reject route announcements that fail cryptographic verification, preventing hijacked prefixes from propagating.Route poisoning
Route poisoning is a technique used in distance-vector routing protocols to mark a route as unreachable by setting its metric to infinity, preventing routing loops. Attackers can exploit this mechanism to deliberately poison routing tables, causing traffic to be dropped or misdirected. Keeping routing software patched and deploying authentication for routing protocol sessions (e.g., MD5 or TCP-AO for BGP sessions) reduces this risk.Diagnostic tools
Use these tools to observe routing and addressing on your own system:| Command | What it shows |
|---|---|
ping <host> | Tests reachability and measures round-trip time |
traceroute <host> / tracert <host> | Maps each hop between you and the destination |
ip addr / Get-NetIPAddress | Shows IP and MAC addresses for all interfaces |
ip route / Get-NetRoute | Displays the local routing table |
ip neigh / Get-NetNeighbor | Displays the ARP cache |
dig <domain> | Detailed DNS lookup including TTL and record type |