Note · 2026-11-29
Selling Wi-Fi from a phone
Two customer models for a phone-as-gate, what the exit daemon will actually admit, and the one platform fact that rules out the keyless variant. With eight diagrams. Written before the alphabet settled — see the note at the top.
On the letters. This note was written before the vocabulary settled, and it uses “Model A” and “Model B” for whether the customer holds a key. Those map onto the current alphabet as: Model A → A, Model B → C. The full definition is on The alphabet, settled, and the reason two sets of letters existed is on Same letters, different questions. The text below is left as written, because the argument does not depend on the labels.
A phone can’t run a captive portal. It has no nftables, no ARP table, no AP control. So if a phone is going to sell internet the way a TollGate router does, the gatekeeping has to happen somewhere else.
The proposal on the table was to use a FIPS exit node on the phone as the valve: customers connect to the phone’s hotspot, pay, and the exit opens or closes their access. Two variants were floated.
- Model A — the customer runs FIPS too, so they are a real mesh peer with their own
fd…address. - Model B — the customer has only a MAC address, and the phone derives something from it.
The answer turned out to be: partly out of scope, partly impossible, and the impossible part is not where anyone expected it. Two of my own earlier claims were too generous and are corrected below — marked Correction.
Correction: paying needs a portal, and a phone cannot be one
I wrote earlier that “scan a QR, paste a token” needs no app, and that a TollGate already accepts a raw Cashu token as text/plain to POST :2121/. Both are true of the router. They are not true of a phone, and the gap is the whole design.
A captive portal is an interception: to show a payment page, the seller must be the customer’s default gateway and must redirect the first HTTP/DNS request. On Android that is exactly the tethering→VpnService path the platform forbids (see below). So on a phone there is no portal to host. The payment has to happen outside the connection the customer has not yet paid for:
- a QR on the seller’s screen, scanned with the customer’s own cellular data;
- or a printed code / session URL.
That is the pay leg only. Paying can need no app; paying through a portal needs a router.
Correction: fips2go is a buyer, not a seller
I said Model A “works today, on a stock phone”. It does — but I described the wrong party as the seller. Reading v0.14.0:
- The phone runs a real node. The APK ships
lib/arm64-v8a/libfips_android.so, a pinnedfr34aky/fips@android-hooksbuild, inside aVpnService. - It refuses to be an exit itself.
shim/src/exit.rs:377:return Err("exit node npub: that is this phone's own npub".into()); - The exit half is a separate Linux Docker container (
exit-node/) that needsip6tnlper client, nftables, NAT and a rootful netns. - And it never starts a hotspot: no
startLocalOnlyHotspot, nostartTethering, noTetheringManager, noSoftApanywhere in the tree.
So the phone is the customer, and the seller is a box. “FIPS Hotspot” in the fips2go docs means the app joins an existing open SSID named !FIPS as a station — not that it creates one.
This is the finding that reorganises the whole design: the phone can buy, the phone cannot sell.
First, the thing that already works
Before any of the models: a TollGate already accepts a raw Cashu token as the body of POST :2121/, Content-Type: text/plain, and it derives the client’s identity from the socket — the mac parameter is ignored on every client-scoped route. So “scan a QR, paste a token” needs no app at all.
Read row four: reach the gate’s API is green for all four arrival classes. That is the whole point. Everything else in that table needs software the customer brought with them.
The caveat, which I did not know until I checked: a captive-portal page is plain HTTP, and plain HTTP is not a secure context. No crypto.subtle (it is undefined), no OPFS, no service workers. A wallet created inside the portal sheet is crippled. It has to exist beforehand, or live server-side per session.
Where the customer’s identity comes from
TollGate has no mDNS, no Zeroconf, no SSDP. Discovery is: captive portal → gateway IP → :2121. The project says this is deliberate — docs/architecture/discovery-signaling-decision.md:128 states that post-association broadcast “cannot answer a pre-association question.”
The pricing advert is a Nostr kind-10021 event, built in src/merchant/merchant.go:2237. One thing surprised me: it is never published to a relay. It exists only as the HTTP body of GET /. So no client can learn a gate’s prices without already being on its LAN. That is a small, fixable gap — the event is already signed, it is just never sent anywhere.
FIPS, by contrast, does have LAN discovery: _fips._udp.local. via mDNS/DNS-SD (docs/reference/configuration.md:457). But the advert carries only the npub as a hint — identity is proven by the Noise IK handshake, so a spoofed advert fails.
Model A: the customer runs FIPS
The exit daemon — fips-exitd, from fr34aky/fips-exit — has exactly one entrance. from_mesh() at src/main.rs:857 reads two raw sockets, protocol 4/41, bound to the mesh. And admits() at :597 does this:
fn admits(&self, proto: i32, src: &[u8; 16], inner: &[u8]) -> Verdict<()> {
let Some(client) = self.by_v6.get(src) else {
return Verdict::Refused;
};
by_v6 is keyed on 16-byte fd… addresses. Then, for IPv6, it requires inner[8..24] == src[..] — the packet’s inner source must be the outer source.
And that address is not something a client can claim. On the receive path the inner source is not read from the packet at all — it is reconstructed from the authenticated session:
// repos/fips-upstream/src/node/handlers/session.rs:678-687
Ipv6Address::from_node_addr(src_addr)
src_addr is “an envelope field the sender chooses” (session.rs:426-429), and FIPS routes it “which nothing binds to the peer that sent it” (core/src/proto/routing/core.rs:203-215) — but the handshake does bind it. A peer’s address claim is held as Bond::Claimed(addr) and accepted only if the completed Noise handshake’s static key derives to that same address:
// repos/fips-upstream/core/src/proto/rekey/proof.rs:72-93
Self::Claimed(addr) => done.remote.addr() == *addr,
And the address is derived from the key, so possessing the address means possessing the key:
node_addr = SHA-256(x-only pubkey)[0..16] core/src/identity/node_addr.rs:12-46
fd… = 0xfd || node_addr[0..15] core/src/identity/address.rs:38-43
That is why a MAC cannot be substituted for a key: it is not a name you can be given, it is a hash of a secret you must hold.
There is one interesting laxity. The control socket will accept an arbitrary fd… string as a member — address() only checks that it parses as an IPv6 literal starting 0xfd (src/main.rs:1260-1266), and member_list() only checks duplicates and MAX_MEMBERS = 32 (:1268-1286). So you can write a non-existent address into a member list. It is useless: admission is keyed on the outer source of an authenticated mesh packet, and no one can produce one for an address whose key they do not have.
So admission is by address, and the address is proved by the mesh session. No login, no token for identity. A device with no key cannot pass, and no change to the daemon would let it: the daemon has no MAC concept at all.
Model A works, today, on a stock phone. Not through routing — through discovery. A device tethered to the phone’s own hotspot that runs fips is found over the hotspot’s LAN by mDNS and linked directly. From fips2go’s own docs:
“It also works the other way round: a device tethered to this phone’s own hotspot that runs fips is found and linked over the hotspot LAN, with nothing to set up — which is how tethered devices get the mesh.”
And it is device-verified: “device-verified on 0.6.0, underlay cellular, a laptop running fips on the hotspot was discovered and linked.”
The customer’s packet already arrives with its own fd… address as the source, so the daemon’s rule holds unchanged. No MAC anywhere.
Model B: the customer has only a MAC
Two designs were proposed.
Option 1, a hotspot-side valve. The phone is an ordinary NAT with a byte budget per client. The valve reads the lease table, counts bytes per MAC, and drops the client when the budget runs out. No FIPS at all.
Option 2, a relay. The relay terminates the customer’s traffic and re-originates it under its own mesh identity. The mesh sees the relay; the customer is invisible. Metering happens at the relay, per customer. The cost is that the relay becomes a trusted party — it sees plaintext if it terminates TCP, and it holds the money and the identity.
What would have to change in the daemon: a second entrance (a whole new read loop), a different identity keyed on (peer IP, MAC) — which loses the anti-spoof guarantee, since a NATed client’s inner address is never its outer one — and a ledger that survives Android killing the process, because accounts are memory-only.
But after changes one and two, what is left of fips-exitd is “read a packet, look up a payer, count bytes, stop at the budget”. That is a hotspot NAT with a byte counter. Model B is not a patch to this daemon; it is a smaller, different component.
The experiment: is Model B ruled out by Android?
I said the real blocker might not be the daemon but the platform. So I tried to measure it.
What I could not do. I booted an Android 14 (SDK 34) AOSP emulator with KVM. It has hwsim (a virtual Wi-Fi device) and a tethering service. But cmd wifi start-softap returned state: 11 — SAP disabled — because there is only one virtual radio. I could not produce a second device on a hotspot, so I could not test end-to-end. That is a limitation of the emulator, not evidence about real phones.
What I could do, and did. Read the AOSP source that implements tethering. That is more definitive than a single emulator run, because it shows what any app can and cannot reach.
Do tethered client MACs exist in the system?
Yes. Tethering/src/android/net/ip/IpServer.java:589-603 builds them:
final MacAddress macAddress = MacAddress.fromBytes(lease.hwAddr);
leases.add(new TetheredClient(macAddress, Collections.singletonList(addressInfo), mInterfaceType));
The DHCP lease carries hwAddr, and it becomes a TetheredClient with a full MacAddress.
Can a normal app read them?
No. The API that delivers this list is TetheringEventCallback.onClientsChanged(Collection<TetheredClient>) in Tethering/common/TetheringLib/src/android/net/TetheringManager.java:1755:
@SystemApi
default void onClientsChanged(@NonNull Collection<TetheredClient> clients) {}
@SystemApi means it is stripped from the public SDK. An ordinary app cannot compile against it, and reflection is blocked by the hidden-API greylist. Even a system-privileged app needs the TETHERING_PRIVILEGED permission.
And the AOSP javadoc — written by the people who own the code — says this about the data itself:
“This callback provides best-effort information on connected clients based on state known to the system, however the list cannot be completely accurate (and should not be used for security purposes). For example, clients behind a bridge and using static IP assignments are not visible to the tethering device; or even when using DHCP, such clients may still be reported by this callback after disconnection as the system cannot determine if they are still connected.”
That is the framework’s own verdict on using this list to decide who gets access.
And the traffic itself?
The figure is the whole argument, and it is worth walking through, because it explains why no app can fix this.
Read the top row first. The packet arrives from a customer on the hotspot with iif = ap0 — it entered on the hotspot interface. And it has no uid: the kernel is forwarding it, not generating it on behalf of an app.
Now the rules, in priority order. netd picks one rule by priority:
- 21000 —
RULE_PRIORITY_TETHERING. Matches oniif = ap0, points at table 1002, the uplink. - 24000 —
RULE_PRIORITY_VPN_OUTPUT_TO_LOCAL. Matches on a uid range plusiif lo, points attun0. - 25000 —
RULE_PRIORITY_VPN_OVERRIDE_SYSTEM. Same shape, uid plusiif lo.
Two independent reasons the packet goes to the uplink, and either alone is enough:
- It matches 21000 first, so no VPN rule is ever reached.
- Even if it did reach them, a VPN rule requires
iif = loand a uid it can name. This packet hasiif = ap0and belongs to no uid — it cannot match.
The two lower cards in the figure are the same decision made twice more, so this is not a single leaky rule:
TetherControlleronly ever installsMASQUERADE intIface → extIface, neverintIface → tun0.UpstreamNetworkMonitorselects a tethering upstream only from networks that haveNET_CAPABILITY_NOT_VPN. A VPN is excluded from being an upstream by construction.
That is why “routing around the VPN” is not an Android quirk — it is how the rule table is shaped, and a VpnService tunnel was always a policy on locally originated traffic. Forwarded traffic is the normal case; the VPN is the exception.
And the bottom row is the practical answer: on a stock phone the working paths are none. Root/Shizuku works by exploiting the 20500–20900 gap below 21000. The “Allow clients to use VPN” toggle is a downstream OEM patch, absent on AOSP. Both require a device you do not control.
Google closed the exact request — issuetracker 472139317, “Route tethered/hotspot traffic via system default route when VPN is active” — as Infeasible, noting that root/ROMs prove it is technically possible but that it will not be supported.
The working non-root path: none. The working root paths: Mygod/VPNHotspot (which exploits the 20500–20900 rule gap) and magisk-vpn-tether. The “Allow clients to use VPN” toggle some people remember is a downstream OEM patch (TETHERING_ALLOW_VPN_UPSTREAMS) on LineageOS/Samsung/Calyx — absent on Pixel, AOSP and GrapheneOS. So a phone that offers it is the exception, and you cannot ship against it.
fips2go’s docs/features.md says the same from the app side:
“Android gives an app no way to route a tethered client’s traffic into the tunnel: the kernel forwards it, no app owns it, and tethering never uses a VPN as its upstream.”
Can the app at least start the hotspot?
No. startLocalOnlyHotspot gives no internet by design and dies with the requesting process (ERROR_INCOMPATIBLE_MODE unless foreground, killed on requestor death). TetheringManager.startTethering requires TETHER_PRIVILEGED, a signature|privileged permission. setWifiApEnabled is @hide and removed. There is no non-privileged way to turn a phone into a hotspot programmatically.
iOS is worse. Apple DTS is explicit on the same question:
“you are connecting via a personal hotspot interface… and are not able to reach the tun1 interface directly” — and “An iPhone is not meant to be used as a Proxy Server.”
There is no API to even enable Personal Hotspot. NEHotspotConfiguration only joins networks; NEHotspotHelper is join-side captive-portal auth behind an Apple-granted entitlement.
So: is Model B ruled out?
| Environment | Verdict |
|---|---|
| Stock, non-rooted phone | Ruled out. No metering path, no client list, no trusted identity. |
| Rooted or Shizuku-granted phone | Buildable — the traffic can be redirected, and the lease file becomes readable. |
| A device that owns its forwarding path (router-class) | Buildable — this is what fips-exitd was written for. |
The blocker is neither the daemon nor an API gap that better code would close. It is that Android does not let an app own forwarded traffic — Google has ruled this out as Infeasible — and the one list that names the clients is a system API the framework itself says is unfit for security decisions.
There is a second, independent reason, and it survives the first one being “fixed” by root. MACs are the wrong identifier. Android 10+ randomises the MAC per SSID, and iOS uses a Private Wi-Fi Address by default, so the same customer presents a new MAC on reconnect. A design that keys access on a MAC hands out a fresh identity every time the customer rejoins — which is why the “small frequent payments, top up rather than hold a balance” instinct was right, but for a reason that makes the identifier useless as an account key rather than merely weak.
The two payment ideas that came up
Mining for access. A mid-range phone does roughly 1 MH/s on SHA-256d. Network value per hash is about 4.2e-24 BTC, so a phone produces ~0.0015 sat per hour of full-tilt hashing. A 1,000-sat day pass is about 76 years of continuous phone mining. Verification is nearly free, which is the trap, not the fix: because work is fungible, a reseller with rented hashpower (~€0.02/TH/day) mints your entire inventory for fractions of a cent and undercuts you. And the literature settled this — Hashcash is a denial-of-service counter-measure, not money, and NIP-13 devotes a section to Delegated Proof of Work, i.e. a third party mining for you. A payment rail whose payer can outsource to someone cheaper is not a payment rail. Where PoW does belong: ~18–22 bits before issuing a session, as an anti-abuse throttle.
Deriving a secret from the MAC. A Cashu proof is a bearer instrument: whoever knows secret can spend it. A MAC is broadcast in cleartext in every 802.11 frame, so deriving the spend key from it publishes that key to the whole room — and the gate knows the MAC too, so the gate can spend it. Entropy is 48 bits, 24 of which are a public vendor OUI, so 2^24 is milliseconds; NUT-13 needs 128. It also cannot become a wallet: one secret per MAC means no change outputs, no splits, no reissue. Not weak — unsafe.
What I would build
The experiments changed this. The minimum shippable architecture is three tiers, not two, and the phone is at the bottom of it:
customer seller upstream
──────── ────── ────────
pay: QR / browser ──► OpenWrt / Linux box ──► paid FIPS exit
route: fips2go ──► + gateway + meter (or internet)
the phone: ordinary hotspot + uplink. Not the gate.
- The QR + Cashu-token pay leg is the no-prerequisite answer — but it needs something other than a phone to serve the portal. A router already does.
- Publish the kind-10021 advert to relays. It is built and signed and never sent. That is the difference between “a gate you must already be inside” and “a gate you can find.”
- For routed access, require FIPS — and put the gate on the box. Model A works, but the seller must be a device that owns its kernel. The customer installs fips2go; the seller runs
fips-exitdandfips-gateway. The hard part is distribution, not engineering: Android can sideload from a portal, iOS cannot. - If the seller genuinely wants to be a phone, then the product is not “a gate on a phone” — it is “a phone that pays a gate.” That is a real product, and fips2go already is it.
The uncomfortable finding is that the two halves of the original idea pull in opposite directions: the valve needs to own the packets, and a phone app is precisely the thing every mobile OS forbids from owning them. The way out is not to fight that — it is to accept the phone can buy, and only a box can sell.
The one that got routed around the VPN
I was reminded, correctly, that a GrapheneOS developer has said traffic from the phone’s access point is routed around the VPN on Android — so it cannot be intercepted.
That is not an Android quirk. It is how every OS kernel network stack works. A VpnService tunnel is a policy applied to locally originated traffic (by UID, by destination prefix). Forwarded traffic has no originating UID — it is a packet the kernel routes from wlan0 to the upstream interface. There is nothing for the policy to match. “Routing around the VPN” is the normal case; the VPN is the special case.
So yes: a phone-side VPN cannot meter hotspot customers, and this affects every app equally. Not just fips-exitd. Not just fips2go. Also Myco — whatever its own gate logic is, it cannot see forwarded packets from a locked, non-rooted phone, for exactly the same reason.
The distinction worth keeping clear:
| Thing | Can it work on a stock phone? |
|---|---|
| A phone app metering hotspot customers | No. No UID, no policy match, for any app. |
| A phone app metering its own traffic | Yes — that is what VpnService is for. |
| A phone discovering peers on its hotspot’s LAN | Yes — mDNS, and it needs no traffic interception at all. |
That third row is why Model A survives and Model B does not. Model A never asks anyone to intercept a packet.
What about fips-gateway? FIPS already has a relay.
This was the most useful correction. FIPS ships a gateway mode that does exactly what the “relay” option described — official, not invented here:
“Outbound gateway (LAN → mesh). Non-FIPS LAN workstations resolve
<npub>.fipsnames against the gateway’s DNS listener and receive AAAA answers from the gateway’s virtual-IP pool. Outbound traffic to those addresses is DNAT’d to the real mesh address and SNAT’d (masqueraded) ontofips0under the gateway’s mesh identity. The audience is unmodified LAN clients.” —docs/how-to/deploy-gateway.md
So the mesh sees the gateway, and the LAN client needs nothing installed. That is Model B’s Option 2, already built and documented.
But look at what it needs:
docs/design/fips-gateway.md:69-70
It needs CAP_NET_ADMIN to install nftables rules, manage proxy NDP
entries, and add the pool route.
CAP_NET_ADMIN plus nftables plus proxy NDP. On Android that is root, full stop. So fips-gateway is the right component for the job — and it cannot run inside a normal app either.
Where it does fit: the seller’s box. An OpenWrt router, a Linux host, a small ARM board — the canonical deployment is OpenWrt, where the ipk ships the gateway: block pre-populated and the init script wires dnsmasq forwarding and RA route distribution. A device that owns its kernel can run fips-gateway and fips-exitd and a byte meter. A phone does not.
Questions for fr34aky
These came out of reading the code, and I would rather ask than assume. Some have changed since the experiments — I have marked where an earlier framing turned out to be wrong.
Is
fips2godeliberately buy-only, and is that a permanent boundary?shim/src/exit.rs:377refuses with “exit node npub: that is this phone’s own npub”, andexit-node/is a Linux container needingip6tnl, nftables and a rootful netns. I read that as a considered decision rather than an unfinished corner. Was there aVpnService-fd path you tried and abandoned, or is a phone simply never the seller in your model?fips-gatewayas the keyless path. It masquerades LAN clients ontofips0under the gateway’s own identity, and the design doc says plainly “There is no per-client authentication; access restriction is a network-level concern.” Is that the intended way to sell access to clients without FIPS — gateway account pays, per-customer accounting is the LAN owner’s problem? And isCAP_NET_ADMINgenuinely unavoidable, or is there a userspace mode I missed?Where should per-customer metering live? Given (2), the exit cannot distinguish two customers behind one gateway — the masquerade makes them identical, and that is by design. So either the meter is at the gateway, or there is a per-member idea the exit was supposed to enforce that the masquerade forecloses. Which do you intend?
Hotspot discovery in fips2go, for the customer side. The README says a tethered device running fips is found over the hotspot LAN by mDNS and that it was device-verified on 0.6.0. Does that work when the phone’s uplink is cellular only, and does it survive the app being backgrounded? We would be relying on exactly this for the customer’s first contact.
Distribution. For a customer to be routed they must run fips, and on iOS there is no sideloading path from a captive portal — and no portal at all if the seller is a phone. Do you see iOS as app-store-only indefinitely, or is there a TestFlight/enterprise route you would consider for a venue deployment?
The advert.
fips-exitpublishes its kind-30078 advert with a 3-hour TTL, republished hourly. TollGate builds a kind-10021 advert and never publishes it. Would you want TollGate-gated exits announcing through your relay list, and would “behind a TollGate gate” be anaccessword distinct frompaid? Your note that a TollGate-gated exit must not saypaidis the thing I want to get right — otherwise fips2go buyers land on a shop that is not there.Accounts are memory-only, and Android has no systemd. On Linux, a restart is recovered within ~2 s by payd’s epoch-diff re-
put. On a phone there is no restart policy, no/run, and Doze reaps both processes. If the seller is always a box, this is moot — but if you have ever considered the phone as a seller, what is your answer to a customer whose access silently stops? I would want a persisted snapshot and a visible “tunnel down” signal, not silent fail-closed.The daemon’s one-dependency rule. If the per-customer meter belongs at the gateway rather than the exit, is that a split you want held even when both run on the same box — “the gate decides, the exit applies” — or is co-location permission to let the exit know about money?