
What Is an IP Address? How IP, TCP and UDP Really Work
Run one command on the laptop this article was written on, and it lists eleven addresses. Ask a web server which address is talking to it, and the answer is a twelfth, one that appears nowhere in that list. Neither side is lying. They are describing different points on the same path, and almost every confusing network problem lives in the gap between them.
This article explains what an IP address actually is, what the Internet Protocol does and, more importantly, what it deliberately refuses to do. It covers the four-layer model that TCP/IP really uses, the single byte in the header that decides whether a packet is TCP or UDP, how a machine picks which of its own addresses to use, why traceroute shows nine hops out and the reply comes back over six, what happens when a packet is one byte too big, why IPv6 forbids routers from fragmenting, and what NAT rewrites on the way past. Every command output below was produced on 7 September 2026 on a lab machine running Ubuntu 24.04 with Linux 6.11, iproute2 6.1.0 and curl 8.5.0, and the standards references were checked against the RFCs the same day.
IP does not deliver your data. It carries one packet toward one address and forgets it. Everything that feels reliable was built on top of that by something else.
Goal: after reading this you can look at an address, a route and a failed connection and say which layer owns the problem.
1. The Basics
The Internet Protocol (IP) has one job: take a block of bytes, put an address on the front, and hand it to the next machine on the way. That is the whole service. The current IPv4 specification, RFC 791 from September 1981, says the protocol is "specifically limited in scope to provide the functions necessary to deliver a package of bits (an internet datagram) from a source to a destination over an interconnected system of networks".
1.1 One Job, and Everything It Refuses to Do
What makes IP worth understanding is not what it does but what it openly declines to do. The same RFC continues: "There are no mechanisms to augment end-to-end data reliability, flow control, sequencing, or other services commonly found in host-to-host protocols."
RFC 1122 of October 1989, which is Internet Standard 3, spells out the consequence for anyone writing software on top: "IP is a connectionless or datagram internetwork service, providing no end-to-end delivery guarantees. Thus, IP datagrams may arrive at the destination host damaged, duplicated, out of order, or not at all."
Read that list again, because it is the mental model for the rest of this article. Damaged. Duplicated. Out of order. Not at all. IP promises none of it away. A packet that is dropped is simply gone, and nothing at the IP layer will tell you, retry it, or slow down.
That sounds like a design failure and it is the opposite. By refusing to guarantee anything, IP stays small enough that any network can carry it: fibre, copper, wifi, a satellite link, a phone modem. Everything that feels dependable when you load a web page was added above IP by a transport protocol that chose to add it. TCP chose reliability and paid for it in round trips. UDP chose not to and stayed fast.
1.2 What Is Actually in the Header
An IPv4 packet is a header followed by whatever the layer above handed down. The header is at least 20 bytes, which is five 32-bit words:
IPv4 header (RFC 791), the fixed first 20 bytes
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Six of those fields explain most of the behaviour you will ever debug:
| Field | Size | What it decides |
|---|---|---|
| Version | 4 bits | 4 for IPv4, 6 for IPv6. Section 3.2 explains why there is no 5. |
| Total Length | 16 bits | The whole packet in bytes, so the ceiling is 65535. Section 6.1 explains why you never see one that big. |
| Flags and Fragment Offset | 3 + 13 bits | Whether this packet may be split, and where this piece belongs. The Don't Fragment bit lives here. |
| Time to Live | 8 bits | A hop counter, not a clock. Every router subtracts one. Section 4.4 reads it. |
| Protocol | 8 bits | What is inside: 6 means TCP, 17 means UDP. See 1.4. |
| Source and Destination Address | 32 bits each | The two numbers everything else in this article is about. |
The IPv6 header, defined in RFC 8200 of July 2017 (Internet Standard 86), is a deliberate simplification of the same idea: a fixed 40 bytes, eight fields instead of thirteen, and no header checksum at all.
| IPv4 | IPv6 | Why the change |
|---|---|---|
| 20 to 60 bytes, variable | 40 bytes, fixed | A router can find the payload without arithmetic. Options moved to extension headers. |
| 32-bit addresses | 128-bit addresses | 4,294,967,296 addresses versus 2 to the power of 128. |
| Header Checksum | none | Every hop had to recompute it. See 7.4. |
| Time to Live | Hop Limit | Same 8-bit counter, honest name at last. |
| Protocol | Next Header | Same registry of numbers, extended to chain extension headers. |
| Fragment fields in every header | an optional extension header | Routers no longer fragment at all. See 6.2. |
1.3 Four Layers, Not Seven
Most training material teaches the seven-layer OSI model. The internet does not use it. RFC 1122 describes the stack that was actually built, and it has four layers:
Application layer HTTP, DNS, SMTP "what the bytes mean"
Transport layer TCP, UDP, QUIC "who gets them, and are they all there"
Internet layer IP, ICMP "which machine"
Link layer Ethernet, wifi "which cable, this hop only"
Each layer wraps the one above it, so a single web request on the wire is four nested envelopes:
+-------------------------------------------------------------+
| Ethernet frame to a MAC address on this cable |
| +---------------------------------------------------------+ |
| | IPv4 packet to 104.20.23.154, protocol 6 | |
| | +-----------------------------------------------------+ | |
| | | TCP segment to port 443, sequence numbers, flags | | |
| | | +-------------------------------------------------+ | | |
| | | | TLS record, and inside it: GET / HTTP/1.1 | | | |
| | | +-------------------------------------------------+ | | |
| | +-----------------------------------------------------+ | |
| +---------------------------------------------------------+ |
+-------------------------------------------------------------+
The link layer is replaced at every hop. Your Ethernet frame does not survive past your router; the router strips it, keeps the IP packet, and puts a new frame on the next link. The IP packet is the part that travels end to end, which is exactly why it is the layer that carries the address of the far end.
The mental model: the IP packet is a postcard, and the link layer is the mail truck it happens to be riding in. The mail truck changes at every depot. The postcard does not, and only the postcard knows where it is going.
1.4 The One Byte That Says TCP or UDP
There is no separate "TCP network" and "UDP network". Both ride inside the same IP packet, and one 8-bit field in the IP header says which. The values come from the IANA Protocol Numbers registry, and your machine keeps a local copy:
$ getent protocols tcp udp icmp ipv6-icmp
tcp 6 TCP
udp 17 UDP
icmp 1 ICMP
ipv6-icmp 58 IPv6-ICMP
Eight bits gives 256 possible values. The registry, last updated on 9 March 2026, assigns numbers 0 to 147, leaves 148 to 252 unassigned, and keeps 253 and 254 for experimentation. A handful matter in daily work:
| Number | Keyword | Where you meet it |
|---|---|---|
| 1 | ICMP |
ping, and every "unreachable" message the network sends you |
| 6 | TCP |
HTTP/1.1, HTTP/2, SSH, SMTP, database connections |
| 17 | UDP |
DNS, NTP, and HTTP/3 by way of QUIC |
| 41 | IPv6 |
IPv6 tunnelled inside IPv4 |
| 47 | GRE |
tunnels, VPNs |
| 50 | ESP |
the encrypted half of IPsec |
| 58 | IPv6-ICMP |
ICMPv6, which IPv6 cannot work without |
| 132 | SCTP |
telecom signalling, WebRTC data channels |
This is worth knowing because firewalls filter on it. A rule that allows "TCP 443" is a rule about protocol number 6, and it says nothing whatever about protocol number 17 arriving at the same port number. That single gap is why HTTP/3 quietly fails to be used on many networks; section 6.4 comes back to it.
1.5 The Address Itself: 32 Bits Wearing a Costume
An IPv4 address is a 32-bit unsigned integer. The four numbers separated by dots are a convention for humans, not the address:
$ python3 -c "
import socket, struct
print('int of 127.0.0.1 =', struct.unpack('!I', socket.inet_aton('127.0.0.1'))[0])"
int of 127.0.0.1 = 2130706433
Both forms describe the same four bytes, 01111111 00000000 00000000 00000001. The dotted form writes each byte separately, as a number from 0 to 255. The integer writes all 32 bits as one number. Each byte is worth 256 times the byte to its right, so the conversion is simple arithmetic:
127 * 256^3 = 127 * 16777216 = 2130706432
0 * 256^2 = 0
0 * 256^1 = 0
1 * 256^0 = 1
----------
2130706433
The dots are not stored anywhere. The computer stores and sends only the 32 bits; dotted decimal, hexadecimal (0x7F000001) and the single integer are three ways for humans to write them down.
Section 7.2 shows how far that goes, and why it is a security problem. An IPv6 address is the same idea at 128 bits, written as eight groups of four hexadecimal digits, with one compression rule defined in RFC 4291 of February 2006: a run of zero groups may be replaced by ::, and only once per address.
$ python3 -c "
import ipaddress
for a in ['2001:0db8:0000:0000:0000:ff00:0042:8329','::1']:
n = ipaddress.ip_address(a)
print(n.compressed, ' <- ', n.exploded)"
2001:db8::ff00:42:8329 <- 2001:0db8:0000:0000:0000:ff00:0042:8329
::1 <- 0000:0000:0000:0000:0000:0000:0000:0001
The "only once" rule exists because :: means "however many zero groups are needed to make eight". Two of them in one address would be ambiguous.
2. Where the Names Come From
Every name in this article is descriptive, and each one records a decision.
Internet is short for internetwork, and it was a common noun long before it was a proper one. In 1974 there were already several packet networks that could not talk to each other. The problem was not building a network; it was joining networks that had different packet sizes, different addressing and different owners. A protocol for working between networks is an inter-network protocol, and the capital letter came later.
Datagram is a deliberate borrowing from telegram. A telegram is short, self-contained, addressed on the front, and handed over without a conversation. That is precisely the delivery model IP chose, and the word carries the promise level with it: you can send a telegram, and nobody guarantees it arrives.
TCP/IP is written as a pair because it was once a single protocol that got cut in half. Vint Cerf and Bob Kahn's 1974 paper "A Protocol for Packet Network Intercommunication" described one thing, the Transmission Control Program, which did both the addressing and the reliability. On 15 August 1977 Jon Postel wrote IEN 2 and objected:
"We are screwing up in our design of internet protocols by violating the principle of layering. Specifically we are trying to use TCP to do two things: serve as a host level end to end protocol, and to serve as an internet packaging and routing protocol."
His conclusion was to split them: "I suggest that a new distinct internetwork protocol is needed, and that TCP be used strictly as a host level end to end protocol." The split happened, IP became a protocol in its own right, and the slash in TCP/IP is the scar. It is also the reason UDP could exist at all: once addressing was a separate protocol, a second transport could sit beside TCP without reimplementing anything.
UDP is the User Datagram Protocol, and the "user" is the application programmer. The name says that the datagram model of IP is being handed up to you unchanged, with ports added and nothing else. RFC 768 of 28 August 1980 is three pages long, which is itself the point. It offers "a procedure for application programs to send messages to other programs with a minimum of protocol mechanism", and warns in the same breath that "delivery and duplicate protection are not guaranteed".
TTL, Time to Live, is the one name that misleads. RFC 791 really did define it in seconds: "This field indicates the maximum time the datagram is allowed to remain in the internet system." Routers were supposed to subtract the seconds they held a packet. In practice every router subtracts exactly one, which makes it a hop counter, and IPv6 renamed the field Hop Limit to stop the pretence.
Back to top3. A Short History
3.1 The Milestones That Still Affect You
| Date | Event | Why it still matters |
|---|---|---|
| May 1974 | Cerf and Kahn publish "A Protocol for Packet Network Intercommunication" in IEEE Transactions on Communications, COM-22(5), pages 637-648 | The architecture of the internet, as one protocol that has not been split yet |
| 15 August 1977 | IEN 2 proposes separating the internetwork protocol from TCP | Why "TCP/IP" is two names, and why UDP was possible |
| 28 August 1980 | RFC 768 defines UDP | Still the specification in force. Three pages, never revised |
| September 1981 | RFC 791 (IP) and RFC 793 (TCP) | The IPv4 header in section 1.2 is this document |
| 1 January 1983 | The ARPANET flag day. RFC 801 set the goal: "make a complete switch over from the NCP to IP/TCP by 1 January 1983" | The last time the internet changed protocol on a fixed date. It has never been possible since, which is the whole IPv6 story |
| September 1993 | CIDR, in RFC 1519, later replaced by RFC 4632 (August 2006) | Killed address classes A, B and C, and gave us the /24 notation in section 5.1 |
| December 1995 | IPv6 first specified, in RFC 1883 | Replaced by RFC 2460 and then by RFC 8200 in July 2017 |
| February 1996 | RFC 1918 reserves private address space | 10.x, 172.16-31.x and 192.168.x, on nearly every network you will ever touch |
| January 2001 | RFC 3022 documents Traditional NAT | Standardised what everyone was already doing to survive address scarcity |
| 3 February 2011 | IANA hands its last five /8 blocks to the regional registries |
The global free pool of IPv4 addresses ended on this date |
| 6 June 2012 | World IPv6 Launch. Google measured 0.65 percent of its users on IPv6 that day | The starting line for the number in section 7.3 |
| April 2012 | RFC 6598 reserves 100.64.0.0/10 for carrier-grade NAT | The address your router gets when your ISP has no IPv4 left for you |
| 25 November 2019 | RIPE NCC makes its final IPv4 allocation | In Europe, new IPv4 space now comes from the transfer market or not at all |
| May 2021 | RFC 9000 standardises QUIC | A reliable transport built on UDP, and the basis of HTTP/3 |
| 28 March 2026 | Google's IPv6 measurement reaches 50 percent for the first time, on a Saturday | Dual stack is now the normal case, not the advanced one |
3.2 The Version Number That Never Shipped
The Version field is four bits, IPv4 uses 4 and IPv6 uses 6. The obvious question is what happened to 5, and the answer is in the IANA IP Version Numbers registry, last updated 28 January 2021:
4 IP Internet Protocol RFC 791
5 - Reserved (Historic) RFC 1819
6 IPv6 Internet Protocol version 6 RFC 8200
7 - Reserved (Historic) RFC 1475, RFC 6814
8 - Reserved (Historic) RFC 1621
9 - Reserved (Historic) RFC 1347
Version 5 was the Internet Stream Protocol, an experiment in carrying real-time audio and video with reserved bandwidth. It used up the number, so the next general-purpose IP had to be 6. Versions 7, 8 and 9 were competing proposals for that next generation; all three are marked historic, and the one that won is the one in your address bar when a site is dual stack.
The 1983 flag day in the table above is the reason IPv6 has taken so long. The internet was small enough that a committee could set a date and everyone moved. Nothing like that can happen now, so IPv6 has been deployed for thirty years by running both protocols side by side and waiting.
Back to top4. Simple Use Cases
4.1 Which Addresses Does This Machine Have
One command answers it. On Linux, ip -br addr prints the brief form, one interface per line:
$ ip -br addr
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 192.168.88.2/24 fe80::ea12:8c67:7359:3d26/64
wlp0s20f3 UP 192.168.1.198/24 fe80::6e5a:efe7:e2b6:1a81/64
ztugauq32g UNKNOWN 172.29.126.158/16 fe80::28a5:64ff:fe6d:8161/64
docker0 DOWN 172.17.0.1/16 fe80::8865:82ff:feb2:f9fc/64
br-623353ab4079 DOWN 10.10.10.1/24
That is one laptop with eleven addresses: six IPv4 and five IPv6. They are not spares. Each one belongs to a different network the machine is attached to:
| Address | Interface | What it is for |
|---|---|---|
127.0.0.1 and ::1 |
lo |
Loopback. Traffic to it never reaches a cable. |
192.168.88.2 |
eth0 |
The wired LAN, and the default route |
192.168.1.198 |
wlp0s20f3 |
The wifi LAN, a different network entirely |
172.29.126.158 |
ztugauq32g |
A VPN's virtual network |
172.17.0.1 and 10.10.10.1 |
docker0, br-... |
Container bridges. This machine is the gateway for them. |
fe80::/64 addresses |
every interface | IPv6 link-local. Generated automatically, valid on that one link only, and never routed. |
Two of the interfaces are marked DOWN and still hold addresses. An address is a property of a configured interface, not proof that anything is plugged in.
The equivalents elsewhere: ipconfig /all on Windows, ifconfig -a or ipconfig getifaddr en0 on macOS. On Linux, ifconfig still exists but has not been the maintained tool for years; ip shows things ifconfig cannot, including multiple addresses per interface and the routing policy.
4.2 Public, Private, and the One the Server Sees
Every address in that list except the loopbacks and the link-locals is private. RFC 1918 of February 1996, which is BCP 5, reserved three blocks for networks that are not on the public internet:
10.0.0.0 - 10.255.255.255 (10/8 prefix) 16777216 addresses
172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 1048576 addresses
192.168.0.0 - 192.168.255.255 (192.168/16 prefix) 65536 addresses
The rule attached to them is the important half: "Because private addresses have no global meaning, routing information about private networks shall not be propagated on inter-enterprise links, and packets with private source or destination addresses should not be forwarded across such links."
So none of those addresses can be what a web server sees. Ask one:
$ curl -s https://api.ipify.org
203.0.113.27
(The real answer here was a public address belonging to the lab's internet connection. It is shown as an RFC 5737 documentation address throughout this article.)
That address is on the router, not on the laptop. The laptop sent a packet with source 192.168.88.2, the router rewrote the source to its own public address on the way out, and rewrote it back on the way in. Section 6.2 covers what else that rewrite touches.
This is the single most common misunderstanding about IP addresses, and it has two practical consequences. First, an address in an access log identifies a household or an office, not a machine. Second, "my IP address" is an ambiguous phrase: your machine has one, your router has another, and only one of them means anything to the rest of the internet.
Beyond RFC 1918 there is a longer list of blocks that never appear on the public internet, all of it in the IANA IPv4 Special-Purpose Address Registry. The ones worth recognising on sight:
| Block | Name | Where you see it |
|---|---|---|
0.0.0.0/32 |
This host on this network | As a bind address it means "every address I have" |
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 |
Private-Use (RFC 1918) | Home and office LANs, container networks |
100.64.0.0/10 |
Shared Address Space (RFC 6598) | Your router's WAN address under carrier-grade NAT |
127.0.0.0/8 |
Loopback | The whole /8, not just 127.0.0.1 |
169.254.0.0/16 |
Link Local (RFC 3927) | What a machine gives itself when DHCP fails |
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 |
Documentation (RFC 5737) | Examples in articles like this one |
240.0.0.0/4 |
Reserved | 268 million addresses nobody can use, reserved since 1989 |
Seeing 169.254.x.x on a machine is a diagnosis in itself: it did not get a DHCP lease. Seeing 100.64.x.x on a router's WAN side is also a diagnosis: the ISP has put you behind carrier-grade NAT, so inbound connections and port forwarding will not work no matter what you configure.
4.3 Which Address Will It Use to Reach That Host
With six IPv4 addresses available, something has to choose. On Linux, ip route get answers the question without sending a packet:
$ ip route get 8.8.8.8
8.8.8.8 via 192.168.88.1 dev eth0 src 192.168.88.2 uid 1000
$ ip route get 192.168.1.50
192.168.1.50 dev wlp0s20f3 src 192.168.1.198 uid 1000
$ ip route get 127.0.0.1
local 127.0.0.1 dev lo src 127.0.0.1 uid 1000
Read those three lines as a sentence. To reach that destination, go out of this interface, using this address as my source, and hand the packet to that gateway. The via only appears when a gateway is involved; where it is missing, the destination is on a directly attached network.
The choice is not a preference, it is a lookup, and section 5.2 shows the rule. The application can confirm the same answer:
$ python3 -c "
import socket
for dest in ['1.1.1.1','192.168.1.1','127.0.0.1']:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((dest, 53))
print(dest, '->', s.getsockname()[0])
s.close()"
1.1.1.1 -> 192.168.88.2
192.168.1.1 -> 192.168.1.198
127.0.0.1 -> 127.0.0.1
Connecting a UDP socket sends nothing at all. It only asks the kernel to fix a destination, which forces the routing decision and the source address to be chosen. It is the quickest way to ask a program which address it is about to appear as.
This is why a service that binds to one specific address can be unreachable in one direction and fine in the other, and why "the firewall must be blocking it" is so often wrong. The TCP ports article covers the binding half of that problem in detail.
4.4 Is It Reachable, and How Far Away Is It
ping sends an ICMP echo request and waits for the echo reply. It exercises the IP layer and nothing above it, which is exactly why it is the first test and never the last one:
$ ping -c 3 example.com
PING example.com (104.20.23.154) 56(84) bytes of data.
64 bytes from 104.20.23.154: icmp_seq=1 ttl=58 time=5.51 ms
64 bytes from 104.20.23.154: icmp_seq=2 ttl=58 time=5.18 ms
64 bytes from 104.20.23.154: icmp_seq=3 ttl=58 time=5.05 ms
--- example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 5.052/5.248/5.509/0.192 ms
Four things in that output are worth reading properly.
The name resolved to an address first. If ping fails with "Name or service not known" it never sent a packet, and the problem is DNS rather than the network. See the DNS article.
The time is a round trip, out and back, not the distance one way. 5 ms to a content network's nearest site is normal; 150 ms usually means the other end is on another continent, or a satellite link is involved.
ttl=58 is the arrival value of the counter, so it tells you the hop count of the return path. Senders start it at a round number, almost always 64, 128 or 255. Two hosts on the same day from the same machine:
$ ping -c1 1.1.1.1 | sed -n 2p
64 bytes from 1.1.1.1: icmp_seq=1 ttl=58 time=5.64 ms # 64 - 58 = 6 hops
$ ping -c1 8.8.8.8 | sed -n 2p
64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=5.41 ms # 128 - 119 = 9 hops
A value of 119 cannot come from a start of 64, so that sender began at 128. Reading the counter therefore tells you two things at once: roughly how many routers the reply crossed, and something about the operating system that sent it.
A failed ping proves very little. ICMP echo is routinely filtered by choice. Section 7.6 comes back to this, and the short version is that a host which does not answer ping may be serving traffic perfectly on port 443.
4.5 Which Address the Server Writes in Its Log
Section 4.2 ended with the address a server sees. On a modern site that is often not the visitor's address either, because the visitor's packets never reached your server. A typical stack puts two or three machines in the path first:
browser → CDN → load balancer → nginx → PHP application
|
each hop opens its OWN TCP connection to the next,
so the application sees the address of the hop in
front of it, not the address of the visitor
The original address survives only because a proxy chooses to write it into a header. The de facto version is X-Forwarded-For; the standardised one is Forwarded, defined in RFC 7239 of June 2014, whose purpose is to let "proxy components disclose information lost in the proxying process, for example, the originating IP address of a request".
A header is not a fact. Anyone can send one, and it arrives intact:
$ curl -s -H 'X-Forwarded-For: 192.0.2.99' https://echo.free.beeceptor.com
{
"method": "GET",
"protocol": "https",
"host": "echo.free.beeceptor.com",
"path": "/",
"ip": "203.0.113.27",
"headers": {
"Host": "echo.free.beeceptor.com",
"User-Agent": "curl/8.5.0",
"Accept": "*/*",
"Accept-Encoding": "gzip",
"X-Forwarded-For": "192.0.2.99"
},
"parsedQueryParams": {}
}
Two addresses in one response, and only one of them is real. The ip field is the address of the TCP connection, which the network established and nobody can fake from a browser. The X-Forwarded-For field is a string this request invented. RFC 7239 states the problem plainly: the header "cannot be relied upon to be correct, as it may be modified, whether mistakenly or for malicious reasons, by every node on the way to the server, including the client making the request".
That produces the rule almost every application gets wrong at least once:
- Trust the header only when the connection came from a proxy you operate. Configure the trusted proxy addresses explicitly, in the web server or the framework. If the request did not come from one of them, ignore the header entirely.
- Count from the right end.
X-Forwarded-Foris a comma-separated list that each proxy appends to, so the leftmost entry is the one the client supplied and the rightmost entries are the ones your own infrastructure added. Taking the first entry is taking the attacker's value. - Assume it is missing until you have checked. A site put behind a CDN without updating the application logs every visitor as the CDN, which quietly breaks rate limiting, abuse blocking, geolocation and any analytics based on addresses.
5. Moderate Use Cases
5.1 The Mask, and What "Same Network" Means
Every time a machine sends a packet, it first asks one question: is this destination on my own network, or do I have to hand the packet to a gateway? A gateway is the router that forwards traffic to other networks. The mask is what answers that question.
The /24 in 192.168.1.198/24 is the prefix length. It says how many of the 32 bits name the network. The remaining bits number the hosts on that network. So /24 means: the first three numbers (192.168.1) are the network, and the last number is the host. Python does the arithmetic for you:
$ python3 -c "
import ipaddress
ip = ipaddress.ip_interface('192.168.1.198/24')
print('address ', ip.ip)
print('network ', ip.network)
print('netmask ', ip.netmask)
print('broadcast', ip.network.broadcast_address)
print('usable ', ip.network.num_addresses - 2)"
address 192.168.1.198
network 192.168.1.0/24
netmask 255.255.255.0
broadcast 192.168.1.255
usable 254
A /24 holds 256 addresses, but two are reserved. The first one names the network and the last one is the broadcast address, so 254 are left for hosts. Each bit you add to the prefix halves the block:
| Prefix | Netmask | Addresses | Typical use |
|---|---|---|---|
/32 |
255.255.255.255 | 1 | One host, as used in a firewall rule |
/30 |
255.255.255.252 | 4 | A point-to-point link between two routers |
/24 |
255.255.255.0 | 256 | A normal office or home LAN |
/16 |
255.255.0.0 | 65536 | A large site, or a container bridge |
/8 |
255.0.0.0 | 16777216 | All of 10.0.0.0/8 |
/0 |
0.0.0.0 | everything | The default route |
Get the mask wrong and two machines on the same cable decide they are strangers. The classic symptom: a computer that can reach the internet, but not the printer next to it.
IPv6 uses the same notation. One /64, the standard size for a single network, holds four billion times as many addresses as the whole IPv4 internet.
5.2 Longest Prefix Match: The Whole Routing Decision
Why you care: when traffic goes out of the wrong interface, for example over wifi instead of the cable, or around a VPN instead of through it, this is the rule that decided it.
A routing table is a list of networks, each with an instruction: "send it out of this interface" or "give it to this gateway". When several entries match, one rule decides: the most specific match wins. "Most specific" means the longest prefix, so a /24 beats a /16. Here is the lab machine's table:
$ ip route
default via 192.168.88.1 dev eth0 proto static metric 100
default via 192.168.1.1 dev wlp0s20f3 proto dhcp src 192.168.1.198 metric 600
10.10.10.0/24 dev br-623353ab4079 proto kernel scope link src 10.10.10.1 linkdown
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.29.0.0/16 dev ztugauq32g proto kernel scope link src 172.29.126.158
192.168.1.0/24 dev wlp0s20f3 proto kernel scope link src 192.168.1.198 metric 600
192.168.88.0/24 dev eth0 proto kernel scope link src 192.168.88.2 metric 100
default means 0.0.0.0/0: a prefix of length zero. It matches every destination, so it always loses to any other match. It is simply the last resort. ip route get shows which entry wins for a given address:
$ for d in 192.168.1.50 172.29.1.1 10.10.10.5 8.8.8.8; do ip route get $d; done
192.168.1.50 dev wlp0s20f3 src 192.168.1.198 uid 1000
172.29.1.1 dev ztugauq32g src 172.29.126.158 uid 1000
10.10.10.5 dev br-623353ab4079 src 10.10.10.1 uid 1000
8.8.8.8 via 192.168.88.1 dev eth0 src 192.168.88.2 uid 1000
The first three are on networks this machine is directly connected to, so they go straight out of the matching interface. Only 8.8.8.8 matches nothing but the default route, so only that one is handed to a gateway (via 192.168.88.1).
Notice the two default routes, one over the cable (eth0) and one over wifi. They do not conflict, because of the metric: lower wins, so 100 beats 600 and the cable carries everything while wifi stands by. A VPN works the same way: it installs routes. So when a machine on a VPN suddenly cannot reach something, check ip route first.
This table is the only routing decision you control. After your gateway, every network on the path makes its own decision with its own table. Nobody holds the whole path, which is why section 7.1 can count a different number of hops in each direction.
5.3 Following the Path with traceroute
Why you care: traceroute shows the routers between you and a server, and how long each one takes to answer. It is the first tool to use when a site is slow or unreachable from one place only.
It uses the TTL field (short for Time to Live) from section 1.2. Every router lowers the TTL by one, and the router that brings it to zero throws the packet away and sends back an error message with its own address. traceroute sends a packet with TTL 1 (the first router answers), then TTL 2 (the second router answers), and so on:
$ traceroute -n -q 1 -m 15 104.20.23.154
traceroute to 104.20.23.154 (104.20.23.154), 15 hops max, 60 byte packets
1 192.168.88.1 0.529 ms
2 198.51.100.1 2.306 ms
3 10.227.142.230 5.552 ms
4 10.226.9.67 5.803 ms
5 141.101.65.185 5.776 ms
6 *
7 141.101.65.184 5.409 ms
8 141.101.65.225 6.330 ms
9 104.20.23.154 5.689 ms
(Hop 2 is the lab's own internet provider and is shown as a documentation address. Everything else is real.)
Three things in this trace are easy to misread:
- Hops 3 and 4 are private addresses on the public path. The provider numbers its internal routers from
10.0.0.0/8. Those routers can send you a message, but you cannot reach them. "Private" is about routing, not about visibility. - Hop 6 is a star, and hop 7 answers normally. A star only means that router did not reply. The packet clearly went on, because later hops answered. Many routers ignore or rate-limit these replies. A single star in the middle is noise; stars from one hop all the way to the end are a real signal.
- The times do not increase steadily. Hop 8 is slower than hop 9. Each time is a separate trip to a different router, which answers whenever it has time. Do not compare single hops; only the trend over many hops means something.
To find where packets get lost, use mtr: it repeats the trace continuously and shows the loss per hop. On Windows, use tracert and pathping.
5.4 TCP or UDP: Choosing the Contract
Both TCP and UDP travel inside IP packets. The difference is what they add on top of IP, which itself promises nothing.
| Question | TCP (protocol 6) | UDP (protocol 17) |
|---|---|---|
| Setup cost | A three-message handshake, one full round trip before any data | None. The first packet is data. |
| Lost packet | Detected and retransmitted | Gone. The application never hears about it. |
| Order | Delivered in the order sent | Whatever order they arrive in |
| Duplicates | Removed | Delivered twice |
| Message boundaries | None. It is a byte stream; one send is not one recv. |
Preserved. One datagram in, one datagram out. |
| Congestion control | Yes, and it will slow itself down | None, unless you write it |
| Header size | 20 bytes minimum | 8 bytes, fixed |
| Specification | RFC 9293, August 2022 | RFC 768, August 1980, never revised |
The choice comes down to one question: is late data still useful? For a file, a web page or an email: yes, so TCP's resending is exactly right. For a live voice call: no. By the time TCP has resent a lost piece of sound, that moment of the conversation is over, and everything behind it had to wait. That is why voice, video calls and games use UDP and accept a short glitch instead.
TCP also has two separate brakes, and people often mix them up. Flow control protects the receiver: the other side says how much it can take (in ss -ti this is snd_wnd). Congestion control protects the network: the sender guesses how much the path can carry (cwnd, defined in RFC 5681). TCP always sends the smaller of the two. UDP has neither.
DNS mostly uses UDP for a different reason: a question and its answer usually fit in one packet each, so a handshake would triple the cost. Section 5.5 shows it.
The mental model: UDP is IP with port numbers added and nothing else. TCP is a complete reliability protocol that happens to travel inside IP. When people say "UDP is unreliable", they really mean "UDP adds nothing", because IP was never reliable to begin with.
5.5 The Same Question Both Ways
DNS can use either transport, so it is the easiest place to compare them. dig tells you which one it used:
$ dig example.com A | tail -4
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Mon Sep 07 23:09:53 CEST 2026
;; MSG SIZE rcvd: 72
$ dig +tcp example.com A | grep SERVER
;; SERVER: 127.0.0.53#53(127.0.0.53) (TCP)
The answer is 72 bytes. Over UDP that is one packet out and one back. Over TCP the same answer needs a handshake first, then the question, then the answer, then closing the connection. For such a small exchange, the overhead is bigger than the data.
DNS still needs TCP. When an answer is too big for UDP, the server marks it as truncated and the client asks again over TCP. So a firewall that allows UDP port 53 but blocks TCP port 53 creates a confusing problem: most lookups work, and only the ones with big answers time out.
5.6 What a UDP Failure Looks Like
TCP says "no" clearly: when nothing listens on a port, the other side answers with a reset and you get "connection refused". UDP has no handshake, so it often says nothing at all. Here is the same small UDP message sent to a closed port twice, once on this machine and once on a remote server:
$ python3 -c "
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.settimeout(3)
s.connect(('127.0.0.1', 9999)); s.send(b'hello')
try: print(s.recv(1024))
except Exception as e: print(type(e).__name__, e)"
ConnectionRefusedError [Errno 111] Connection refused
$ # the same script with ('1.1.1.1', 9999):
TimeoutError timed out
On this machine, the kernel saw that nothing listened on UDP port 9999 and sent back an ICMP "port unreachable" error, which Python reports as a refusal. On the remote server, that error message was never sent, or was dropped on the way back. So the send looks successful, and then nothing happens.
That is why nobody can easily prove from outside that a UDP port is open. With UDP, silence can mean open, closed or blocked. Only a real reply from the application tells you.
5.7 What TCP's Reliability Does Not Cover
TCP promises that your bytes arrive, complete and in order, at the other computer's kernel. It does not promise that the program on that computer ever reads them. Why you care: "the data was sent successfully" does not mean "the server did something with it". Mixing the two up is how orders, payments and form submissions get lost without any error.
Think of a large office building with a mailroom. TCP is a courier that guarantees your parcel reaches the mailroom, complete and undamaged. The courier does not check whether anyone collects the parcel from the mailroom, opens it, or acts on it.
On a computer, the mailroom is the kernel: the core of the operating system, which handles the network for all programs. The person in the office is the program, for example a web server running PHP. TCP delivers to the kernel, and the program has to pick up the data itself.
A small lab test shows this. A test program accepts a connection but never reads anything. The other side sends it 100000 bytes, and the send reports full success:
send() returned 100000
Recv-Q Send-Q Local Address:Port Peer Address:Port
0 34518 127.0.0.1:34158 127.0.0.1:43397
100000 0 127.0.0.1:43397 127.0.0.1:34158
The second line of the ss output is the receiving side. Its Recv-Q (receive queue) holds all 100000 bytes: they are in the mailroom, waiting. The program has not read a single byte, but the sender was still told "success".
A TCP acknowledgement has the same limit. It is the mailroom signing for the parcel. It proves the data arrived, not that the PHP script ran or that the database saved the order. If the server crashes just after signing, the sender sees success and the work never happens.
That is why you can only trust an answer from the program itself. "The data was sent" says the parcel reached the mailroom. "The server replied 201 Created" says someone opened it and did the work. The HTTP methods article covers what to do when that reply never arrives.
6. Advanced Use Cases
6.1 MTU, and the Packet That Is One Byte Too Big
Why you care: when a site starts loading and then hangs, while small requests work fine, the cause is often packet size, not bandwidth.
An IP packet may be up to 65535 bytes, but the network link underneath sets its own limit: the MTU (short for Maximum Transmission Unit). On Ethernet the MTU is 1500 bytes:
$ ip link show eth0 | head -1
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP ...
You can test the limit with ping. -M do sets the Don't Fragment bit, which forbids splitting the packet, and -s sets the size of the payload:
$ ping -c 1 -M do -s 1472 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 1472(1500) bytes of data.
1480 bytes from 1.1.1.1: icmp_seq=1 ttl=58 time=6.02 ms
$ ping -c 1 -M do -s 1473 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 1473(1501) bytes of data.
ping: local error: message too long, mtu=1500
1472 works and 1473 does not. ping shows the sum in brackets: 1472 bytes of payload, plus 8 bytes of ICMP header, plus 20 bytes of IP header, is exactly 1500. One byte more does not fit.
Without Don't Fragment, IPv4 splits a packet that is too big into smaller pieces, called fragments, and the receiver puts them back together. That works, but it is best avoided:
- If one fragment is lost, the whole packet is lost, because a single piece cannot be resent.
- Firewalls and load balancers often drop fragments, because only the first piece contains the TCP or UDP header they need to inspect.
- Putting the pieces back together costs memory at the receiver.
TCP avoids the problem: at the start of a connection both sides agree on a maximum segment size that fits. That is why a normal web page never fragments, while a large UDP message might.
IPv6 goes further: routers are not allowed to fragment at all. Every IPv6 link must carry at least 1280 bytes. A router that receives a packet that is too big drops it and sends back an ICMPv6 "Packet Too Big" message, so the sender can send smaller packets. This only works if that message gets back. A firewall that blocks all ICMP creates a path MTU black hole: ping works, the connection opens, and then it hangs the moment a full-size packet is sent. Section 7.6 explains why this keeps happening.
6.2 NAT: What Actually Gets Rewritten
Why you care: NAT (short for Network Address Translation) is why a home server cannot be reached without port forwarding, and why idle SSH sessions freeze.
NAT lets every laptop, phone and television in a building share one public IPv4 address. The router does not only rewrite addresses, but also port numbers (RFC 3022 calls this NAPT). It keeps a table so it knows which reply belongs to which device:
OUTBOUND, as the laptop sends it
src 192.168.88.2:41026 -> dst 104.20.23.154:443
OUTBOUND, after the router rewrites it
src 203.0.113.27:52001 -> dst 104.20.23.154:443
INBOUND reply, as it arrives at the router
src 104.20.23.154:443 -> dst 203.0.113.27:52001
|
the table says 52001 belongs to 192.168.88.2:41026,
so the destination is rewritten back before delivery
Three practical consequences follow:
- Connections must start from inside. The outgoing packet creates the table entry. An incoming packet that nobody asked for matches nothing and is dropped. That is why a self-hosted service needs port forwarding.
- The router remembers every connection. If it reboots, or forgets an idle entry, the connection dies without an error on either side. A frozen SSH session after a long pause is usually a NAT entry that timed out.
- Your provider may use NAT too. Providers that run out of IPv4 addresses put many customers behind one address (carrier-grade NAT). Your router then gets an address from
100.64.0.0/10, a block reserved for this in RFC 6598. If you see100.64.x.xon your router's internet side, port forwarding cannot work, because that address is not really yours.
6.3 Running Dual Stack, and Finding Out Yours Is Broken
Why you care: broken IPv6 hides itself. Most visitors never notice, and the few who do cannot reach your site at all.
Most machines today run IPv4 and IPv6 side by side ("dual stack"). This lab machine has no working IPv6, and daily use does not reveal it:
$ dig +short AAAA example.com
2606:4700:10::6814:179a
2606:4700:10::ac42:93f3
$ curl -6 -sS -o /dev/null https://example.com/
curl: (7) Failed to connect to example.com port 443 after 0 ms: Couldn't connect to server
$ curl -4 -s -o /dev/null -w '%{http_code} %{remote_ip} %{time_total}\n' https://example.com/
200 104.20.23.154 0.033117
The site has IPv6 addresses (AAAA records), this machine cannot use them, and the page still loads in 33 milliseconds. The browser tries both address families at the same time and uses whichever answers first. This is called Happy Eyeballs; the article on what happens when you enter a URL explains how it works.
So when one visitor cannot reach a site that works for everyone else, and it does work for them over mobile data, suspect a broken address family. Test each one separately:
$ curl -4 -sS -o /dev/null https://example.com/ ; echo "IPv4 exit $?"
$ curl -6 -sS -o /dev/null https://example.com/ ; echo "IPv6 exit $?"
If one works and the other fails, you know which half of the network to look at. Run the same two commands from the server side too: a site with an AAAA record but no working IPv6 is broken, even though most visitors never notice.
6.4 QUIC: Rebuilding TCP on Top of UDP
Why you care: HTTP/3 runs over QUIC, and QUIC runs over UDP. A firewall that only allows TCP quietly takes HTTP/3 away from your visitors.
QUIC (RFC 9000, May 2021) does what TCP does, reliability, ordering and flow control, and adds encryption. But it sends everything inside UDP packets. The reason is practical: a brand-new protocol number in the IP header would be dropped by firewalls and routers everywhere. UDP already gets through.
QUIC also solves a TCP problem. A TCP connection is tied to its addresses and ports, so changing networks breaks it. QUIC uses its own connection ID instead. When you walk out of the house and your phone moves from wifi to mobile data, your IP address changes, but the download continues.
For site owners, the important part: HTTP/3 uses UDP port 443, and the server announces it in a header on a normal HTTP/2 response:
$ curl -sI https://cloudflare.com/ | grep -i alt-svc
alt-svc: h3=":443"; ma=86400
If a firewall allows TCP 443 but not UDP 443, the browser tries HTTP/3, gets no answer, and falls back to HTTP/2 without telling anyone. The article comparing HTTP/1.1, HTTP/2 and HTTP/3 covers what is lost when that happens.
There is one more trade-off. TCP runs in the operating system's kernel, so one command (ss -ti) shows the state of every TCP connection. QUIC runs inside the browser or the server application. That means it improves with every browser update, but tools like ss and tcpdump filters written for TCP cannot see inside it.
7. Something Most Users Do Not Know
7.1 The Path Back Is Not the Path Out
Section 5.3 traced nine hops to 104.20.23.154. Section 4.4 pinged the same address and got ttl=58, which from a start of 64 means the reply crossed six routers. Nine out, six back, at the same moment, to the same host.
Nothing is wrong. Routing on the internet is decided independently by each network for traffic it is sending, so the forward and return paths are separate decisions made by different organisations with different commercial arrangements. Symmetry is a coincidence, not a rule.
The consequences are practical and constant:
- A traceroute shows you half the story. When it looks clean and the connection is still slow, the congestion may be entirely on the return path, which your trace never touched. A trace from the far end back to you is a different measurement, not a repeat of the same one.
- Loss can be one-directional. Requests arriving perfectly while responses are dropped looks like a broken server and is a broken network.
- Firewalls that only see one direction get confused. Asymmetric routing through a stateful firewall means the return packets arrive at a device with no record of the connection, and get dropped as invalid.
This is also why the TTL arithmetic in 4.4 is an estimate. It counts the return trip, and it assumes a starting value you are inferring from the number that arrived.
7.2 A Dotted Quad Is Only a Display Convention
Section 1.5 showed that an IPv4 address is a 32-bit integer. The dots are for people, and the standard C library will happily accept several other spellings of the same number:
$ ping -c1 2130706433 | head -1
PING 2130706433 (127.0.0.1) 56(84) bytes of data.
$ ping -c1 0x7f000001 | head -1
PING 0x7f000001 (127.0.0.1) 56(84) bytes of data.
$ ping -c1 127.1 | head -1
PING 127.1 (127.0.0.1) 56(84) bytes of data.
Decimal, hexadecimal and a shortened form all resolve to 127.0.0.1. There is one more, and it is the dangerous one:
$ python3 -c "
import socket
for a in ['127.0.0.1', '127.1', '2130706433', '010.0.0.1']:
print('%-12s -> %s' % (a, socket.inet_ntoa(socket.inet_aton(a))))"
127.0.0.1 -> 127.0.0.1
127.1 -> 127.0.0.1
2130706433 -> 127.0.0.1
010.0.0.1 -> 8.0.0.1
A leading zero means octal, so 010 is 8. The address 010.0.0.1 does not point at 10.0.0.1; it points at a completely unrelated host.
This matters to anyone who validates a URL before fetching it. Application code that checks whether a hostname "starts with 10." or "is not 127.0.0.1" can be walked straight past with 2130706433 or 0177.0.0.1, while the operating system resolves it to loopback and connects to an internal service. That is the server-side request forgery class of bug, and the reason the fix is never string matching: resolve the name to an address first, parse it as an address, and then test that address against the reserved ranges in section 4.2.
7.3 IPv6 Adoption Has a Weekly Rhythm
Google publishes the share of its users who reach it over IPv6, measured daily since 2008. The numbers tell the deployment story on their own: 0.14 percent on 4 September 2008, 0.65 percent on World IPv6 Launch day in June 2012, 13.04 percent in September 2016, 35.61 percent in September 2021, and 50.30 percent on 5 September 2026. The measurement first touched 50 percent on 28 March 2026. Both of those dates are Saturdays, and that is not a coincidence.
The interesting part is not the trend but the texture. Averaging Google's published daily figures for the 97 days from 1 June to 5 September 2026 by day of week gives this:
Mon 46.78%
Tue 46.80%
Wed 46.87%
Thu 47.16%
Fri 48.45%
Sat 50.32% <- weekends are three and a half points higher
Sun 49.13%
IPv6 usage rises every weekend and falls every Monday, by a margin far too large and too regular to be noise. Nothing about the protocol changes on a Saturday. What changes is who is using the internet: at the weekend people are at home on consumer broadband and mobile networks, where IPv6 has been deployed as standard for years. On weekdays a large share of the same people sit behind corporate networks, which are overwhelmingly still IPv4 only.
Two useful things follow. The world crossed 50 percent IPv6 at weekends months before it will cross it on a Tuesday. And if your site's audience is businesses, its IPv6 share is lower than the global figure suggests, while a consumer audience is already past half.
7.4 IPv6 Threw Away the Header Checksum
IPv4 carries a 16-bit checksum over its own header. Because the TTL changes at every hop, that checksum has to be recalculated by every router on the path, for every packet. It was a real cost when routers were slow, and it protected against something that had already been checked twice: Ethernet has a frame check sequence below, and TCP and UDP have their own checksums above.
IPv6 removed the field entirely. The integrity of the header is left to the link layer beneath and the transport above, which is why RFC 8200 also closed the loophole that made the transport checksum optional. UDP over IPv4 may send a checksum of zero, meaning "not computed", exactly as RFC 768 allowed in 1980. Over IPv6 that is forbidden: "Unlike IPv4, the default behavior when UDP packets are originated by an IPv6 node is that the UDP checksum is not optional", and IPv6 receivers "must discard UDP packets containing a zero checksum and should log the error".
The trade is honest: one fewer thing for every router to do, in exchange for one mandatory thing at each end. It is the same instinct as the rest of IPv6, and the same instinct that produced IP in the first place. Keep the middle of the network simple and push the work to the edges.
7.5 One Address, Many Machines
An IP address is normally assumed to identify one machine. For most of the internet's busiest addresses that is false. Anycast means many machines in many countries announce the same address, and the routing system delivers your packets to whichever one is nearest to you.
$ ping -c1 1.1.1.1 | sed -n 2p
64 bytes from 1.1.1.1: icmp_seq=1 ttl=58 time=5.64 ms
Light travels about 200 kilometres per millisecond in fibre, so a five-millisecond round trip means the other end is at most 500 kilometres away, and that is before any equipment in between adds delay. That answer did not come from a single machine serving the world; it came from the nearest site announcing that address. A colleague in another country pings the same address and also gets a few milliseconds, from different hardware.
DNS root servers, public resolvers and every large content network work this way. It changes how you read your own tools:
- Two people running
tracerouteto the same address legitimately reach different machines, so comparing their traces proves nothing. - "The server is up for me" and "it is down for me" can both be true at once.
- An address in a geolocation database is a guess about a prefix, not a fact about a machine, and for anycast addresses there is no single right answer.
7.6 Half of the Network's Error Messages Are Optional
ICMP is not a diagnostic add-on; it is how the IP layer reports failure. "Time exceeded" is what makes traceroute work. "Destination unreachable, port unreachable" is what turns a UDP send into a refusal instead of a timeout, as section 5.6 showed. "Packet too big" is what makes path MTU discovery work, and IPv6 depends on it completely.
None of it is guaranteed to arrive. Every one of those messages can be, and routinely is, dropped by a firewall configured on the belief that "blocking ICMP" is a hardening step. What it actually does is remove the network's ability to tell you why something failed, and in the MTU case it removes the mechanism that makes large transfers work at all.
The practical rules that follow:
- A host that does not answer
pingmay be perfectly healthy. Test the port and the protocol you care about, not the echo. - A host that does answer
pingis not necessarily working. The kernel replies to echo requests while the application behind it is dead. - Blocking ICMP wholesale on IPv6 breaks the protocol. Neighbour discovery, address configuration and Packet Too Big all run over ICMPv6, protocol number 58.
- The "it hangs after a few hundred kilobytes" bug is almost always MTU. Small responses fit in one packet and work; a large one needs full-size packets and a Packet Too Big message that never arrives.
7.7 One Person, Many Addresses
Section 7.5 showed one address that is many machines. The reverse is just as common and catches more people. A single visitor can appear as a stream of different addresses, and on IPv6 that happens by design.
RFC 8981 of February 2021 defines temporary IPv6 addresses, because a stable interface identifier is a tracking cookie that cannot be cleared: "anytime a fixed identifier is used in multiple contexts, it becomes possible to correlate seemingly unrelated activity using this identifier". So a host generates extra randomised addresses, uses them for outgoing connections, and replaces them after hours or days. Most operating systems now do this by default:
$ sysctl net.ipv6.conf.all.use_tempaddr
net.ipv6.conf.all.use_tempaddr = 2 # 2 = prefer a temporary address for outgoing connections
Add the ordinary causes and the picture is complete. One person moves between mobile data, home wifi and an office; a mobile network renumbers them; a router reconnects and the ISP hands out a different address; a VPN moves them to another country. Meanwhile, in the other direction, carrier-grade NAT can put thousands of unrelated subscribers behind the one address you are looking at.
So an address is not a user, in either direction, and any feature built as though it were will misfire. Rate limiting by address throttles a whole office. Blocking by address blocks a neighbourhood. "Log in from a new IP" alerts fire every time a phone changes cell. Counting unique addresses as unique visitors overcounts the mobile audience and undercounts the corporate one.
There is a legal dimension in Europe as well, and it is worth knowing even though it is not advice. GDPR Recital 30 names "internet protocol addresses" among the online identifiers a person may be associated with, and in Case C-582/14 (Breyer), decided on 19 October 2016, the Court of Justice of the European Union held that a dynamic IP address held by a website operator can be personal data where that operator has lawful means of identifying the visitor with additional information held by the access provider. The practical questions that follow are ordinary engineering ones: whether you need the whole address, how long the logs keep it, whether it is passed to a third party, and whether truncating the last octet would serve the purpose just as well. The answers depend on your jurisdiction and your purpose, so treat this as a reason to ask rather than as a ruling.
7.8 Knowing Where IP Stops
The IP layer answers exactly one question: which machine. Everything else belongs to a neighbour, and knowing the boundary is most of the diagnostic skill:
- Which name maps to this address is DNS. "Could not resolve host" never reached the IP layer. See the DNS article.
- Which program on the machine gets the bytes is the port, in the transport header rather than the IP header. See the TCP ports article.
- Whether the data arrives complete and in order is TCP or QUIC, never IP.
- Which site or certificate is SNI and the
Hostheader, which is why one address serves thousands of websites. - Which cable, and which machine on this link is the link layer: MAC addresses, ARP for IPv4 and neighbour discovery for IPv6. It is replaced at every hop and never travels.
- Who is allowed to connect is authentication. An IP address is not an identity, however often an allowlist is asked to pretend otherwise.
The whole chain from typing a name to seeing a page is laid out in the article on what happens when you enter a URL, and this article is the layer that sits underneath all of it.
Back to top8. Best Practices
- Say which address you mean. "My IP address" is ambiguous once a machine has six of them and a router in front. Name the interface, or say public or private.
- Ask the routing table before you guess.
ip route get <destination>tells you the interface, the gateway and the source address in one line, without sending anything. - Test both address families explicitly.
curl -4andcurl -6, every time a site works for most people and not for one. Dual stack hides its own failures by design. - Publish an
AAAArecord only when the service actually answers on it. A record pointing at a listener that is not there is a slow page for every IPv6 visitor, and invisible to everyone else. - Never treat an IP address as an identity. Carrier-grade NAT puts thousands of subscribers behind one address, mobile addresses change constantly, IPv6 hosts rotate temporary addresses on purpose, and an office is one address for hundreds of people. Rate limiting and blocking by address will catch the innocent.
- Configure the trusted proxies before you read
X-Forwarded-For. Accept the header only on connections from your own CDN or load balancer, take the entry your infrastructure added rather than the leftmost one, and check this the same day you put a site behind a CDN. - Decide deliberately how long logs keep a whole address. In Europe an address can be personal data; truncating the last octet often serves the operational purpose just as well.
- Confirm work at the application level, not the transport level. A successful write proves the bytes reached a buffer. Only a response says the request was carried out.
- Allow the ICMP types that make the network work, in particular Packet Too Big and Time Exceeded, and all of ICMPv6. Blocking the lot is not hardening; it is removing your own error messages.
- Prefer a firewall rule with an explicit prefix.
203.0.113.4/32says what you meant. A bare address in a tool that assumes a classful mask does not. - Resolve first, then validate. Any code that fetches a user-supplied URL must resolve the name, parse the result as an address, and check that address against the reserved ranges, because
2130706433and0177.0.0.1are both loopback. - Watch for
169.254.x.xand100.64.x.x. The first means DHCP failed. The second means your ISP has put you behind carrier-grade NAT and inbound connections will never work. - Do not fight fragmentation, avoid it. Keep UDP payloads inside the path MTU, and let TCP negotiate its segment size. If large transfers stall while small ones succeed, suspect MTU before bandwidth.
- Document the subnet plan next to the service that uses it. Container bridges, VPNs and office LANs collide surprisingly often on
192.168.1.0/24and172.17.0.0/16, and the symptom is a route that quietly steals traffic. - Go to the sources when it matters. IPv4 is RFC 791 and IPv6 is RFC 8200; UDP is RFC 768 and TCP is RFC 9293; host requirements are RFC 1122; the reserved ranges are the IANA IPv4 Special-Purpose Address Registry and its IPv6 equivalent; the protocol numbers are the IANA Protocol Numbers registry. On Linux the local behaviour is in
man 7 ip,man 8 ip-routeand the kernel'sDocumentation/networking/ip-sysctl.rst.
9. Common Mistakes
9.1 Myth versus Reality
| Myth | Reality |
|---|---|
| A machine has an IP address | It has one per configured interface, plus loopback and a link-local per interface. The lab machine in section 4.1 has eleven. |
| The address in my access log is the visitor's computer | It is whatever the last NAT device on the path used. It identifies a household, an office or an entire ISP region under carrier-grade NAT. |
| IP delivers data reliably | RFC 1122: datagrams "may arrive at the destination host damaged, duplicated, out of order, or not at all". TCP adds the reliability; IP never had it. |
| TCP and UDP are different networks | They are two values, 6 and 17, in one byte of the same IP header. The packets travel identically. |
| UDP is unreliable because something is wrong with it | UDP adds nothing to IP except ports and a length. The unreliability is IP's, and it is deliberate. |
| TTL is a timer in seconds | RFC 791 defined it that way and no router implements it that way. Every hop subtracts one. IPv6 renamed it Hop Limit. |
| The route to a host is the route back | The two are decided separately by different networks. Section 7.1 measures nine hops out and six back to the same address. |
If ping fails, the host is down |
ICMP echo is filtered on a great many hosts that are serving traffic normally. |
| Blocking ICMP makes a network safer | It breaks path MTU discovery, and on IPv6 it breaks address configuration and neighbour discovery entirely. |
| My access log shows the visitor's address | Behind a CDN or load balancer it shows the proxy. The visitor's address survives only in a header that anyone can forge. |
A successful send() means the other side got my data |
It means the kernel accepted it into a buffer. Section 5.7 sends 100000 bytes to a program that reads none of them and gets complete success. |
| Flow control and congestion control are the same thing | Flow control is the window the receiver advertises (snd_wnd); congestion control is the sender's own estimate of the path (cwnd). Both appear in ss -ti, and the smaller one wins. |
| One address means one server | Anycast means one address can be hundreds of machines on several continents. |
A /24 gives me 256 usable addresses |
254. The first is the network address and the last is the broadcast address. |
| Address classes A, B and C still apply | CIDR deprecated them in 1993. The prefix length is the only thing that decides where the network part ends. |
010.0.0.1 is the same as 10.0.0.1 |
The leading zero means octal, so it is 8.0.0.1. Section 7.2 shows the library doing it. |
| IPv6 is coming | Google measured 50.30 percent of its users on IPv6 on Saturday 5 September 2026. It arrived; what is left is mostly corporate networks. |
| My site works, so IPv6 is fine | Happy Eyeballs hides a broken address family behind a few milliseconds. Test with curl -6 to actually find out. |
9.2 Other Traps to Avoid
- Reading a private address as evidence of anything. Private hops appear inside public paths, as section 5.3 shows. They tell you about the provider's numbering, not about where the packet is.
- Assuming the wrong default route. A laptop on wifi and Ethernet has two, and the metric decides. A VPN installs more. When traffic goes somewhere unexpected, print the table before theorising.
- Comparing traceroute hop times to each other. Each line is a separate round trip to a different router with its own rate limiting. Only the overall trend means anything.
- Reading stars in the middle of a trace as a fault. Routers may ignore expired packets. Stars from one hop to the end are meaningful; a single star with working hops after it is not.
- Overlapping subnets. A container bridge on
172.17.0.0/16and an office VPN on the same range means one of them silently wins, and only for some destinations. - Blocking UDP 443 while allowing TCP 443. HTTP/3 fails silently and falls back, so nobody reports it and you lose the benefit you paid for.
- Allowing TCP 53 and forgetting UDP 53, or the reverse. DNS needs both. Blocking one gives you a resolver that works until an answer is large.
- Trusting geolocation for an anycast or mobile address. It is a lookup of a prefix registration, and it is regularly wrong by a country.
- Hardcoding an address where a name belongs. Content networks, cloud load balancers and mail providers change addresses without notice, and the name is the part they promise to keep working.
- Taking the first entry in
X-Forwarded-For. Each proxy appends, so the leftmost value is the one the client supplied and the rightmost ones are yours. Reading from the wrong end hands an attacker control of your logs and your rate limiter. - Monitoring a QUIC site with tools that only understand TCP. There is no
ss -tiequivalent for a QUIC connection; the numbers live in the application, so the graph that used to show retransmits will simply be empty. - Forgetting that a firewall rule for an address family only covers that family. An IPv4 rule set with no IPv6 equivalent is an open door on every dual-stack host.
10. Summary
- IP carries one packet toward one address, and promises nothing else. RFC 1122 lists what may go wrong: damaged, duplicated, out of order, or not at all.
- The stack has four layers, not seven. Link, internet, transport, application. The link layer is replaced at every hop; the IP packet is what travels end to end.
- One byte in the IP header decides the transport. 6 is TCP, 17 is UDP, 1 is ICMP, 58 is ICMPv6. A firewall rule for one says nothing about the others.
- TCP adds reliability, ordering and congestion control; UDP adds ports and a length. Both are carried identically by IP.
- An address is a 32-bit number (IPv4) or a 128-bit number (IPv6). Dotted decimal and hexadecimal groups are display conventions, and the library accepts several other spellings of the same value.
- A machine has many addresses. Loopback, one per interface, a link-local per interface, plus container bridges. The routing table picks which one is the source.
- Private ranges never appear on the public internet:
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16, plus100.64.0.0/10for carrier-grade NAT and169.254.0.0/16when DHCP fails. - The prefix length answers one question: is this destination on a network I am attached to, or does it need a gateway? Longest prefix match decides, and
defaultis a prefix of length zero that always loses. - TTL is a hop counter. Senders start at 64, 128 or 255, so the arriving value tells you both the return hop count and something about the sender.
- The path out is not the path back. Nine hops out and six back to the same host, measured in the same minute.
- MTU is 1500 on Ethernet, which leaves 1472 bytes for an ICMP echo payload. Larger packets are fragmented unless
Don't Fragmentis set, and fragmentation is best avoided. - IPv6 forbids routers from fragmenting, requires a minimum link MTU of 1280, and depends on ICMPv6 Packet Too Big getting back to the sender. Block that message and large transfers hang.
- NAT rewrites the address and the port, keeps the mapping as state in the middle of the network, and is why inbound connections need explicit configuration and why idle sessions die.
- QUIC rebuilt reliability on top of UDP to get past middleboxes, and identifies connections by a connection ID so changing network does not kill them. HTTP/3 is UDP port 443.
- Dual stack hides its own breakage. Happy Eyeballs turns a dead address family into a few wasted milliseconds, so test with
curl -4andcurl -6separately. - IPv6 passed half of Google's users on Saturday 28 March 2026, and its weekly rhythm (50.32 percent on Saturdays against 46.87 percent on Wednesdays) shows the remaining gap is corporate networks.
- An IP address is not an identity, in either direction. One address can be a household, an office, thousands of carrier-grade NAT subscribers or hundreds of anycast machines; one person can be a stream of addresses, because IPv6 rotates temporary ones by design (RFC 8981) and mobile networks renumber constantly.
- Behind a CDN, your log shows the CDN. The visitor's address survives only in
X-Forwarded-FororForwarded, which RFC 7239 says "cannot be relied upon to be correct". Trust it only from a proxy you operate, and read it from the right end. - TCP's reliability stops at the far kernel. A successful send means bytes are in a buffer; only an application-level response means work was done.
- Flow control and congestion control are different windows.
snd_wndis what the receiver will accept,cwndis what this sender thinks the path will carry, andss -tishows both.
The commands worth keeping next to a terminal:
WHAT AM I
ip -br addr # every address, one line per interface
ip route # the whole routing table
ip route get 8.8.8.8 # interface, gateway and source for ONE destination
curl -s https://api.ipify.org # the address a server actually sees
ip neigh # the link-layer neighbours (ARP / ND)
IS IT REACHABLE
ping -c3 host # IP layer only; silence proves little
ping -6 -c3 host # the other address family
traceroute -n host # the path OUT, one direction only
mtr -n host # the same, repeated, with loss per hop
WHICH FAMILY IS BROKEN
dig +short A host ; dig +short AAAA host
getent ahosts host # what the resolver will offer, in order
curl -4 -sS -o /dev/null https://host/ ; echo $?
curl -6 -sS -o /dev/null https://host/ ; echo $?
MTU AND FRAGMENTATION
ip link show eth0 # mtu 1500 on Ethernet
ping -M do -s 1472 host # largest payload that fits: 1500 - 20 - 8
ping -M do -s 1473 host # one byte too many, on purpose
# small requests fine, large ones hang -> suspect MTU, not bandwidth
READING AN ADDRESS
10.x, 172.16-31.x, 192.168.x private (RFC 1918), never on the public internet
100.64.x - 100.127.x carrier-grade NAT: no inbound, ever (RFC 6598)
169.254.x DHCP failed and the host gave up
127.x loopback, the whole /8
fe80:: IPv6 link-local, this cable only
192.0.2.x, 198.51.100.x, 203.0.113.x documentation only (RFC 5737)
PREFIX ARITHMETIC
python3 -c "import ipaddress; n=ipaddress.ip_interface('192.168.1.198/24');
print(n.network, n.netmask, n.network.broadcast_address)"
/24 = 256 addresses, 254 usable /16 = 65536 /8 = 16777216
PROTOCOL NUMBERS IN THE IP HEADER
1 ICMP 6 TCP 17 UDP 41 IPv6 47 GRE 50 ESP 58 ICMPv6
getent protocols tcp udp icmp ipv6-icmp
LIVE CONNECTION STATE
ss -ti # per-connection: cwnd, snd_wnd, rtt, pmtu, algorithm
# cwnd = congestion control, this sender's guess about the path
# snd_wnd = flow control, what the RECEIVER advertised
# a UDP or QUIC socket shows none of it; that state lives in the application
THE ADDRESS IN YOUR LOG
behind a CDN or proxy, the connection address IS the proxy
X-Forwarded-For / Forwarded (RFC 7239) carry the client, and can be forged
accept them only from proxies you operate, and read from the RIGHT-hand end
sysctl net.ipv6.conf.all.use_tempaddr # 2 = this host rotates IPv6 addresses
All command output in this article was produced on 7 September 2026 on Ubuntu 24.04 with Linux 6.11, iproute2 6.1.0, curl 8.5.0, DiG 9.18.39 and Python 3.12, with the lab's public address and its provider's first hop replaced by RFC 5737 documentation addresses. The standards references were checked the same day against RFC 768, 791, 801, 1122, 1918, 3022, 4291, 4632, 5681, 5737, 6598, 7239, 8200, 8305, 8981, 9000 and 9293, IEN 2, the IANA registries for protocol numbers, IP version numbers and IPv4 special-purpose addresses, GDPR Recital 30 and Court of Justice of the European Union Case C-582/14, and Google's published IPv6 adoption measurements through 5 September 2026.
And when a site delivers its first few kilobytes and then hangs forever, while ping answers and the connection opens without complaint, the network is not slow and the server is not overloaded: something on the path is discarding the one small ICMP message that would have told the sender its packets are too big.


Peter is a Joomla specialist and a Linux admin for fast, secure and scalable websites.











