Skip to main content

Come Costruire un Captive Portal: Una Guida per Sviluppatori

Una guida tecnica definitiva per architetti IT e gestori di rete sulla costruzione e l'implementazione di captive portal. Questa guida copre i protocolli sottostanti, i flussi di autenticazione, le architetture open-source e un framework per decidere quando costruire rispetto a quando acquistare una piattaforma gestita di livello enterprise.

📖 6 min di lettura📝 1,311 parole🔧 2 esempi3 domande📚 8 termini chiave

🎧 Ascolta questa guida

Visualizza trascrizione
How to Build a Captive Portal: A Developer's Guide A Purple WiFi Intelligence Podcast — Approximately 10 Minutes [INTRODUCTION & CONTEXT — 1 minute] Welcome back. I'm speaking today as a senior solutions architect, and if you're listening to this, you're probably staring down a requirement to deploy guest WiFi at scale — a hotel group, a retail estate, a stadium, or perhaps a public-sector network — and someone has asked you: can we build this ourselves, or do we buy a platform? That's exactly the question we're going to answer today. We'll cover what a captive portal actually does under the hood, walk through the open-source options available to you right now, explain the authentication flows and API integration patterns you need to understand, and give you a clear framework for deciding when to build versus when to buy. By the end of this, you'll have enough to brief your team and make a defensible decision this quarter. Let's get into it. [TECHNICAL DEEP-DIVE — 5 minutes] First, the fundamentals. A captive portal is a network access control mechanism that intercepts unauthenticated HTTP or HTTPS traffic from a connected device and redirects it to a web-based authentication page — what most users know as the WiFi login splash screen. The underlying mechanics rely on a combination of DNS hijacking, HTTP 302 redirects, and firewall rules that block all outbound traffic until the authentication handshake completes. When a device connects to your SSID, it typically sends an HTTP probe request — a lightweight check to see whether the network is open or gated. Your access point or gateway intercepts that probe and returns a redirect to your splash page URL. The user completes whatever authentication method you've configured — email capture, social login, SMS OTP, or a voucher code — and your portal then signals the network controller to open the firewall rule for that device's MAC address or IP. That's the core loop. Now, the standards that govern this are worth knowing. The IEEE 802.11 standard covers the wireless layer, but the captive portal detection and redirection behaviour is largely governed by RFC 7710 and the CAPPORT working group's RFC 8908 and RFC 8910, which define the Captive Portal API — a structured, machine-readable way for devices to discover and interact with captive portals. If you're building from scratch in 2024, you should be implementing the CAPPORT API rather than relying purely on legacy HTTP redirect tricks, because modern iOS and Android devices handle it more gracefully and you'll see fewer authentication failures. On the authentication side, you have several patterns to choose from. The simplest is a click-through or terms-of-service acceptance — no credentials required, just a button press. This is compliant with basic regulatory requirements in many jurisdictions but gives you no guest identity data. One step up is email gating — the guest enters their email address, you validate it optionally via a confirmation link, and you capture a marketing consent record. This is where GDPR becomes directly relevant: you need a lawful basis for processing that data, a clear consent mechanism, and a documented retention policy. If you're operating in the UK or EU, this is non-negotiable. For higher-security environments — corporate guest networks, healthcare facilities, or any deployment that touches PCI DSS scope — you'll want IEEE 802.1X port-based authentication with a RADIUS back-end. The flow here is: device associates with the SSID, the access point acts as a RADIUS client and forwards the authentication request to your RADIUS server — FreeRADIUS is the most widely deployed open-source option — the RADIUS server validates credentials against your directory, and returns an Access-Accept or Access-Reject. You can layer EAP methods on top of this: EAP-TLS for certificate-based auth, PEAP for username and password with a server-side certificate. WPA3-Enterprise with 192-bit mode is the current gold standard for high-security deployments. Now, let's talk about the open-source landscape, because there are real options here. pfSense with its built-in captive portal module is a solid starting point for single-site deployments — it handles RADIUS integration, per-user bandwidth throttling, and basic session management. OpenWRT with Nodogsplash is lightweight and works well on embedded hardware, but it has limited social authentication support and minimal GDPR tooling. Coova-Chilli is a more mature option — it implements the WISPr protocol, supports RADIUS, and can be extended with plugins for social login. PacketFence is the most feature-complete open-source network access control platform — it handles 802.1X, social auth, and has reasonable compliance tooling, though the operational overhead is significant. The honest assessment: open-source captive portal software gives you the authentication plumbing, but it leaves you to build everything else — the splash page UI, the data capture forms, the consent management, the analytics pipeline, the CRM integrations, and the ongoing compliance posture. For a single venue with a small IT team, that's a manageable project. For a 50-site retail estate or a hotel group with 200 properties, the total cost of ownership of a self-built stack almost always exceeds a managed platform within 18 months. That's where platforms like Purple come in. Purple's guest WiFi platform sits on top of your existing network infrastructure — it's hardware-agnostic, so it works with Cisco Meraki, Aruba, Ruckus, Ubiquiti, and most enterprise access point vendors. It handles the splash page, the authentication flows, the consent management, the data capture, and then feeds that data into a WiFi analytics layer that gives you footfall heatmaps, dwell time analysis, repeat visitor rates, and direct integrations with marketing automation platforms. For a hospitality operator, that means connecting guest WiFi data to your PMS and CRM. For a retailer, it means correlating footfall data with sales transactions. [IMPLEMENTATION RECOMMENDATIONS & PITFALLS — 2 minutes] Let me give you the implementation framework I use when advising clients on this decision. Start with your compliance requirements. If you're in scope for PCI DSS — and any venue that processes card payments on the same network as guest WiFi potentially is — you need network segmentation as a baseline, and your captive portal needs to sit on an isolated VLAN. GDPR compliance requires consent records with timestamps, a clear privacy notice linked from the splash page, and a documented data retention schedule. Don't bolt these on after the fact. Second, think about your authentication method relative to your audience. A stadium with 60,000 concurrent connections needs a lightweight click-through or social login — anything that adds friction at that scale will result in support calls and abandoned connections. A conference centre with 500 delegates who need to be individually tracked for compliance purposes needs email gating with verification. A hospital guest network needs 802.1X with certificate-based auth and strict VLAN segmentation from clinical systems. Third, plan your API integration points before you write a line of code. If you're building custom, define your webhook endpoints for authentication events, your data schema for guest records, and your integration contracts with downstream systems — CRM, marketing automation, analytics — before you start on the portal UI. Retrofitting integrations is where self-build projects typically go over budget. The most common failure modes I see: DNS rebinding attacks on poorly configured portals — always validate redirect URLs server-side. MAC address spoofing — don't rely on MAC as your sole session identifier. HTTPS interception issues — modern browsers and apps increasingly refuse to follow captive portal redirects on HTTPS connections, which is why implementing the CAPPORT API is important. And finally, bandwidth management — if you don't implement per-device rate limiting, a single guest running a software update can degrade the experience for everyone else on the network. [RAPID-FIRE Q&A — 1 minute] Can I use a Raspberry Pi as a captive portal gateway? Yes, with OpenWRT or Coova-Chilli for a single small venue — but don't put it in production at scale. Do I need a RADIUS server for social login? No — social OAuth flows bypass RADIUS entirely. You need RADIUS for 802.1X certificate or credential-based authentication. Is WPA3 mandatory for new deployments? Not legally mandatory, but it should be your default for any new infrastructure procurement. WPA2 is still widely supported but has known vulnerabilities. How do I handle Apple's Captive Network Assistant? Implement the CAPPORT API and ensure your splash page loads cleanly within the CNA browser window — avoid JavaScript redirects that the CNA can't follow. [SUMMARY & NEXT STEPS — 1 minute] To summarise: building a captive portal from scratch is entirely feasible with open-source tools like pfSense, Coova-Chilli, or PacketFence — but the build cost is only part of the equation. The ongoing cost of maintaining compliance, integrating with marketing systems, and scaling across multiple sites is where self-build projects typically struggle. For most enterprise venue operators, the right answer is a managed platform that handles the authentication plumbing, the compliance layer, and the analytics pipeline — and exposes a clean API for custom integrations where you need them. If you want to go deeper on the technical architecture, there's a full written guide linked in the show notes — it covers the CAPPORT API implementation, RADIUS configuration, and GDPR consent flow in detail. And if you're evaluating Purple's platform, the guest WiFi and analytics documentation is a good starting point for understanding what the integration looks like in practice. Thanks for listening. Until next time.

