basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    UDP and QUIC: connectionless transport, troubleshooting, and the basis of HTTP/3

    UDP adds only 8 bytes to an IP packet — ports, length, and checksum — with no handshake, acknowledgments, or retransmissions. Covers why DNS, WireGuard, and voice calls run on it, why UDP port checks mislead you, and how QUIC and HTTP/3 are built on top of UDP.

    What you’ll get

    Send one short UDP datagram to three ports on the same server — open (5353), closed (5354), and blocked by an nftables drop rule (5355) — and watch the response in tcpdump:

    sudo tcpdump -nn -i eth0 'udp or icmp'
    # Open port 5353 — request and reply in two packets, no handshake:
    # 19:17:07.469182 IP 10.0.10.20.35591 > 10.0.10.10.5353: UDP, length 4
    # 19:17:07.469300 IP 10.0.10.10.5353 > 10.0.10.20.35591: UDP, length 4
    
    # Closed port 5354 — server kernel replies with ICMP (type 3, code 3):
    # 19:17:07.469429 IP 10.0.10.20.54321 > 10.0.10.10.5354: UDP, length 4
    # 19:17:07.469448 IP 10.0.10.10 > 10.0.10.20: ICMP 10.0.10.10 udp port 5354 unreachable, length 40
    
    # Port 5355 behind an nftables drop rule — silence and timeout:
    # 19:17:07.469522 IP 10.0.10.20.36620 > 10.0.10.10.5355: UDP, length 4

    Diagnosing a closed UDP port comes down to that single ICMP reply line (ICMP and MTU):

    tcpdump -nn -i eth0 'udp or icmp' · Pick a segment
    If a firewall blocks this ICMP reply, the client waits until timeout — indistinguishable from packet loss or a silent UDP service.

    UDP header: 8 bytes and why an unverified transport exists

    The UDP header (RFC 768) consists of four 2-byte fields — 8 bytes compared to TCP’s 20-byte minimum (TCP: flags and states). It carries no seq/ack numbers, handshake flags, window size, or retransmission logic. Each sendto() call becomes a single datagram with preserved message boundaries: it arrives whole, disappears, or arrives out of order.

    UDP packet and encapsulated QUIC · 8 bytes UDP vs 20+ bytes TCPPick a layer
    IP header (L3)End to end
    Protocol / Next · 1 B17 (UDP)Value 17 tells the kernel to pass the payload to UDP
    Src / Dst IP10.0.10.20 > 10.0.10.10Sender and receiver IP addresses
    UDP header (L4) — fixed 8 bytesSeen by sender and receiver

    No kernel connection state: ss -ulnp always shows UNCONN, and ordering or retries live in the application if needed.

    Src Port · 2 B54321Sender port (can be 0 if no reply is expected)
    Dst Port · 2 B53 / 443 / 51820Destination service port (DNS, QUIC/HTTP/3, WireGuard)
    Length · 2 B8 + payloadCombined length of the UDP header and payload in bytes
    Checksum · 2 BchecksumOptional in IPv4, mandatory in IPv6
    QUIC (RFC 9000) inside UDPEncrypted end to end (TLS 1.3)

    QUIC relies on UDP to traverse legacy routers and NAT, while handling delivery, streams, and encryption itself.

    Connection IDsurvives IP changesSwitching from Wi-Fi to cellular keeps the connection alive
    Built-in TLS 1.31-RTT (0-RTT resume)Transport and cryptographic handshakes combine into a single round trip
    StreamsindependentA lost packet stalls only one stream, not the whole page

    Skipping delivery guarantees in UDP is a deliberate trade-off for four workloads:

    • Short request/response (DNS, NTP, DHCP). One packet out, one packet back. Spending three packets on a TCP handshake and four on teardown just to fetch a 60-byte answer adds latency to every page load.
    • Real-time media (VoIP, video calls, online games). If a voice frame from 200 milliseconds ago goes missing, retransmitting it makes no sense — the conversation has moved on. Dropping one slice beats freezing the whole stream for stale audio.
    • VPN tunnels (WireGuard, OpenVPN over UDP). Traffic inside a tunnel is mostly TCP already. Tunneling TCP inside another TCP causes both layers to retransmit and throttle simultaneously on packet loss (“TCP meltdown”). UDP forwards packets directly and lets the inner TCP handle retries.
    • New transport protocols (QUIC). Rolling out a brand-new IP protocol number to replace TCP is impractical because millions of routers and corporate firewalls pass only TCP and UDP. Building the new transport on top of UDP bypasses that barrier.

    Why UDP port checks mislead you

    With TCP, results are clear-cut: an open port returns SYN-ACK, a closed port returns RST, and a firewall DROP times out. With UDP, the three cases look different:

    1. Client✓ UDP :5353 (4 B)
    2. Server :5353✓ received and replied
    3. Client✓ received PONG
    19:17:07.469182 IP 10.0.10.20.35591 > 10.0.10.10.5353: UDP, length 4
    19:17:07.469300 IP 10.0.10.10.5353 > 10.0.10.20.35591: UDP, length 4
    What happened

    The service understood the packet and answered. Many protocols (DNS, WireGuard) stay silent on arbitrary text payloads.

    Check with

    Protocol check: dig @10.0.10.10 example.org or sudo wg show

    1. Client✓ UDP :5354
    2. Server kernel✕ no socket
    3. ICMP reply✕ udp port 5354 unreachable
    4. Client socket✕ Connection refused
    19:17:07.469429 IP 10.0.10.20.54321 > 10.0.10.10.5354: UDP, length 4
    19:17:07.469448 IP 10.0.10.10 > 10.0.10.20: ICMP 10.0.10.10 udp port 5354 unreachable, length 40
    Cause

    Nothing listens on the port and the firewall did not strip the ICMP error — the only case where you know for sure the UDP port is closed.

    Check with

    sudo ss -ulnp 'sport = :5354' on the server

    1. Client✓ UDP :5355
    2. Client✕ TimeoutError
    19:17:07.469522 IP 10.0.10.20.36620 > 10.0.10.10.5355: UDP, length 4
    # Silence: from outside, identical to WireGuard dropping an unauthenticated packet
    Cause

    A firewall DROP and an open but silent UDP service look identical to the client — nothing comes back.

    Check with

    sudo tcpdump -nn -i eth0 'udp port 5355' directly on the server

    QUIC and HTTP/3: why transport moved onto UDP

    HTTP/2 over TCP (TCP: flags and states) solved parallel downloads over one connection, yet kept three TCP limitations:

    1. Two sequential handshakes. First 1 RTT for TCP (SYN / SYN-ACK), then 1–2 RTT for TLS, and only then does the first HTTP request go out.
    2. Head-of-Line Blocking. To the kernel, TCP is one flat byte stream. If a single packet for an image drops, the kernel withholds already-received packets for adjacent scripts and stylesheets until that missing segment is retransmitted.
    3. IP address binding. A TCP connection is locked to its 5-tuple (IP:port). When a phone walks off Wi-Fi onto cellular, its IP changes and every TCP connection breaks.

    QUIC (RFC 9000) moves delivery control and multiplexing out of the kernel into user space over UDP :443, removing all three bottlenecks:

    Property TCP (+ TLS 1.3) UDP QUIC (basis of HTTP/3)
    Handshake before data 2 RTT (TCP + TLS) 0 RTT (none) 1 RTT (0 RTT on repeat visits)
    Ordering and retries Single kernel byte stream None Independent streams over UDP
    Single packet loss Stalls the entire HTTP/2 connection Packet lost Stalls only one stream
    Network switch (Wi-Fi / LTE) Connection drops Stateless Connection ID migrates without dropping
    Header encryption Payload only (TLS) None Nearly the entire transport header is encrypted

    Browsers discover HTTP/3 support through the Alt-Svc header returned on the initial 443/tcp request:

    curl -sI https://cloudflare.com | grep -iE '^HTTP/|alt-svc'
    # HTTP/2 301
    # alt-svc: h3=":443"; ma=86400

    The browser caches that hint for 24 hours (ma=86400 seconds) and attempts QUIC on 443/udp for follow-up requests, falling back to TCP silently if UDP is blocked.

    Six resources download at once over HTTP/2 (TCP) and HTTP/3 (QUIC). One packet of the first file drops on a cellular link. What happens to the other five?
    TCP  (HTTP/2):  [file 1: loss] -> stall for files 2, 3, 4, 5, 6
    QUIC (HTTP/3):  [stream 1: retry]   streams 2..6 continue without pause
    Six resources download at once over HTTP/2 (TCP) and HTTP/3 (QUIC). One packet of the first file drops on a cellular link. What happens to the other five?
    Answer:
    TCP: Head-of-Line Blocking across the whole connection · QUIC: independent streams

    QUIC guarantees delivery just like TCP (lost packets are retransmitted), but tracks each stream separately inside the connection. TCP sees one shared byte stream and holds back later bytes until the gap is filled.

    You probe WireGuard port `51820/udp` from outside with `nc` and get no response. Does that prove a firewall is blocking the port?
    sudo tcpdump -nn -i eth0 'udp port 51820'
    You probe WireGuard port `51820/udp` from outside with `nc` and get no response. Does that prove a firewall is blocking the port?
    Answer:
    Silence on UDP = either firewall DROP or an open service chose not to reply

    ICMP Port Unreachable only comes from a closed port with no firewall hiding it. To distinguish working WireGuard from DROP, watch incoming packets on the server with sudo tcpdump -nn 'udp port 51820' or wg show.

    If it doesn’t work

    A UDP port check via nc -zuv or a script times out, leaving it unclear whether a firewall blocks the port or the service stays silent

    Cause
    UDP has no SYN/SYN-ACK handshake. On a closed port the kernel returns ICMP Port Unreachable (type 3, code 3), while a firewall DROP rule — or a silent protocol like WireGuard — produces total silence.
    Fix
    Test UDP with a protocol-aware query (dig for DNS, wg show for WireGuard) and watch tcpdump -nn 'udp or icmp' on the server to confirm packets arrive and replies leave.

    HTTP/3 is enabled on the web server and the alt-svc: h3=":443" header is present, yet browsers still open the site over HTTP/2

    Cause
    The server, hosting provider, or client network firewall opens only 443/tcp and blocks 443/udp. Browsers try QUIC and silently fall back to TCP.
    Fix
    Add udp dport 443 accept in nftables/ufw and your hosting firewall, then verify on the server with sudo ss -ulnp 'sport = :443' and sudo tcpdump -nn 'udp port 443'.

    A WireGuard tunnel works, then stops accepting incoming packets after a minute of idle time behind NAT

    Cause
    UDP entries in a router's conntrack table (NAT, DNAT, and conntrack) expire quickly — around 30 seconds without traffic, compared to hours for TCP. Once evicted, the router drops incoming packets.
    Fix
    Set PersistentKeepalive = 25 on the client behind NAT so it refreshes the NAT mapping every 25 seconds.

    Voice calls or large UDP DNS responses drop over a VPN, even though TCP sites with MSS clamping load fine

    Cause
    UDP has no TCP SYN header or MSS option, so MSS clamping rules never touch it (ICMP and MTU). Packets larger than the tunnel MTU with the DF bit set vanish when ICMP is blocked.
    Fix
    Configure the right MTU on the tunnel interface (for example 1420 for WireGuard) and permit ICMP Fragmentation Needed / ICMPv6 Packet Too Big.

    ss -tulnp shows UDP services in state UNCONN instead of LISTEN

    Cause
    UDP does not establish kernel-level connections: a socket accepts datagrams from any sender immediately after bind(), with no LISTEN queue.
    Fix
    This is the expected state for a running UDP server. Check only its bind address (0.0.0.0:53 rather than 127.0.0.1:53, Ports and sockets).