captive portal: never forward any record type for probe hosts

`address=` only synthesizes A/AAAA answers.  iOS also asks for the HTTPS
record type; dnsmasq forwarded that upstream, Apple's answer aliased to
captive.g.aaplimg.com, and the phone fetched the genuine "Success" from
Apple instead of the portal.  Each probe host now also gets `local=`, so
dnsmasq answers every type itself, and the CDN alias is a probe host too.

Observed with dnsmasq query logging on a hotspot with an eth0 uplink.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-09-13 19:42:22 -06:00
parent 85c27b91df
commit 66151df6c6
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 15 additions and 2 deletions

View file

@ -16,6 +16,7 @@ logger = logging.getLogger(__name__)
# wildcard would break the hotspot's forwarding of everything else to the WROLPi's uplink.
PROBE_HOSTS = (
'captive.apple.com', # iOS / macOS
'captive.g.aaplimg.com', # the CDN name captive.apple.com aliases to
'connectivitycheck.gstatic.com', # Android
'connectivitycheck.android.com', # Android (older)
'www.msftconnecttest.com', # Windows 10+
@ -88,8 +89,11 @@ def render_dnsmasq_config(ip: str) -> str:
'# Captive portal: captive-portal probe hostnames resolve to this WROLPi.',
'# Only these names are hijacked so the hotspot still forwards everything else.',
]
lines.extend(f'address=/{host}/{ip}' for host in PROBE_HOSTS)
lines.append(f'address=/{FRIENDLY_NAME}/{ip}')
for host in (*PROBE_HOSTS, FRIENDLY_NAME):
# `address=` only answers A/AAAA. Phones also ask for the HTTPS record type, and a
# forwarded answer leads them to the real host; `local=` never forwards any type.
lines.append(f'local=/{host}/')
lines.append(f'address=/{host}/{ip}')
return '\n'.join(lines) + '\n'

View file

@ -41,6 +41,15 @@ class TestRenderDnsmasqConfig:
assert f'address=/{host}/10.42.0.1' in config
assert f'address=/{FRIENDLY_NAME}/10.42.0.1' in config
def test_probe_hosts_are_never_forwarded(self):
"""iOS asks for the HTTPS record type too; a forwarded answer leads it to the real Apple."""
config = render_dnsmasq_config('10.42.0.1')
for host in (*PROBE_HOSTS, FRIENDLY_NAME):
assert f'local=/{host}/' in config
def test_apple_cdn_alias_is_a_probe_host(self):
assert 'captive.g.aaplimg.com' in PROBE_HOSTS
def test_no_wildcard(self):
"""A wildcard would break the hotspot's Internet passthrough."""
assert '/#/' not in render_dnsmasq_config('10.42.0.1')