Skip to content
vamola.devv2.4 · online

How fragma Works: SNI Blocking and TLS Record Fragmentation

Last Updated: 2026-11-25·Reading Time: 3 min·fragma

This page explains what fragma does to a connection, step by step, so you do not have to take it on trust. Everything below matches the source code at github.com/vam0laa/fragma, which is about 2,000 lines of Go with no dependencies.

What an SNI block reads

Every HTTPS connection starts with a TLS ClientHello: the first message your browser sends. It contains a field called SNI (Server Name Indication) with the plain-text name of the site, for example discord.com. The name is there so that one IP address can serve many sites.

Some ISPs run a box on the path that reads this name in the first packet. If it is on a block list, the box cuts the connection (usually with a TCP reset). Nothing is decrypted: the name simply travels in the clear.

Why splitting the record works

A TLS message travels inside records, each with a 5-byte header (type, version, length). The blocking box looks for the name in the first record. fragma rewrites the ClientHello into two valid TLS records, cut in the middle of the site name:

Before and after (simplified)
before:  [record: ...... discord.com ......]
after:   [record: ...... disc] [record: ord.com ......]

A real server accepts this, because the TLS standard allows a handshake message to be spread over several records, and it puts the pieces back together. A simple box that reads only the first record sees half a name and finds nothing to block.

TCP splitting is different

The older trick is to split the packet at the TCP level, which leaves the TLS record whole. On the ISP we measured, that did not work (about half of the tries failed), while splitting the TLS record worked 30 times out of 30. Your ISP may differ. fragma experiment tries six ways of sending the hello, ten times each, and prints the counts.

How the traffic reaches fragma

On Linux, fragma install starts a systemd service that creates one nftables table, ip fragma. It redirects outgoing HTTPS (TCP port 443) to fragma's local listener. When the service stops, even by a crash, the table is removed.

Terminal (bash)
sudo nft list table ip fragma     # exists only while fragma runs

Two safety rules are in that table. Local and LAN addresses are never redirected. And fragma marks its own outgoing sockets (SO_MARK), so a connection that fragma opens is not redirected back into fragma, which would be a loop.

Deciding which connections to touch

For each redirected connection fragma reads the ClientHello, finds the site name, and decides:

  1. The site is on a list (built in for Discord and Roblox, or added with fragma add, or learned): the hello is sent as two records. If the server hangs up on that, fragma retries once without fragmenting and remembers the server for 30 minutes, because some servers refuse a fragmented hello.
  2. The site is on no list: the hello is sent unchanged, byte for byte. If the server hangs up, which is the typical sign of a block, fragma retries once fragmented. If that works, the site is learned and written to /var/lib/fragma/learned.txt.

So a site that is not blocked is passed through untouched, and nothing about what you visit is logged.

What fragma cannot do

  • It only changes the first TLS message of a TCP connection. UDP (QUIC, voice) is not touched, and neither is IPv6.
  • It cannot help when the block is by IP address, because the destination does not change.
  • A block that silently drops packets does not look like a hang-up, so it is not detected. Add such a site by hand with sudo fragma add example.com.
  • Servers or firewalls that refuse any fragmented hello need the plain path, which fragma falls back to by itself.

Check it yourself

Terminal (bash)
fragma status                 # is it on?
fragma list                   # built in, yours and learned sites
fragma probe                  # per site: DNS poisoned? IP blocked? SNI blocked?
fragma experiment discord.com # which technique works on your ISP

For install steps and daily use, read the Discord and Roblox guide. For the numbers and a comparison with Zapret, see the project page.