header_image.png

Riepilogo Esecutivo

Per gli architetti di rete aziendali e i direttori IT, l'implementazione di un captive portal è raramente solo un esercizio di networking: è un'intersezione critica tra sicurezza di rete, conformità normativa e business intelligence. Che tu stia gestendo un portfolio Hospitality di 200 proprietà, una vasta proprietà Retail o uno stadio ad alta densità, la decisione di costruire un captive portal personalizzato o di implementare una piattaforma gestita ha profonde implicazioni per il costo totale di proprietà (TCO) e il rischio operativo.

Questa guida fornisce un'analisi tecnica approfondita e neutrale rispetto ai fornitori sull'architettura dei captive portal. Esploreremo i meccanismi sottostanti di reindirizzamento HTTP, la moderna Captive Portal API (RFC 8908), i flussi di autenticazione 802.1X RADIUS e le principali opzioni open-source. Fondamentalmente, forniamo un framework per valutare quando uno stack open-source auto-costruito ha senso e quando il sovraccarico di conformità e integrazione rende necessaria una piattaforma enterprise come la soluzione Guest WiFi di Purple.

Ascolta il nostro briefing audio di accompagnamento per una panoramica strategica:


Approfondimento Tecnico: Come Funzionano i Captive Portal

Prima di valutare le opzioni software, è essenziale comprendere i meccanismi di rete fondamentali. Un captive portal è essenzialmente un meccanismo di controllo dell'accesso alla rete (NAC) che intercetta il traffico HTTP/HTTPS non autenticato e forza un reindirizzamento a un'interfaccia di autenticazione basata sul web.

