A 64 MB travel router that gets through the GFW: sing-box, a Cloudflare tunnel, and one pinned IP
I travel to China with a TP-Link WR703N in my bag. It is a matchbox-sized router running LEDE 17.01, with a 400 MHz single-core MIPS CPU, about 60 MB of usable RAM, one Ethernet port and one 2.4 GHz radio. Everything on its Wi-Fi gets through the firewall: laptop, phone, tablet. No device needs a client app.
The hardware is an absurd place to run a modern proxy. Getting it to work well took most of a week. The final design is simple. The parts that made the difference were not the parts I expected.
The shape of it
LAN client
-> iptables REDIRECT (all LAN TCP, except private ranges)
-> redsocks 192.168.1.1:12346
-> sing-box SOCKS 127.0.0.1:11081
-> VLESS over WebSocket + TLS, h2mux
-> Cloudflare edge (a pinned Hong Kong IP)
-> cloudflared tunnel
-> sing-box on a small VPS, listening on 127.0.0.1 only
-> the internet
The VPS has no open proxy port. cloudflared dials out to Cloudflare, and Cloudflare forwards the WebSocket to sing-box on localhost. Days before this trip, the IP of another VPS I own was blocked. With this setup a blocked origin IP does not matter, because the client never connects to it. The client only ever sees Cloudflare.
The router side
The core is a minimal sing-box 1.14 build for soft-float MIPS, with no build tags. It runs from a USB stick (ext4 plus 128 MB swap). I started with Xray and ran both cores side by side on the router with identical probes. sing-box peaked at 23 MiB RSS against Xray's 27 MiB, and finished four parallel 1 MB downloads in 11–12 s against Xray's 15 s. Xray stays on the stick as a standby; one file tells the supervisor which core to start.
The client config is short:
{
"inbounds": [
{"type": "socks", "listen": "127.0.0.1", "listen_port": 11081},
{"type": "http", "listen": "127.0.0.1", "listen_port": 10822},
{"type": "direct", "tag": "dns-in", "listen": "127.0.0.1", "listen_port": 5353,
"override_address": "1.1.1.1", "override_port": 53}
],
"outbounds": [{
"type": "vless", "server": "104.26.1.1", "server_port": 443, "uuid": "<uuid>",
"tls": {"enabled": true, "server_name": "tunnel.example.org"},
"transport": {"type": "ws", "path": "/<secret-path>", "headers": {"Host": "tunnel.example.org"}},
"multiplex": {"enabled": true, "protocol": "h2mux", "max_connections": 1, "min_streams": 4}
}],
"route": {"final": "proxy"}
}
Two lines in it carry most of the weight.
The server is a hard-coded Cloudflare IP, not the hostname. That matters more than anything else in this post, and I explain it below.
multiplex must be on. With mux off, every request opens its own WebSocket. When the server closes one, a single-core CPU sometimes loses the race between the close and the last response bytes, and those bytes are dropped. The router's health check failed 6 to 17 times out of 20. Each failure put LAN DNS back on the poisoned local resolver, so browsers showed "server not found". I reproduced it on a laptop by pinning Go to one core (GOMAXPROCS=1). With mux on, 20 of 20 probes passed.
Traffic gets in through a small iptables chain. Private ranges are skipped, all other LAN TCP is redirected to redsocks, and outbound UDP 443 is rejected so browsers drop QUIC and fall back to TCP:
iptables -t nat -N LEDE_REALITY
for subnet in 0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 127.0.0.0/8 \
169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 224.0.0.0/4 240.0.0.0/4; do
iptables -t nat -A LEDE_REALITY -d "$subnet" -j RETURN
done
iptables -t nat -A LEDE_REALITY -p tcp -j REDIRECT --to-ports 12346
iptables -I FORWARD -i br-lan -p udp --dport 443 -j REJECT
iptables -t nat -I PREROUTING -i br-lan -j LEDE_REALITY
A supervisor loop keeps this honest. It probes generate_204 through the core's HTTP port, and it installs the chain only after a probe succeeds. After three misses in a row it removes the chain again, so the router degrades to a plain, unproxied router instead of a dead one.
DNS: remote, with a short domestic list
China's resolvers lie about blocked names, and you can't argue your way around that. sing-box 1.13 also removed SNI-based destination override, so a poisoned IP will be dialled exactly as given. Remote DNS is therefore the first thing that has to work.
When the proxy is armed, dnsmasq sends every query through the tunnel. The exception is a short list of domestic names, which stay on the local resolver so Baidu and Taobao still get nearby CDN nodes. dnsmasq runs with noresolv and a serversfile that the supervisor owns:
server=127.0.0.1#5353
server=/cn/baidu.com/qq.com/taobao.com/alicdn.com/apple.com/.../<uplink-dns>
Port 5353 is the dns-in inbound above. It forwards to 1.1.1.1:53 through the tunnel. When the supervisor disarms, it rewrites the file to the uplink resolvers and sends dnsmasq a SIGHUP, which re-reads the file and flushes the cache in one step.
Two traps cost me an hour each. First, dnsmasq runs as the dnsmasq user, so a file written under umask 077 is silently unreadable to it. Second, an empty resolv-file doesn't clear dnsmasq's upstreams; it keeps the old ones. That's why the design uses noresolv plus a servers-file rather than swapping resolv-files.
The part that mattered: which Cloudflare colo you land in
With all of that in place, the proxy worked in the morning and fell apart in the evening. Google's generate_204 timed out, downloads crawled at 10 KB/s, and the health check flapped. It was natural to suspect the GFW had fingerprinted the traffic.
To check, I ran each comparison from the same laptop, on the same broadband, minutes apart:
- A plain HTTPS download from Cloudflare, using the same IP the tunnel was using, ran at ~700 KB/s.
- The tunnel through the router managed 9–23 KB/s.
- The same tunnel config, run from the VPS outside China, ran at 5–30 MB/s, so the origin and
cloudflaredwere fine. - A plain, non-proxied
curl https://tunnel.example.org/cdn-cgi/tracetook 7–12 seconds or timed out. The trace saidcolo=LAX.
The last result settled it. Even without a proxy, the hostname barely responded. The problem was the path: China Unicom's international link to Cloudflare's Los Angeles colo was losing packets badly at peak hours. A single bulk download can survive that. A proxy carrying dozens of small, latency-sensitive connections cannot.
Which colo a China client reaches depends on which Cloudflare IP it connects to, and the IPs your DNS returns are not the only ones that work. Any Cloudflare anycast IP will serve your zone if you send the right SNI and Host. So I scanned:
for ip in 104.16.1.1 104.17.1.1 ... 104.26.1.1 ... 172.67.1.1 162.159.1.1 188.114.96.1; do
for k in 1 2 3; do
curl -4 -s -m 6 --resolve tunnel.example.org:443:$ip \
-w " T=%{time_total}" https://tunnel.example.org/cdn-cgi/trace
done # count successes, record colo= and total time
done
Most of the 24 IPs landed in LAX and answered 0–2 of 3 attempts. 104.26.1.1 landed in HKG and answered 3/3, at about 0.7 s each. I put that IP in the outbound's server, kept the real hostname in the TLS server_name and the WebSocket Host header, and the evening numbers changed. With the final stack, 20 parallel probes complete in about 2 s, and four parallel 1 MB downloads take about 5 s. In practice that is fast enough to forget the router is there.
The scan takes three minutes. If HKG degrades one day, I'll run it again.
Things that didn't work, briefly
- A Tailscale exit node on the router. From China the userspace
tailscaledcould only use DERP relays: GitHub took 10–14 seconds, and running it alongside the proxy pushed 60 MB of RAM into swap thrash. I removed it. - KCP transport. It passed short tests, then timed out under sustained use on both the router and a laptop.
- REALITY + Vision straight to the VPS. The protocol is good, but the path to a Sydney VPS at peak hours ran at 1–2.5 KB/s. It also puts the VPS IP on the wire for the firewall to block.
- Turning mux off. I briefly turned it off, because on the lossy LAX path one multiplexed connection seemed to stall everything. Once the colo was fixed, the single-core race described above was the real problem, and mux went back on.
- Xray's
chromeuTLS fingerprint. It offers a post-quantum ML-KEM key share, and computing it on this CPU took 10–20 seconds per handshake. - Preferring IPv6 to Cloudflare. The ISP's IPv6 was four times faster to Cloudflare, until the modem rebooted, got a new prefix and then lost IPv6 entirely. A pinned IPv4 address to the right colo beat it anyway.
Small things that will bite you on hardware like this
- One radio cannot be a reliable Wi-Fi client and an access point at once. Each time the upstream Wi-Fi dropped (a phone hotspot in another room), the router's own AP went down with it. Use the Ethernet port for the uplink when you can.
- dnsmasq skips LAN DHCP when
br-lanhas no carrier at the moment it starts, and nothing re-runs that check. On a single-radio router that happens during Wi-Fi reconnects.uci set dhcp.lan.force=1fixes it. syncafter every write to the USB stick. A power-cycle left the proxy config at zero bytes. The supervisor now keeps a known-good copy and restores it when the live file is empty.