Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$os_meta is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$has_disclaimer is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_lock is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_category is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_blz_affiliation_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_content_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_speciali is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskw is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_linkdex is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_content_score is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskeywords is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_keywordsynonyms is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_estimated-reading-time-minutes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$os_previous_publish_date is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$os_notification_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_indexnow_last_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
Accendere un PC da remoto senza IP pubblico: trucco con ESP32 e MQTT che aggira NAT e CGNAT | IlSoftware.it

Accendere un PC da remoto senza IP pubblico: trucco con ESP32 e MQTT che aggira NAT e CGNAT

Un microcontroller ESP32 collegato a un broker MQTT permette di accendere un PC da remoto via Wake-on-LAN (WoL) anche senza IP pubblico, senza VPN né porte aperte, mantenendo la rete LAN sempre chiusa.

Wake-on-LAN (WoL) è una tecnologia solida e collaudata, ma storicamente confinata all’interno della rete locale. Appena si esce dal perimetro della LAN emergono i limiti classici: NAT, firewall, in certi casi assenza di IP pubblico e, sempre più spesso, CGNAT imposto dagli operatori. Abbiamo visto come attivare WoL in Windows 11 e configurare il router per accedere un sistema a distanza.

Un ricercatore indipendente ha pubblicato su GitHub un progetto innovativo basato su ESP32 e MQTT che risolve il problema in modo elegante, senza forzare aperture di porte, usare VPN o servizi esposti verso l’esterno.

L’idea di fondo è semplice ma potente: invece di tentare una connessione in ingresso, da remoto, verso la rete LAN, si mantiene una connessione persistente in uscita verso un broker MQTT. È l’ESP32 a collegarsi a Internet, non il contrario. In questo modo la rete locale rimane completamente chiusa, ma comunque “raggiungibile” tramite messaggi asincroni.

Come funziona l’accensione da remoto di un sistema con WoL, ESP32 e MQTT

ESP32 è una famiglia di microcontrollori sviluppata da Espressif Systems, progettata per applicazioni embedded con connettività di rete integrata. A differenza dei microcontrollori tradizionali, ESP32 nasce con WiFi e Bluetooth integrati nel chip, caratteristica che lo rende particolarmente adatto a progetti IoT, automazione domestica e dispositivi connessi.

Dal punto di vista hardware, ESP32 integra una CPU a 32 bit (single o dual-core a seconda del modello), memoria RAM on-chip e numerose periferiche: GPIO, UART, SPI, I²C, ADC, DAC e timer. La dotazione consente di realizzare dispositivi completi senza componenti esterni complessi, mantenendo costi e consumi contenuti.

Come accennato in apertura, nel progetto in questione ESP32 si collega via WiFi e stabilisce una connessione outbound verso un broker MQTT.

MQTT è un protocollo di messaggistica leggero basato su pub/sub (un dispositivo pubblica un messaggio su un topic senza sapere chi lo leggerà; altri dispositivi si iscrivono a quel topic e ricevono automaticamente i messaggi pubblicati), progettato per dispositivi con risorse limitate e reti poco affidabili, utilizzatissimo in ambito IoT.

Scambio dei dati via MQTT

Durante l’avvio viene generato un identificativo univoco del dispositivo, derivato dall’hardware interno del chip. Questo ID diventa il nome del topic MQTT a cui il dispositivo si iscrive. Qualsiasi messaggio che non rispetti esattamente quel topic viene ignorato, riducendo drasticamente la superficie di attacco.

Quando arriva un payload valido, contenente un indirizzo MAC nel formato standard, ESP32 genera il magic packet Wake-on-LAN (ossia il pacchetto che permette di accendere il sistema, ad esempio il PC Windows) e lo trasmette in broadcast sulla LAN. Da quel momento il comportamento è identico a un classico WoL locale: se la scheda di rete del PC è correttamente configurata e il BIOS supporta la funzione WoL, la macchina si accende.

MQTT come canale di controllo, non come servizio esposto

La scelta di MQTT non è casuale. È un protocollo progettato per dispositivi embedded e connessioni persistenti, ideale per attraversare NAT e CGNAT senza alcuna configurazione lato router. Non ci sono socket in ascolto, non ci sono daemon esposti, non esistono porte da mappare. Tutto il traffico è in uscita.

Il firmware supporta due modalità operative distinte. La prima, pensata per la maggior parte degli utenti, utilizza un broker pubblico e un’interfaccia Web pronta all’uso. In questo scenario non è richiesto alcun setup manuale: si flasha il firmware via browser su ESP32, si configura il WiFi e il dispositivo è immediatamente utilizzabile. L’interfaccia Web consente di inserire Device ID e MAC address e inviare il comando di accensione in pochi secondi.

Lo sviluppatore ha creato un pannello Web dimostrativo che è utilizzabile proprio per dialogare con un microcontrollore ESP32 remoto e inviare la richiesta di accensione del PC via WoL.

La seconda modalità è pensata per chi vuole il pieno controllo dell’infrastruttura. Disabilitando l’ID già presente e configurando manualmente host, porta e credenziali MQTT, ESP32 può collegarsi a un broker privato, anche self-hosted. Il formato del comando resta minimale e chiaro: topic dedicato al dispositivo e payload contenente esclusivamente il MAC address. Tutto il resto viene ignorato.

Sicurezza efficace, senza complicazioni inutili

Dal punto di vista della sicurezza, il modello è sorprendentemente pulito. Ogni dispositivo ascolta un solo topic, derivato dal proprio ID hardware, opzionalmente offuscato con hashing SHA-256.

Non esistono servizi interni accessibili dall’esterno, non vengono accettate connessioni inbound e non è richiesto alcun port forwarding. Anche in caso di compromissione del broker, l’attaccante dovrebbe conoscere l’ID esatto del dispositivo e inviare un payload formalmente valido.

Il supporto TLS aggiunge un ulteriore livello di protezione, soprattutto quando si utilizzano broker pubblici. In questo contesto MQTT non diventa un punto debole, ma un semplice canale di trasporto cifrato per un comando, qual è appunto WoL, estremamente limitato nelle sue capacità.

Un’alternativa concreta a VPN e tunnel permanenti

Molti risponderebbero che una VPN risolve il problema. È vero, ma introduce complessità, manutenzione e un’esposizione della rete domestica.

Il progetto basato su ESP32 e MQTT segue una filosofia diversa: fare una sola cosa, farla bene e con il minimo impatto possibile. Accendere un PC da remoto, nulla di più.

È proprio questa focalizzazione a renderlo interessante anche in contesti homelab o domotici più avanzati. L’integrazione con sistemi esterni come Home Assistant è naturale, ma non obbligatoria. Il dispositivo resta autonomo, silenzioso e invisibile sulla rete.

Ti consigliamo anche

Link copiato negli appunti