Il Modello di Intercettazione Legacy

Storicamente, i captive portal si basavano su una combinazione di dirottamento DNS e reindirizzamenti HTTP 302. Quando un dispositivo ospite si connette a un SSID, il Captive Network Assistant (CNA) del sistema operativo invia una richiesta di sonda a un endpoint noto (ad esempio, captive.apple.com per iOS).

  1. Intercettazione DNS: Il gateway locale intercetta la richiesta DNS per l'URL della sonda e la risolve all'indirizzo IP del captive portal.
  2. Reindirizzamento HTTP: Se l'intercettazione DNS non viene utilizzata, il gateway intercetta la richiesta HTTP GET in uscita e restituisce un HTTP 302 Found, reindirizzando il client alla splash page.
  3. Firewall Walled Garden: Tutto il resto del traffico in uscita viene bloccato dal firewall del gateway fino al completamento dell'autenticazione. È consentito solo il traffico verso il portal e le risorse esterne approvate (il "walled garden").

Per una ripartizione più dettagliata di questi meccanismi, consulta la nostra guida: Come Funziona un Captive Portal? Approfondimento Tecnico .

Lo Standard Moderno: RFC 8908 (CAPPORT API)

Il modello di intercettazione legacy ha difficoltà con le moderne architetture HTTPS-everywhere. I browser segnalano giustamente il traffico HTTPS intercettato come un attacco Man-in-the-Middle (MitM), risultando in avvisi di certificato anziché una splash page pulita.

Per risolvere questo problema, il gruppo di lavoro IETF CAPPORT ha sviluppato RFC 8908 e RFC 8910. Invece di intercettare il traffico, la rete pubblicizza esplicitamente la presenza di un captive portal tramite DHCP (Opzione 114) o IPv6 Router Advertisements. Il dispositivo client interroga una JSON API per scoprire l'URL del portal e il suo stato di autenticazione attuale. Se stai costruendo un portal moderno, l'implementazione della CAPPORT API è fondamentale per un'esperienza utente senza interruzioni sui moderni dispositivi iOS e Android.

auth_flow_diagram.png

Flussi di Autenticazione e Autorizzazione

