Iran bridges
A bridge is a small server inside Iran. Your clients connect to the bridge, and the bridge passes their traffic on to the panel on your server abroad. It helps when international traffic is filtered or cut, because clients then reach an address inside the country. The bridge also tests from Iran, every 5 minutes, whether each inbound answers, and the panel shows Reachable from Iran or Blocked from Iran beside the inbound.
Before you start
Section titled “Before you start”- You need a Linux server inside Iran that you can open as root. The install command adds
nftablesandiproute2itself if they are missing.wireguard-toolsis optional: without it the bridge works, but skips the tests from Iran. With systemd the bridge starts again after a reboot by itself. Without it the installer starts the bridge in the background and says it will not start after a reboot. - The panel must be on HTTPS. A bridge joins only a panel that has it, so that nobody on the way can read or change what the panel tells the bridge. If it is not, the Bridges page says how to turn it on: Settings → Panel → Get a certificate. See HTTPS.
- Bridges are hidden until you turn on Selling and operator tools in Settings → Panel. Have at least one inbound, see Inbounds.
Add a bridge
Section titled “Add a bridge”- Open Bridges and press Add bridge.
- Give it a Name, and the Address clients connect to: the IP address of your server in Iran, or a domain that points to it. Leave How traffic crosses the border at As it is for now.
- Press Create. The panel shows the install command.
- Run that command as root on the server in Iran. It downloads a small program from your own panel, not from GitHub, checks it against the SHA-256 written in the command, and joins the panel. The command carries a secret that works once and lasts 24 hours. If it expires or fails, open the bridge’s menu, choose Install command and copy a new one.
- If the Iranian provider has a firewall, open the UDP ports the install window lists. They are the ports of your inbounds, and the whole port range of an inbound that has one.
- Point an inbound at the bridge: Inbounds → Edit inbound → Clients connect to. New configs and subscription links of that inbound then use the bridge’s address. Older configs keep working, because every bridge forwards every inbound.
The bridge shows Waiting for install until it first reports, then Connected.
A bridge hides the panel’s address only in the configs that name the bridge. Configs made or imported before the inbound pointed at the bridge still name the panel’s address, and so do new configs while the bridge is offline, because the panel then falls back to its own address. The client’s subscription page also lists this server as another way in. If the panel’s address is blocked, send those clients their configs again, or let their subscription links update.
Choose how traffic crosses the border
Section titled “Choose how traffic crosses the border”The form’s How traffic crosses the border has four choices.
| Mode | Use it when |
|---|---|
| As it is | The default and the fastest. The client’s own packets go abroad unchanged, so it works when WireGuard or AmneziaWG gets through from Iran. |
| WireGuard tunnel | The traffic travels from the bridge to the panel inside a WireGuard tunnel. |
| AmneziaWG tunnel | The same inside an AmneziaWG tunnel, which filtering does not recognise even when clients use plain WireGuard. The panel’s server needs AmneziaWG installed. |
| TLS tunnel | UDP across the border is blocked or slow. The tunnel runs inside an ordinary-looking HTTPS connection over TCP, which is slower than the UDP tunnels. The bridge opens one such connection per CPU core, up to 4, and each client stays on one of them. |
The bridge sets the same kernel tuning as an exit: larger socket buffers, BBR with fq when the kernel has it, a connection table sized to the server’s RAM, and packet steering when the network card has fewer queues than cores. Each report says how full that table is and how many connections the kernel dropped. The panel alerts when a bridge, exit or fleet server is at least 80% full. If any base tuning key does not take (often on container-based VPSs), a warning is shown on the bridge row and in Settings → Network → Performance; when either this server or the bridge cannot raise the net.core socket buffers, TLS tunnel mode is refused with the reason shown.
Configs through a bridge use MTU 1200 at most, in every mode. The two UDP tunnels end on a UDP port of the panel’s server, from 52000 up, and AFTAB opens it in ufw or firewalld itself; a firewall of your provider still needs it opened. For the TLS tunnel open a TCP port instead: 443, or 8443 when the panel itself uses 443. AFTAB opens it there too, and you can set another one in the form.
For the two UDP tunnels you can switch on Move to TLS by itself when the tunnel stays down. After no handshake for 5 minutes the panel moves the bridge to TLS, tries your chosen mode again after an hour, and waits longer each time that fails. Clients import nothing again.
CDN, mirror and second uplink
Section titled “CDN, mirror and second uplink”- CDN name (optional): available only when How traffic crosses the border is TLS tunnel. Point a domain name at this server through Cloudflare with the proxy and WebSockets switched on and put that name here. The bridge connects to Cloudflare on TCP port 443 and asks for the name with an encrypted handshake (ECH) looked up over DNS over HTTPS. It carries tunnel traffic between servers only; some countries block encrypted handshakes, and Cloudflare may suspend an account used this way.
- Subscription page mirror: opens clients’ subscription pages through this bridge when the panel is blocked from Iran. Open Subscription page mirror, enter the Mirror name pointing at this bridge and the Port (port 443 by default). It works only over HTTPS with a valid subscription certificate covering that name (or a wildcard certificate), so links cannot be read on the way. A tunnel bridge reaches the subscription server on its link address, so let the subscription server listen on every address (
sub_listenin Settings → Panel). While the bridge is enabled and connected, the subscription page lists this mirror link, and anyone opening it reaches the panel as this bridge’s address. - Second uplink: sends everything this bridge talks to on the panel’s side (the panel itself and the tunnel endpoint) out through another line while clients still arrive on the main line. Under Second uplink give an Interface such as
eth1(notloor anaftabinterface) and/or an IPv4 Gateway such as192.168.1.1. Leave both empty to use the main line. If the panel cannot be reached through it 3 times in a row, the bridge switches back to the main line for 10 minutes.
Move the panel
Section titled “Move the panel”Bridges store the panel’s signing key and list of addresses (node_addresses). When you move the panel to another server, they reconnect by themselves once HTTPS is back up on the new server: see Moving to a new server.
What can go wrong
Section titled “What can go wrong”- It stays on “Waiting for install”. The command was not run, or the server cannot reach the panel. The installer then prints “The first contact with the panel failed” and keeps trying. On the Iranian server run
sudo /usr/local/lib/aftab-bridge/aftab-bridge status, or read the log withjournalctl -u aftab-bridge. - The bridge shows “Offline”. It stopped reporting. While it is away, new configs of its inbounds use the panel’s own address, and they use the bridge again when it returns.
- “Traffic on port N reaches the bridge but nothing comes back”. The clients’ packets arrive, and the panel’s side does not answer. Check that the panel’s server accepts UDP on that port and that the path from Iran is not blocked.
- A tunnel says “No handshake yet”. The tunnel port is closed on the panel’s server, UDP for the WireGuard and AmneziaWG tunnels and TCP for TLS, or the bridge’s program is old. A banner offers to move the bridges whose tunnel is down to TLS. If TLS does not get through either, try another TCP port, or a domain in the TLS handshake.
- “… for bridges is not available yet”. The panel hands bridges two outside programs,
amneziawg-goandwstunnel, and downloads each once from the project’s GitHub release. If the panel’s server cannot reach GitHub, copy the file there and runsudo aftab component add amneziawg-go FILE, or the same withwstunnel.
Remove or revoke a bridge
Section titled “Remove or revoke a bridge”Delete takes the bridge out of the panel. Its inbounds go back to the panel’s own address, and clients connecting through it lose their connection once the bridge is uninstalled. To remove the program by hand on the Iranian server run sudo /usr/local/lib/aftab-bridge/aftab-bridge uninstall.
Revoke is for a server that was lost or seized. Its token, its keys and its install command stop working at once, so a copy of them is useless. The bridge stops forwarding until you run the new install command on the server.