A 60MB travel router doesn't need xray — bare Shadowsocks with all-TCP DNS just works

My travel router is a LEDE 17.01 box (60MB RAM, MIPS) living behind the GFW. The "modern" stack — xray with DoH DNS and geoip routing, plus kcptun for UDP acceleration — ate ~45MB of RAM, lived on a USB stick, and kept zombifying after restarts. Meanwhile UDP on Chinese networks got worse every month: kcptun sessions died, UDP DNS relays never worked.

The fix was going backwards: bare shadowsocks-libev 3.2.1, global transparent proxy, DNS over TCP.

Global transparent proxy, no geoip — everything except private ranges rides the tunnel:

iptables -t nat -N SSRULE
for net in 0.0.0.0/8 10.0.0.0/8 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 \
           100.64.0.0/10 <server-ip>/32; do
  iptables -t nat -A SSRULE -d $net -j RETURN   # server-IP entry avoids a redirect loop
done
iptables -t nat -A SSRULE -p tcp -j REDIRECT --to-ports 12345
iptables -t nat -A PREROUTING -i br-lan -p tcp -j SSRULE
iptables -t nat -A OUTPUT -p tcp -j SSRULE

DNS without UDP relay is the clever bit. Unpoisoned DNS has to go through the tunnel, which normally means ss-tunnel's UDP relay — which silently fails on this MIPS box: it logs "listening" but no socket ever appears in netstat. Instead, OpenWrt's tiny dns-forwarder listens on UDP locally and queries upstream over TCP:

dns-forwarder -b 127.0.0.1 -p 1053 -s 8.8.8.8:53

dnsmasq forwards to 127.0.0.1#1053 as usual; the forwarder's TCP:53 packets hit the same REDIRECT rule and ride the tunnel. You get real answers — NXDOMAIN passes through untouched, something poisoned DNS never gives you. No UDP ever leaves the router.

Total cost: 490KB of binaries, embedded in internal flash (verified by unmounting the USB stick mid-run and pulling google in 1.3s), RAM down to 28MB, procd respawns everything if it dies, and boot just works.

Sometimes the modern stack is the problem, not the solution.

Comments

  1. Markdown is allowed. HTML tags allowed: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.