Una volta servita la splash page, il flusso di autenticazione detta l'esperienza utente e i dati raccolti.

  • Click-Through (Terms of Service): L'approccio a minor attrito. Nessuna credenziale richiesta, solo un'accettazione booleana dei termini. Adatto per ambienti ad alta densità dove la velocità di trasmissione è prioritaria rispetto all'acquisizione dei dati.
  • Acquisizione dell'Identità (Email/Social): L'utente si autentica tramite OAuth (Google, Facebook) o un modulo email. Ciò richiede un'attenta integrazione con i provider di identità e robusti meccanismi di conformità GDPR.
  • 802.1X e RADIUS: Per ambienti ad alta sicurezza (ad esempio, Healthcare o reti ospiti aziendali), è richiesto il controllo dell'accesso alla rete basato su porta tramite IEEE 802.1X. L'Access Point agisce come client RADIUS, inoltrando le credenziali a un server RADIUS (come FreeRADIUS) per la convalida rispetto a un servizio di directory.

Guida all'Implementazione: Piattaforme Open-Source vs. Gestite

Per gli sviluppatori incaricati di costruire un captive portal, l'ecosistema open-source offre diverse solide basi. Tuttavia, questi strumenti forniscono l'infrastruttura di rete, non la logica di business.

Principali Opzioni Open-Source

  1. pfSense + Captive Portal: Una popolare distribuzione firewall che include un modulo captive portal capace. Gestisce l'integrazione RADIUS, il filtraggio degli indirizzi MAC e la modellazione di base della larghezza di banda. Ideale per implementazioni a sito singolo con ingegneri di rete esperti.
  2. Coova-Chilli: Un controller di accesso maturo e ricco di funzionalità che implementa il protocollo WISPr. Eccelle in ambienti RADIUS complessi e può essere esteso per il social login, ma richiede una significativa esperienza nell'amministrazione di sistemi Linux.
  3. PacketFence: Una soluzione NAC open-source completa. Supporta 802.1X, l'onboarding BYOD e l'integrazione con le directory aziendali. Altamente scalabile, ma comporta una curva di apprendimento ripida e un significativo sovraccarico operativo.

open_source_comparison.png

Il "Costruire vs. "Quadro decisionale "Acquista"

Mentre il software open-source è "gratuito", il costo totale di proprietà per un Captive Portal autoprodotto scala in modo non lineare con il numero di sedi e la complessità dei requisiti aziendali.

Quando costruire:

  • Gestisci una singola sede o un piccolo gruppo di siti altamente uniformi.
  • I tuoi requisiti sono limitati all'accettazione di base dei Termini di Servizio o a un semplice accesso WPA2-PSK.
  • Disponi di risorse interne dedicate all'ingegneria Linux e di rete.

Quando acquistare (Piattaforma Enterprise):

  • Scala Multi-Sito: Stai implementando su decine o centinaia di sedi con hardware sottostante variabile (Cisco, Aruba, Meraki).
  • Conformità: Richiedi la gestione automatizzata del consenso GDPR/CCPA, la gestione delle richieste di accesso dei soggetti interessati (DSAR) e percorsi di audit verificabili.
  • Business Intelligence: Devi integrare i dati di rete con i sistemi di marketing. Piattaforme come Purple forniscono un livello unificato di WiFi Analytics , trasformando gli indirizzi MAC in metriche azionabili di affluenza e tempo di permanenza.
  • Integrazioni Avanzate: Hai bisogno di un'integrazione senza soluzione di continuità con i sistemi di gestione della proprietà (PMS) o i database di fidelizzazione.

