How does the internet work? Every networking concept a developer needs, in order
The internet works by cutting data into packets, giving every device an IP address, and passing each packet from router to router until it arrives. On top of that, DNS turns names into addresses, TCP or UDP deliver the data to the right program, HTTP carries web pages, and TLS encrypts it all. This guide explains every one of those pieces, in the order they build on each other.
Video · How the Internet Works: Every Networking Concept Explained (IP, DNS, TCP, HTTP, TLS) · 17:03
How the internet works, in one paragraph
Prefer to watch? The 17-minute video covers the same ground in the same order, with diagrams for every concept.
Every message you send online is cut into packets. Each packet carries the IP address it is going to. Your device hands it to your router, and routers pass it from network to network until it reaches the right machine.
On top of that, DNS turns the name you typed into that address, TCP or UDP deliver the data to the right program, HTTP is the language of the web, and TLS keeps it private. The rest of this guide takes those pieces one at a time, from the bottom up.
Networks and packets
A network is a set of devices that can send data to each other. Your laptop, phone and printer at home form a LAN, a local area network. The internet is a network of networks: millions of them, connected by routers.
Data never travels as one big piece. It is cut into packets, usually up to about 1,500 bytes each on a typical Ethernet or Wi-Fi network. Every packet has a header (where it comes from, where it is going, and a few control fields) and a payload, the data itself. Packets can take different paths and arrive out of order; the receiving side puts them back together.
The four layers (and the OSI model)
Networking is split into layers, so each part can do one job and ignore the rest. The OSI model has seven; the internet itself runs on a simpler four-layer model:
| Layer | What it does | Examples |
|---|---|---|
| Application | What programs say to each other | HTTP, DNS, SSH |
| Transport | Delivers data to the right program, reliably or not | TCP, UDP, QUIC |
| Internet | Gets packets from one network to another | IP (IPv4, IPv6) |
| Link | Moves frames across one physical network | Ethernet, Wi-Fi |
Every concept below lives on one of these layers. Keeping the table in mind is the fastest way to make sense of a new acronym.
IP addresses: IPv4, IPv6, public and private
An IP address tells packets where to go. An IPv4 address is four numbers from 0 to 255, such as 192.168.1.10: 32 bits, so about 4.3 billion addresses (RFC 791). That turned out to be too few, so IPv6 uses 128 bits, written as eight groups of hexadecimal such as 2001:db8::8a2e:370:7334 (RFC 8200). Both run side by side today.
Some ranges are private and never appear on the public internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (RFC 1918). Millions of homes reuse them. Your router owns one public address and rewrites each outgoing packet's private address into it, and back for the replies. That is NAT, network address translation, and it is why a whole household shares one public IP.
Subnets, routers and the default gateway
Addresses are grouped into subnets, written in CIDR notation. 192.168.1.0/24 means the first 24 bits name the network and the last 8 name the devices: 256 addresses. Devices in the same subnet talk directly.
Everything else goes through a router. Your device sends any packet for another network to one router, the default gateway. Each router on the path reads the destination address, looks it up in its routing table, and forwards the packet to the next hop.
You can watch this happen. ping sends a small ICMP echo and measures the round trip. traceroute lists the routers on the path by using the TTL (time to live) field: every router lowers it by one, and a packet whose TTL reaches zero is dropped, which also means a packet can never loop forever.
MAC addresses, switches and ARP
Inside one local network, devices also use a MAC address: a 48-bit hardware address on every network interface, written like 3c:22:fb:9a:41:07. A switch connects the devices of a LAN and learns which MAC address sits behind each of its ports, so it forwards each frame only where it needs to go.
Your laptop knows the IP address it wants to reach, not the MAC address. ARP fills the gap (RFC 826): it asks the whole local network "who has 192.168.1.20?" and the owner replies with its MAC address. The answer is cached for a while. IPv6 does the same job with neighbor discovery.
DHCP: how a device gets its address
Nobody types an IP address when joining Wi-Fi. A DHCP server, usually your router, hands one out in four messages: discover, offer, request, acknowledge (RFC 2131). With the address you also get the subnet, the default gateway and the DNS servers to use. The address is leased: it expires unless the device renews it.
DNS: the internet's phone book
People type names; networks need addresses. DNS, the domain name system, maps one to the other (RFC 1034).
A lookup for example.com goes like this:
- Your device asks a recursive resolver, run by your internet provider or a public service.
- If the resolver has no cached answer, it asks a root server, which points to the servers for
.com. - The
.comservers point to the domain's authoritative name server. - The authoritative server answers with the address, and the resolver returns it to you and caches it.
| Record | What it holds |
|---|---|
| A | name → IPv4 address |
| AAAA | name → IPv6 address |
| CNAME | name → another name |
| MX | the mail servers for a domain |
| TXT | free text, often used to prove domain ownership |
Every record has a TTL that says how long it may be cached. That is why a DNS change can take a while to reach everyone, and why lowering the TTL before a migration helps.
Ports and sockets
An IP address reaches a machine; a port reaches a program on it. Ports are numbers from 0 to 65535. Servers listen on well-known ones: 443 for HTTPS, 80 for HTTP, 22 for SSH, 53 for DNS. The pair of addresses and ports on both ends identifies one connection, and in code you hold that connection as a socket.
TCP vs UDP
The transport layer has two classic protocols.
TCP gives a reliable, ordered byte stream (RFC 9293). It opens a connection with a three-way handshake (SYN, SYN-ACK, ACK), numbers every byte, and resends what is not acknowledged. Flow control keeps a fast sender from flooding a slow receiver, and congestion control slows everyone down when the network is busy.
UDP sends independent packets with no handshake, no ordering and no resending (RFC 768). It is lighter and faster, which suits video calls, online games and DNS lookups: a lost video frame is better skipped than waited for.
| TCP | UDP | |
|---|---|---|
| Connection | three-way handshake | none |
| Delivery | guaranteed, in order | best effort |
| Good for | web pages, files, email, APIs | calls, games, live data, DNS |
HTTP: methods, status codes and versions
HTTP is how browsers and APIs talk (RFC 9110). A request has a method, a path and headers; a response has a status code, headers and a body.
- Methods:
GETreads,POSTcreates,PUTreplaces,DELETEremoves. - Status codes:
2xxsuccess,3xxredirect,4xxa client mistake (404 not found),5xxa server failure. - Stateless: each request stands alone, so sites remember you with cookies or tokens.
Most web APIs are plain HTTPS requests with a JSON body: the Claude Messages API, for example, is one POST per model call. The same goes for remote MCP servers, which can talk to AI apps over HTTP as well as over a local pipe.
HTTP/1.1 handles one request at a time per connection. HTTP/2 multiplexes many requests over one TCP connection. HTTP/3 runs over QUIC, a transport built on UDP (RFC 9114, RFC 9000): it connects faster, and a lost packet only delays its own stream instead of every request behind it.
TLS and HTTPS
Plain HTTP can be read by anyone on the path. TLS encrypts the connection, detects tampering, and proves you are talking to the real server (RFC 8446). HTTPS is simply HTTP inside TLS.
The proof is a certificate for the domain, signed by a certificate authority your browser already trusts. During the handshake the two sides check that certificate and agree on fresh session keys. TLS 1.3 needs a single round trip for a new connection.
Firewalls, proxies and load balancers
A firewall allows or blocks traffic by address, port and protocol: for example, port 443 from anywhere, SSH only from the office. Most are stateful, so replies to connections you opened get back in automatically.
A forward proxy acts for clients (a company filtering outbound traffic). A reverse proxy such as Nginx sits in front of servers, routes each request to the right backend, and often handles TLS and caching for them.
A load balancer spreads requests across several servers, round robin or to the least busy one, and stops sending traffic to servers that fail their health checks. A layer 4 balancer only sees IP addresses and ports and works for any TCP or UDP traffic; a layer 7 balancer understands HTTP and can route /api to one pool and /images to another.
CDNs, latency and bandwidth
Distance costs time. A CDN (content delivery network) keeps copies of your content on edge servers around the world, so users are served from a nearby one and your origin server sees far less traffic.
Two words decide how fast things feel. Latency is how long one trip takes; bandwidth is how much data can flow per second. Picture a highway: latency is the length of the road, bandwidth the number of lanes. More lanes never make a small request arrive sooner, which is why CDNs and fewer round trips (TLS 1.3, HTTP/3) matter so much.
VPNs
A VPN builds an encrypted tunnel from your device to a VPN server. The local network sees only the tunnel, and websites see the VPN server's address instead of yours. Companies use VPNs to reach private networks from outside; WireGuard and IPsec are common protocols.
Putting it together: what happens when you press enter
- Your device already has an IP address, a gateway and DNS servers from DHCP.
- The browser asks DNS for the site's address; the resolver walks from the root to the authoritative server, or answers from its cache.
- It opens a TCP connection to port 443 (three-way handshake), or a QUIC connection over UDP for HTTP/3.
- TLS checks the certificate and sets up encryption.
- Packets leave through the default gateway, are rewritten by NAT, and hop from router to router.
- They usually reach a CDN edge or a load balancer, which passes the request to a server behind a firewall and a reverse proxy.
- The server answers
200 OKover HTTP, and the browser draws the page.
All of that usually takes well under a second.
Recap
- Data moves in packets, organized in four layers: link, internet, transport, application.
- IP addresses (with NAT, subnets and routers) get packets across networks; MAC addresses, switches and ARP handle the last hop; DHCP hands out the settings.
- DNS turns names into addresses; ports pick the program; TCP is reliable, UDP is fast.
- HTTP carries the web, TLS secures it, and firewalls, proxies, load balancers, CDNs and VPNs shape the path in between.
Sources: RFC 791 (IPv4), RFC 8200 (IPv6), RFC 1918 (private addresses), RFC 826 (ARP), RFC 2131 (DHCP), RFC 1034 (DNS), RFC 9293 (TCP), RFC 768 (UDP), RFC 9110 (HTTP), RFC 9114 (HTTP/3), RFC 9000 (QUIC), RFC 8446 (TLS 1.3).
FAQ
How does the internet work, in simple terms?
Data is cut into small packets. Each packet carries the IP address it is going to, and routers pass it from network to network until it arrives. DNS turns names like example.com into IP addresses, TCP makes delivery reliable, and HTTP over TLS carries web pages securely.
What is the difference between TCP and UDP?
TCP opens a connection with a three-way handshake and guarantees that every byte arrives, in order. UDP sends packets with no handshake and no guarantee, which makes it faster and better for video calls, games and DNS lookups.
What happens when you type a URL and press enter?
Your browser asks DNS for the site's IP address, opens a TCP or QUIC connection to port 443, checks the server's TLS certificate, sends an HTTP request, and draws the page from the response. The packets travel through your router, NAT and many other routers on the way.
What are the four layers of the internet?
Link (Wi-Fi, Ethernet), internet (IP), transport (TCP, UDP) and application (HTTP, DNS). The seven-layer OSI model splits the same work more finely.
Do I need to know networking as a software developer?
Yes, at this level. DNS, ports, TCP vs UDP, HTTP status codes, TLS, load balancers and CDNs come up every time you deploy, debug or scale a service.
Read next
- What Is MCP? The Model Context Protocol Explained
- Claude API Basics: Messages, max_tokens and stop_reason
- Authentication vs Authorization: Sessions, JWT, OAuth, SSO
- Big O Notation Explained Simply, With Everyday Examples
- What Is Docker? Docker and Kubernetes Explained Simply
- Software Engineering Unpacked: home
- The CCAR-F video playlist on YouTube