Similmente a come le architetture WAN aziendali si stanno spostando verso soluzioni SD-WAN gestite (vedi I principali vantaggi dell'SD-WAN per le aziende moderne ), il guest WiFi aziendale si sta spostando verso piattaforme cloud hardware-agnostic che astraggono la complessità della rete edge.


Migliori Pratiche e Mitigazione del Rischio

Se procedi con una costruzione personalizzata o stai valutando un fornitore, assicurati che queste migliori pratiche architetturali siano rispettate:

1. Segmentazione della Rete e Sicurezza

Non implementare mai un Captive Portal sulla stessa VLAN della tua rete aziendale o di tecnologia operativa (OT). Il traffico degli ospiti deve essere rigorosamente segmentato. Se la tua sede elabora pagamenti (ad esempio, un hub di Trasporto con concessioni commerciali), la mancata segmentazione del guest WiFi porterà l'intera rete nell'ambito PCI DSS, aumentando notevolmente i costi di conformità.

2. Configurazione del Walled Garden

Il tuo walled garden deve consentire esplicitamente il traffico verso i domini necessari per il successo dell'autenticazione. Per il social login, questo significa consentire l'accesso a accounts.google.com, graph.facebook.com e ai loro CDNs associati. Un walled garden mal configurato fa sì che gli utenti rimangano bloccati su una splash page vuota.

3. Gestione della Larghezza di Banda e delle Sessioni

Implementa rigorosi limiti di velocità per utente e timeout di sessione. Un singolo utente che scarica un aggiornamento di grandi dimensioni del sistema operativo può saturare l'uplink WAN, degradando l'esperienza per tutti gli ospiti. Utilizza gli attributi RADIUS (ad esempio, WISPr-Bandwidth-Max-Down) per applicare questi limiti dinamicamente.

4. Mitigazione dello Spoofing MAC

Affidarsi esclusivamente agli indirizzi MAC per la persistenza della sessione è un rischio per la sicurezza, poiché gli indirizzi MAC sono facilmente spoofabili e le moderne funzionalità del sistema operativo (come iOS Private Wi-Fi Address) li randomizzano per impostazione predefinita. Assicurati che l'architettura del tuo Captive Portal possa gestire la randomizzazione MAC in modo elegante, tipicamente richiedendo una nuova autenticazione quando il MAC cambia, o utilizzando Passpoint/Hotspot 2.0 per un roaming sicuro e senza interruzioni.


ROI e Impatto sul Business

Un Captive Portal non dovrebbe essere visto solo come un centro di costo IT; è un canale critico per l'acquisizione di dati.

Quando implementato correttamente—spesso tramite una piattaforma gestita—il ROI viene misurato in tre aree:

  1. Crescita del Database di Marketing: Un flusso di onboarding senza interruzioni con un chiaro scambio di valore (ad esempio, "WiFi gratuito in cambio dell'email") costruisce rapidamente un database di marketing conforme e di prima parte.
  2. Operational Intelligence: Gli analytics derivati dai dati di connessione forniscono agli operatori delle sedi mappe di calore, analisi del carico di punta e metriche sui visitatori ricorrenti, influenzando direttamente le decisioni relative al personale e al layout.
  3. Riduzione del Rischio: La gestione centralizzata della conformità riduce significativamente il rischio di multe normative associate a una gestione impropria dei dati o a violazioni PCI DSS.

In definitiva, l'obiettivo di uno sviluppatore o di un architetto è fornire un'esperienza di rete sicura e senza attriti che serva gli obiettivi strategici dell'azienda. Scegli l'architettura che consente al tuo team di concentrarsi su tali obiettivi, piuttosto che gestire l'infrastruttura.

Termini chiave e definizioni

Captive Portal

A web page that the user of a public-access network is obliged to view and interact with before access is granted.

The primary interface for guest network onboarding, used for terms acceptance, payment, or data capture.

RADIUS (Remote Authentication Dial-In User Service)

A networking protocol that provides centralized Authentication, Authorization, and Accounting (AAA) management for users who connect and use a network service.

The backend engine that validates credentials and tells the network equipment what permissions a guest should have.

Walled Garden

A limited environment that controls the user's access to external web content and services prior to full authentication.

Essential for allowing users to access identity providers (like Google or Facebook) to log in, before they have general internet access.

MAC Spoofing

The practice of altering a device's factory-assigned Media Access Control (MAC) address to masquerade as another device or bypass network restrictions.

A common method used to bypass captive portal time limits, requiring robust session management strategies to mitigate.

CAPPORT API (RFC 8908)

A modern IETF standard allowing devices to securely discover the captive portal URL and authentication status via DHCP or Router Advertisements, rather than relying on HTTP interception.

Critical for modern portal development to prevent HTTPS certificate errors and improve the user onboarding experience.

IEEE 802.1X

An IEEE Standard for port-based Network Access Control (PNAC), providing an authentication mechanism to devices wishing to attach to a LAN or WLAN.

Used in enterprise and high-security environments where simple web-based authentication is insufficient.

WISPr (Wireless Internet Service Provider roaming)

A draft protocol submitted to the Wi-Fi Alliance that allows users to roam between different wireless internet service providers.

Often implemented by access controllers to handle the XML-based authentication requests from the captive portal to the gateway.

VLAN Segmentation

The practice of partitioning a single layer-2 network to create multiple distinct broadcast domains.

A mandatory security practice to ensure guest WiFi traffic cannot access corporate or operational technology networks.

Casi di studio

A 200-room hotel needs to deploy guest WiFi. They require guests to authenticate using their room number and last name to access a premium bandwidth tier, while non-guests receive a throttled 2Mbps connection. The underlying network uses Cisco Meraki access points.

  1. Configure the Meraki SSID to use an external captive portal (Splash page URL pointing to the custom portal). 2. Set up a RADIUS server (e.g., FreeRADIUS) and configure the Meraki APs as RADIUS clients. 3. Develop the captive portal web application to present a login form requesting Room Number and Last Name. 4. Integrate the portal backend with the hotel's Property Management System (PMS) via API. When credentials are submitted, the portal queries the PMS to validate the guest. 5. Upon successful validation, the portal backend sends a RADIUS Access-Accept message to the Meraki controller, including Vendor-Specific Attributes (VSAs) to apply the 'Premium' group policy (unthrottled bandwidth). 6. For non-guests, provide a 'Free Access' button that bypasses the PMS check and returns a RADIUS Access-Accept with VSAs applying the 'Throttled' group policy.
Note di implementazione: This approach correctly separates the network layer (Meraki) from the business logic (PMS integration). By utilizing RADIUS VSAs, the network dynamically applies bandwidth shaping based on the user's identity tier, satisfying the core requirement while maintaining a centralized control plane.

A national retail chain with 50 locations wants to implement a captive portal to collect customer emails for marketing. They are concerned about GDPR compliance and the operational overhead of managing 50 separate local portal instances.

Instead of deploying local captive portal software (like pfSense) at each site, deploy a centralized, cloud-hosted captive portal platform (like Purple). Configure the local branch routers/APs to redirect guest traffic to the centralized portal URL. Implement a standardized splash page with explicit opt-in checkboxes for marketing consent and a link to the privacy policy. The centralized platform handles the capture, timestamping, and secure storage of consent records, and integrates directly via API with the retailer's central CRM system.

Note di implementazione: A centralized architecture is essential for multi-site retail. Attempting to manage compliance and data aggregation across 50 distributed open-source instances is highly risky and operationally inefficient. The centralized platform ensures uniform compliance posture and real-time data synchronization.

Analisi degli scenari

Q1. You are deploying a captive portal in an airport. The primary goal is maximum throughput and minimizing support tickets from users unable to connect. Which authentication method should you prioritize?

💡 Suggerimento:Consider the friction involved in verifying identities versus simply gaining legal consent.

Mostra l'approccio consigliato

A Click-Through (Terms of Service) portal. In high-density transit environments, requiring email verification or SMS OTP introduces significant friction and relies on external dependencies (cellular reception for SMS, existing email access). A simple Terms of Service acceptance minimizes support overhead while meeting basic legal requirements.

Q2. Your security team reports that users are bypassing the 2-hour free WiFi limit by changing their device's MAC address. How should you architect the network to mitigate this?

💡 Suggerimento:MAC addresses are layer-2 identifiers that can be easily spoofed. You need a layer-7 identity verification.

Mostra l'approccio consigliato

Shift from a purely MAC-based session tracking model to an identity-based model. Require users to authenticate via a unique identifier (e.g., SMS OTP or a verified email address) and tie the session limit to that identity in the RADIUS backend, rather than the device's MAC address.

Q3. A hospital requires a guest WiFi network for patients and visitors. They also need a separate network for medical IoT devices. What is the most critical architectural requirement?

💡 Suggerimento:Consider the impact if a compromised guest device could reach a medical device.

Mostra l'approccio consigliato

Strict VLAN segmentation. The guest WiFi network must be placed on a completely isolated VLAN that has no routing path to the clinical or IoT networks. The captive portal and guest traffic must be firewalled and routed directly to the internet.