<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Antonio Francesco Gentile on Medium]]></title>
        <description><![CDATA[Stories by Antonio Francesco Gentile on Medium]]></description>
        <link>https://medium.com/@antoniofrancesco.gentile?source=rss-b810bf57d7a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VTKHoElxsYhXV10Z</url>
            <title>Stories by Antonio Francesco Gentile on Medium</title>
            <link>https://medium.com/@antoniofrancesco.gentile?source=rss-b810bf57d7a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:27:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antoniofrancesco.gentile/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My OpenBSD Adventures — Building an Enterprise-Grade IKEv2 VPN and Secure Gateway Using OpenBSD]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/my-openbsd-adventures-building-an-enterprise-grade-ikev2-vpn-and-secure-gateway-using-openbsd-ff3649838ac8?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff3649838ac8</guid>
            <category><![CDATA[secure-gateway]]></category>
            <category><![CDATA[openiked]]></category>
            <category><![CDATA[openbsd]]></category>
            <category><![CDATA[pf-firewall]]></category>
            <category><![CDATA[post]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 07:22:14 GMT</pubDate>
            <atom:updated>2026-12-01T07:22:14.576Z</atom:updated>
            <content:encoded><![CDATA[<p>There is a persistent belief in the IT world that “enterprise security” necessarily requires expensive appliances, SaaS subscriptions, and vendor ecosystems. In practice, much of what is marketed as enterprise-grade is built upon the same open technologies that are freely available to anyone willing to invest time and knowledge.</p><p>This article describes how a single OpenBSD server can provide a modern VPN, multi-factor authentication, SMS fallback, account lockout, advanced logging, and a segmented firewall with multiple VLANs. The goal is not to replicate a specific commercial product, but to demonstrate that open-source software already provides the building blocks for designing and operating serious security infrastructure.</p><h3>Why OpenBSD Is an Ideal Foundation</h3><p>OpenBSD has long been recognized for its security-first philosophy and minimal, auditable design. The operating system ships with PF, one of the most respected firewalls, and includes ike, a native IKEv2 VPN daemon. This combination makes OpenBSD particularly well-suited for building a secure network gateway that integrates remote access, firewalling, and authentication in a single coherent platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1f04fka6VKNlHl3sf76Fw.png" /></figure><p>Rather than relying on multiple proprietary appliances, the entire stack can be hosted on one system, simplifying management and reducing operational complexity.</p><h3>Architecture Overview</h3><p>The gateway described here provides secure remote access for users while acting as the primary firewall for a segmented internal network. The network includes a WAN interface connected to the public internet and three internal VLANs dedicated to office workstations, servers, and IoT devices. Remote VPN users are placed on a separate virtual network and are allowed controlled access to selected internal resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFcHhV_DwnSBV93LjEqOeQ.png" /></figure><p>Authentication is designed around a layered model that combines traditional credentials with time-based one-time passwords. If the OTP verification fails, an SMS fallback mechanism is triggered using a self-hosted Asterisk PBX connected to a USB GSM modem. The result is a fully self-contained authentication system that does not depend on third-party services.</p><h3>Implementing Multi-Factor Authentication Without Cloud Services</h3><p>Time-based one-time passwords are generated using the OATH toolkit, which is available directly from the OpenBSD package repository. This makes the system compatible with widely used authenticator applications such as Google Authenticator, Microsoft Authenticator, FreeOTP, and Authy. Each user receives a personal secret that can be enrolled via a locally generated QR code.</p><p>This approach removes the need for cloud-hosted MFA providers while maintaining the same level of security typically expected from commercial VPN platforms.</p><h3>Custom Authentication Logic</h3><p>One of the most powerful aspects of iked is the ability to delegate authentication to an external script. This allows the VPN gateway to implement custom logic that goes beyond simple username and password verification. The authentication workflow validates the user’s Unix password, checks the OTP token, records failures, locks accounts when necessary, and sends fallback SMS messages when the OTP step fails.</p><p>This flexibility illustrates a broader point about open source: the ability to inspect and modify behavior at every layer enables tailoring security controls to specific organizational requirements.</p><h3>Account Lockout and Brute-Force Protection</h3><p>Modern remote-access services must defend against automated attacks such as password spraying and credential stuffing. In this setup, repeated authentication failures are tracked per user and result in temporary account lockouts. At the network level, the PF firewall automatically rate-limits incoming VPN traffic and dynamically blocks aggressive IP addresses.</p><p>By combining application-level controls with firewall-level protections, the system provides layered defenses comparable to those found in commercial security appliances.</p><h3>Self-Hosted SMS Fallback Using Asterisk</h3><p>Many organizations rely on commercial SMS APIs as a fallback for authentication. While convenient, this approach introduces recurring costs and external dependencies. Instead, this design uses Asterisk and a low-cost USB GSM modem to send SMS messages directly from the gateway. When an OTP attempt fails, the authentication script can trigger a message containing the current code, providing a backup channel for users who cannot access their authenticator application.</p><p>This demonstrates how open-source telephony tools can be integrated into broader security workflows.</p><h3>Centralized Logging and Observability</h3><p>Logging is a fundamental requirement for any production-grade system. The gateway records VPN events, firewall activity, authentication attempts, and account lockouts using the native syslog infrastructure. These logs can later be forwarded to centralized monitoring platforms such as ELK, Graylog, Splunk, or Wazuh, enabling long-term analysis and alerting.</p><p>The ability to integrate with established observability tools ensures that the solution remains suitable for professional environments.</p><h3>Network Segmentation with PF</h3><p>The firewall component of the gateway enforces strict network segmentation between office devices, servers, and IoT equipment. IoT devices are treated as untrusted and are prevented from accessing sensitive networks. VPN users are granted access only to the networks they require, and all outbound traffic is subject to stateful filtering and network address translation.</p><p>Segmentation is one of the most effective ways to reduce the attack surface, and PF enables these policies to be implemented with clarity and precision.</p><h3>What This Demonstrates</h3><p>The system described in this article delivers capabilities that are often associated with commercial enterprise products. It provides a secure VPN with multi-factor authentication, SMS fallback, automated lockout policies, network segmentation, centralized logging, and brute-force protection. All of this is achieved using freely available open-source software.</p><p>The broader lesson is that enterprise security is not defined by proprietary hardware or subscription services. It is defined by architecture, design, and operational knowledge. Vendors often package integration and convenience, but the underlying capabilities already exist in the open-source ecosystem.</p><p>Below is an appendix you can add at the end of the article.</p><h3>Appendix — Command Reference and Configuration Examples</h3><p>This appendix collects the main commands and configuration snippets used to build the system described in the article. The goal is not to provide a one-click script, but a practical reference for reproducing the architecture step by step.</p><h3>1. Installing Required Packages</h3><p>On OpenBSD, install the tools required for OTP, QR code generation, and general utilities.</p><pre>pkg_add oath-toolkit libqrencode</pre><p>If SMS fallback is required through Asterisk, the PBX and chan_dongle must be installed and configured separately.</p><h3>2. Creating VPN Users</h3><p>Create a local user dedicated to VPN access.</p><pre>adduser vpnuser<br>passwd vpnuser</pre><p>Each user will also store their mobile phone number locally for SMS fallback.</p><pre>echo &quot;+391234567890&quot; &gt; /home/vpnuser/.vpn_phone<br>chmod 600 /home/vpnuser/.vpn_phone</pre><h3>3. Generating TOTP Secrets (Google Authenticator Compatible)</h3><p>Switch to the user account:</p><pre>su - vpnuser<br>mkdir ~/.google-authenticator<br>chmod 700 ~/.google-authenticator</pre><p>Generate the secret:</p><pre>openssl rand -base64 20 &gt; ~/.google-authenticator/secret<br>chmod 600 ~/.google-authenticator/secret</pre><p>Generate the QR code for enrollment:</p><pre>SECRET=$(cat ~/.google-authenticator/secret)</pre><pre>echo &quot;otpauth://totp/OpenBSD-VPN:vpnuser?secret=$SECRET&amp;issuer=OpenBSD-VPN&quot; \<br>| qrencode -t ansiutf8</pre><p>The user scans the QR code using an authenticator application.</p><h3>4. VPN Authentication Script</h3><p>Create the script used by iked to validate passwords, OTPs, account lockouts, and SMS fallback.</p><pre>doas vi /usr/local/bin/vpn_otp_auth.sh<br>chmod +x /usr/local/bin/vpn_otp_auth.sh</pre><p>Script:</p><pre>#!/bin/sh<br><br>USER=&quot;$1&quot;<br>PASS=&quot;$2&quot;<br>BASE=&quot;/var/db/vpn&quot;<br>LOG=&quot;/var/log/vpn-auth.log&quot;<br><br>FAILFILE=&quot;$BASE/$USER.fail&quot;<br>LOCKFILE=&quot;$BASE/$USER.lock&quot;<br>MAX_FAIL=5<br>LOCK_TIME=900<br>log() {<br>  echo &quot;$(date) user=$USER msg=$1&quot; &gt;&gt; $LOG<br>}<br>mkdir -p /var/db/vpn<br>touch /var/log/vpn-auth.log<br>if [ -f &quot;$LOCKFILE&quot; ]; then<br>    NOW=$(date +%s)<br>    LOCKED=$(cat &quot;$LOCKFILE&quot;)<br>    if [ $((NOW-LOCKED)) -lt $LOCK_TIME ]; then<br>        log &quot;ACCOUNT LOCKED&quot;<br>        exit 1<br>    else<br>        rm -f &quot;$LOCKFILE&quot; &quot;$FAILFILE&quot;<br>    fi<br>fi<br>OTP=&quot;${PASS##* }&quot;<br>PASSWORD=&quot;${PASS% *}&quot;<br>echo &quot;$PASSWORD&quot; | su -l &quot;$USER&quot; -c true 2&gt;/dev/null<br>if [ $? -ne 0 ]; then<br>    log &quot;BAD PASSWORD&quot;<br>    FAILS=$(($(cat $FAILFILE 2&gt;/dev/null || echo 0)+1))<br>    echo $FAILS &gt; $FAILFILE<br>else<br>    FAILS=0<br>fi<br>if [ &quot;$FAILS&quot; -ge &quot;$MAX_FAIL&quot; ]; then<br>    date +%s &gt; &quot;$LOCKFILE&quot;<br>    log &quot;ACCOUNT LOCKED AFTER FAILS&quot;<br>    exit 1<br>fi<br>SECRET=$(cat /home/$USER/.google-authenticator/secret)<br>VALID=$(oathtool --totp -b &quot;$SECRET&quot;)<br>if [ &quot;$OTP&quot; = &quot;$VALID&quot; ]; then<br>    rm -f &quot;$FAILFILE&quot;<br>    log &quot;LOGIN SUCCESS&quot;<br>    exit 0<br>fi<br>PHONE=$(cat /home/$USER/.vpn_phone)<br>SMSOTP=$(oathtool --totp -b &quot;$SECRET&quot;)<br>asterisk -rx &quot;dongle sms send dongle0 $PHONE Code: $SMSOTP&quot;<br>log &quot;OTP SENT VIA SMS&quot;<br>exit 1</pre><p>Users authenticate by entering:</p><pre>password + space + OTP</pre><h3>5. Configuring IKED (IKEv2 VPN)</h3><p>Edit the VPN configuration file:</p><pre>vi /etc/iked.conf</pre><p>Example configuration:</p><pre>ikev2 &quot;roadwarrior&quot; passive esp \<br>    from 0.0.0.0/0 to 10.0.0.0/24 \<br>    local eap &quot;vpn&quot; \<br>    eap auth &quot;/usr/local/bin/vpn_otp_auth.sh&quot;</pre><p>Enable and start the service:</p><pre>rcctl enable iked<br>rcctl start iked</pre><h3>6. Enabling System Logging</h3><p>Configure syslog to store VPN and firewall logs.</p><pre>vi /etc/syslog.conf</pre><p>Add:</p><pre>iked.*  /var/log/iked.log<br>pf.*    /var/log/pf.log</pre><p>Restart syslog:</p><pre>rcctl restart syslogd</pre><p>Enable firewall logging:</p><pre>rcctl enable pflogd<br>rcctl start pflogd</pre><p>Monitor logs in real time:</p><pre>tcpdump -n -e -ttt -i pflog0</pre><h3>7. Network Configuration and VLAN Setup</h3><p>Example network layout:</p><p>InterfaceRoleNetworkem0WANPublic IPem1LAN10.0.10.0/24vlan20Servers10.0.20.0/24vlan30IoT10.0.30.0/24</p><p>Interface configuration files:</p><pre>echo &quot;up&quot; &gt; /etc/hostname.em1<br>echo &quot;inet 10.0.10.1 255.255.255.0&quot; &gt; /etc/hostname.em1<br>echo &quot;vlan 20 vlandev em1 inet 10.0.20.1 255.255.255.0&quot; &gt; /etc/hostname.vlan20<br>echo &quot;vlan 30 vlandev em1 inet 10.0.30.1 255.255.255.0&quot; &gt; /etc/hostname.vlan30</pre><p>Enable routing:</p><pre>echo &quot;net.inet.ip.forwarding=1&quot; &gt;&gt; /etc/sysctl.conf</pre><h3>8. PF Firewall Configuration</h3><p>Create the firewall ruleset:</p><pre>vi /etc/pf.conf</pre><p>Example configuration:</p><pre>set skip on lo<br>set block-policy drop<br>set loginterface egress</pre><pre>wan = &quot;em0&quot;<br>lan = &quot;em1&quot;<br>srv = &quot;vlan20&quot;<br>iot = &quot;vlan30&quot;<br>vpn = &quot;enc0&quot;</pre><pre>lan_net = &quot;10.0.10.0/24&quot;<br>srv_net = &quot;10.0.20.0/24&quot;<br>iot_net = &quot;10.0.30.0/24&quot;<br>vpn_net = &quot;10.0.99.0/24&quot;</pre><pre>table &lt;bruteforce&gt; persist</pre><pre>match out on $wan from { $lan_net $srv_net $iot_net $vpn_net } nat-to ($wan)</pre><pre>block log all</pre><pre>block in quick from &lt;bruteforce&gt;</pre><pre>pass in on $wan proto udp to ($wan) port {500 4500} keep state</pre><pre>pass in on $wan proto udp to ($wan) port {500 4500} \<br>    max-src-conn-rate 10/60 overload &lt;bruteforce&gt; flush global</pre><pre>pass in on $lan from $lan_net to any keep state<br>pass in on $srv from $srv_net to any keep state<br>pass in on $iot from $iot_net to any keep state</pre><pre>pass in on $vpn from $vpn_net to { $lan_net $srv_net } keep state</pre><pre>block in quick from $iot_net to { $lan_net $srv_net }</pre><pre>pass out proto { tcp udp } to any port {53 123} keep state<br>pass out on $wan all keep state</pre><p>Enable PF:</p><pre>pfctl -f /etc/pf.conf<br>pfctl -e</pre><p>This completes the command reference for reproducing the system described in the article.</p><h3>Final Thoughts</h3><p>This approach is suitable for small companies, startups, remote teams, and privacy-focused organizations seeking independence from vendor ecosystems. Open source offers the freedom to build systems that are transparent, customizable, and cost-effective.</p><p>The tools are already available. The true investment lies in learning how to use them effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff3649838ac8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Source seamless Wi-Fi Roaming with OpenWrt]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/open-source-seamless-wi-fi-roaming-with-openwrt-5b564a7df8a8?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b564a7df8a8</guid>
            <category><![CDATA[roaming]]></category>
            <category><![CDATA[openwrt]]></category>
            <category><![CDATA[wireless-access-point]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 08:58:38 GMT</pubDate>
            <atom:updated>2026-11-02T08:58:38.552Z</atom:updated>
            <content:encoded><![CDATA[<h3>A POT with Architecture, Configurations, and Appendices (802.11r / 802.11k / 802.11v)</h3><p>Modern homes, offices, hospitality environments, and multi-floor buildings increasingly depend on uninterrupted wireless connectivity. Voice over IP, video conferencing, cloud applications, streaming, and IoT ecosystems require continuous connectivity while users move between rooms and floors. Traditional multi-access-point deployments often fail to provide this experience because devices remain attached to distant access points (“sticky clients”) or experience short disconnections during handover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*dYfspHlbL1pOIaHNAJocig.png" /></figure><p>OpenWrt enables the build of an enterprise-grade roaming infrastructure using affordable hardware and open-source software. This article provides a complete end-to-end guide covering architecture, theory, configuration, and real deployment examples.</p><h3>Understanding Modern Wi-Fi Roaming</h3><p>A network composed of multiple access points broadcasting the same SSID is called an <strong>Extended Service Set (ESS)</strong>. Each access point represents a <strong>Basic Service Set (BSS)</strong>, but from the user perspective, the network behaves as a single wireless infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AD1fD4X9hoVNsFOLZEuK8g.png" /></figure><p>A fundamental concept must be emphasized: the <strong>client always decides when to roam</strong>. The network cannot force roaming; it can only assist and optimize the process. Modern roaming relies on three IEEE standards:</p><p>802.11k allows access points to provide neighbor reports, reducing scanning time when a client searches for a better signal.<br>802.11v allows the network to suggest when and where the client should roam, helping eliminate sticky clients.<br>802.11r (Fast Transition) dramatically reduces authentication time during handover.</p><p>In real deployments, 802.11k and 802.11v deliver the most consistent improvements, while 802.11r is especially valuable for real-time applications such as VoIP and video calls.</p><h3>Recommended Network Architecture</h3><p>A robust roaming deployment separates routing and wireless access.</p><p>The recommended architecture uses a single main router responsible for DHCP, firewalling, and routing, while additional OpenWrt devices operate as <strong>dumb access points</strong> connected via a wired Ethernet backhaul.</p><p>All access points must share an identical wireless configuration, including SSID, password, encryption method, and Layer-2 network. Radio planning is critical: neighboring access points must use different channels and balanced transmit power to encourage roaming.</p><h3>Required Software Components</h3><p>Seamless roaming requires the full hostapd implementation. The default OpenWrt package must be replaced with:</p><pre>opkg update<br>opkg remove wpad-basic-mbedtls<br>opkg install wpad-mbedtls</pre><p>A roaming coordination daemon must also be installed. OpenWrt offers two main options:</p><p>Usteer is simple, lightweight, and ideal for home and small office deployments.<br>DAWN (Distributed Automatic Wireless Network) is more advanced and better suited to larger infrastructures with high client density.</p><h3>Deployment Example — Four-Floor Building</h3><p>Main Router (Ground Floor) — 192.168.1.1<br>AP Floor 1–192.168.1.2<br>AP Floor 2–192.168.1.3<br>AP Floor 3–192.168.1.4</p><p>Common wireless parameters:</p><p>SSID: CasaRoaming<br>Security: WPA2/WPA3 mixed<br>Mobility Domain: a1b2<br>DTIM: 3</p><h3>Configuration Overview</h3><p>The router remains the only DHCP server. All access points operate as dumb APs with DHCP and firewall disabled.</p><p>Wireless configuration must be identical across all devices and include 802.11r, 802.11k, and 802.11v.</p><h3>Appendix A — Router (Master) Configuration</h3><pre>/etc/config/network<br>config interface &#39;lan&#39;<br>option device &#39;br-lan&#39;<br>option proto &#39;static&#39;<br>option ipaddr &#39;192.168.1.1&#39;<br>option netmask &#39;255.255.255.0&#39;<br><br>/etc/config/dhcp<br>config dhcp &#39;lan&#39;<br>option interface &#39;lan&#39;<br>option start &#39;100&#39;<br>option limit &#39;150&#39;<br>option leasetime &#39;12h&#39;</pre><h3>Appendix B — Access Point (Slave) Configuration</h3><p>Example AP-01:</p><pre>/etc/config/network<br>config interface &#39;lan&#39;<br>option device &#39;br-lan&#39;<br>option proto &#39;static&#39;<br>option ipaddr &#39;192.168.1.2&#39;<br>option netmask &#39;255.255.255.0&#39;<br>option gateway &#39;192.168.1.1&#39;<br>option dns &#39;192.168.1.1&#39;</pre><p>Disable services:</p><pre>/etc/init.d/dnsmasq disable<br>/etc/init.d/firewall disable</pre><h3>Appendix C — Wireless Configuration (All APs)</h3><pre>config wifi-iface &#39;default_radio0&#39;<br> option mode &#39;ap&#39;<br> option network &#39;lan&#39;<br> option ssid &#39;CasaRoaming&#39;<br> option encryption &#39;sae-mixed&#39;<br> option key &#39;PasswordRobusta123&#39;<br> option ieee80211r &#39;1&#39;<br> option mobility_domain &#39;a1b2&#39;<br> option ft_over_ds &#39;0&#39;<br> option ft_psk_generate_local &#39;1&#39;<br> option reassociation_deadline &#39;1000&#39;<br> option ieee80211k &#39;1&#39;<br> option rrm_neighbor_report &#39;1&#39;<br> option rrm_beacon_report &#39;1&#39;<br> option ieee80211v &#39;1&#39;<br> option bss_transition &#39;1&#39;<br> option wnm_sleep_mode &#39;1&#39;</pre><p>Channel planning example:</p><p>Ground floor → 1 / 36<br>Floor 1 → 6 / 52<br>Floor 2 → 11 / 100<br>Floor 3 → 1 / 116</p><h3>Appendix D — Roaming with Usteer</h3><p>Install packages:</p><pre>opkg install usteer luci-app-usteer</pre><p>Enable service:</p><pre>/etc/init.d/usteer enable<br>/etc/init.d/usteer start</pre><p>Configuration file /etc/config/usteer:</p><pre>config usteer &#39;usteer&#39;<br> option enabled &#39;1&#39;<br> option network &#39;lan&#39;<br> option band_steering &#39;1&#39;<br> option load_balancing &#39;1&#39;<br> option steer_reject_timeout &#39;60000&#39;<br> option min_snr &#39;15&#39;<br> option roam_trigger_snr &#39;20&#39;<br> option roam_delta &#39;5&#39;<br> option assoc_steering &#39;1&#39;</pre><p>Usteer provides band steering, client steering, and load balancing, and is recommended for most deployments.</p><h3>Appendix E — Roaming with DAWN (Advanced Alternative)</h3><p>Install packages:</p><pre>opkg install dawn luci-app-dawn</pre><p>Enable service:</p><pre>/etc/init.d/dawn enable<br>/etc/init.d/dawn start</pre><p>Configuration /etc/config/dawn:</p><pre>config network<br> option broadcast_ip &#39;192.168.1.255&#39;<br> option tcp_port &#39;1025&#39;<br> option network_option &#39;2&#39;<br> option shared_key &#39;OpenWrtRoamingKey&#39;<br> <br>config metric &#39;global&#39;<br> option min_probe_count &#39;2&#39;<br> option bandwidth_threshold &#39;6&#39;<br> option use_station_count &#39;1&#39;<br> option max_station_diff &#39;1&#39;</pre><p>DAWN offers distributed decision-making and advanced metrics suited to high-density deployments.</p><h3>Appendix F — LuCI Configuration Workflow</h3><p>Access points must receive static IP addresses, DHCP must be disabled, and the firewall must be turned off.</p><p>Wireless roaming settings are available in:</p><p>Network → Wireless → Edit SSID → WLAN Roaming</p><p>Enable 802.11r, 802.11k, and 802.11v using the same Mobility Domain on every AP.</p><p>Usteer or DAWN can be configured from the Services menu.</p><h3>Appendix G — Deployment Checklists</h3><p>Network prerequisites include wired backhaul, a single DHCP server, static IP assignment, and a shared subnet.</p><p>Wireless verification includes an identical SSID and encryption, matching the mobility domain, non-overlapping channels, and a DTIM set to 3.</p><p>Advanced roaming validation includes full WPA/WPA2 installation, an active steering daemon, and successful roaming tests during VoIP calls.</p><h3>Final Thoughts</h3><p>OpenWrt enables enterprise-grade Wi-Fi roaming using open-source tools and commodity hardware. Successful deployments depend on consistent configuration, thoughtful architecture, and careful RF planning.</p><p>When properly implemented, seamless roaming significantly improves the user experience across multi-floor homes, offices, and hospitality environments, delivering connectivity comparable to that of commercial wireless systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b564a7df8a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a Hybrid VoIP Architecture with FreeSWITCH and Asterisk for GSM Integration (A POC)]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/designing-a-hybrid-voip-architecture-with-freeswitch-and-asterisk-for-gsm-integration-a-poc-92e3f11403e2?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/92e3f11403e2</guid>
            <category><![CDATA[voip]]></category>
            <category><![CDATA[gsm]]></category>
            <category><![CDATA[chan-dongle]]></category>
            <category><![CDATA[asterisk]]></category>
            <category><![CDATA[freeswitch]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Thu, 01 Oct 2026 12:37:34 GMT</pubDate>
            <atom:updated>2026-10-01T12:37:34.790Z</atom:updated>
            <content:encoded><![CDATA[<p>In complex telephony environments, no single platform excels at every task. This article describes a hybrid VoIP architecture that combines <strong>Asterisk</strong> and <strong>FreeSWITCH</strong> to leverage their respective strengths. Asterisk handles <strong>hardware-level GSM integration</strong>, while FreeSWITCH acts as the <strong>core PBX engine</strong>, managing users, routing logic, and advanced call control. The result is a modular, extensible, and hardware-agnostic system that can scale beyond GSM to proprietary gateways and legacy telephony technologies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1BjpU4Cy2sDiSqg73nsvQ.png" /></figure><h3>Why a Hybrid Architecture?</h3><h3>The Problem</h3><p>Many VoIP deployments require:</p><ul><li>Integration with <strong>GSM networks</strong> (USB dongles, SIM-based gateways)</li><li>Advanced <strong>call routing logic</strong></li><li>Flexible <strong>user management</strong></li><li>Interoperability with <strong>softphones, WebRTC, and SIP devices</strong></li></ul><p>While both Asterisk and FreeSWITCH are mature and powerful platforms, they are optimized for different problem domains. Asterisk excels in hardware integration, offering robust support for GSM dongles, FXO/FXS interfaces, and legacy telephony technologies. FreeSWITCH, by contrast, is designed as a high-performance SIP core, optimized for advanced routing logic, scalability, and real-time call control. Attempting to rely on a single platform often introduces architectural compromises: complex routing logic can become difficult to maintain within Asterisk dialplans, while hardware integration and vendor-specific drivers remain challenging in FreeSWITCH. Combining the two allows each system to operate where it performs best, without forcing either beyond its natural strengths</p><p>Using either platform alone often leads to compromises:</p><ul><li>Complex routing logic inside Asterisk dialplans</li><li>Hardware integration difficulties in FreeSWITCH</li></ul><h3>Architectural Decision</h3><p>The system is intentionally split into two logical roles:</p><h3>Asterisk — The Hardware Bridge</h3><p>Asterisk is responsible for:</p><ul><li>Interfacing with <strong>USB GSM dongles</strong></li><li>Handling <strong>AT commands</strong>, serial ports, and radio specifics</li><li>Converting GSM calls into SIP calls</li></ul><h3>FreeSWITCH — The PBX Brain</h3><p>FreeSWITCH manages:</p><ul><li>SIP users (softphones such as MicroSIP)</li><li>Authentication and registration</li><li>Call routing rules</li><li>Inbound and outbound call policies</li></ul><p>The two systems communicate exclusively over <strong>SIP trunks</strong>.</p><h3>High-Level Call Flows</h3><h3>Outbound Calls (VoIP → GSM)</h3><ol><li>A SIP user registers with FreeSWITCH</li><li>The user dials an external number</li><li>FreeSWITCH routing logic matches the number</li><li>The call is bridged to Asterisk via a SIP gateway</li><li>Asterisk sends the call to the GSM dongle</li></ol><h3>Inbound Calls (GSM → VoIP)</h3><ol><li>A call arrives on the GSM SIM</li><li>Asterisk receives the call via the dongle driver</li><li>The call is forwarded to FreeSWITCH via SIP</li><li>FreeSWITCH routes the call to an internal user or IVR</li></ol><h3>Configuration Overview (By Responsibility)</h3><h3>Asterisk Configuration</h3><p><strong>Purpose:</strong> Accept SIP traffic from FreeSWITCH and interface with GSM hardware.</p><p>Key configuration files:</p><p><strong>pjsip.conf</strong><br> Defines the SIP endpoint representing FreeSWITCH (endpoint, auth, AOR).</p><pre>[global]<br>type=global<br>user_agent=Asterisk-GSM<br><br>[transport-udp]<br>type=transport<br>protocol=udp<br>bind=0.0.0.0:5070<br><br>; --- L&#39;AOR DEVE chiamarsi come lo username di FreeSWITCH ---<br>[fs]<br>type=aor<br>max_contacts=5<br>remove_existing=yes<br><br>[fs_auth]<br>type=auth<br>auth_type=userpass<br>username=fs<br>password=fssecret<br><br>[fs]<br>type=endpoint<br>context=from-freeswitch<br>;disallow=all<br>;allow=ulaw,alaw<br><br>allow=!all,alaw,ulaw<br><br>auth=fs_auth<br>outbound_auth=fs_auth<br>aors=fs<br>force_rport=yes<br>rtp_symmetric=yes<br>rewrite_contact=yes<br>direct_media=no<br><br>[fs_identify]<br>type=identify<br>endpoint=fs<br>match=127.0.0.1</pre><p><strong>dongle.conf</strong><br> Defines the GSM hardware:</p><ul><li>Serial interfaces (ttyUSB)</li><li>Gain levels</li><li>Incoming call context</li></ul><pre>[general]<br>interval=15<br><br>[defaults]<br>context=dongle-incoming<br>group=0<br><br>rxgain=1<br>txgain=-5<br><br>autodeletesms=yes<br>resetdongle=yes<br>u2diag=-1<br>usecallingpres=yes<br>callingpres=allowed_passed_screen<br>disablesms=no<br>language=en<br>smsaspdu=yes<br>mindtmfgap=45<br>mindtmfduration=80<br>mindtmfinterval=200<br>callwaiting=auto<br>disable=no<br>initstate=start<br>dtmf=relax<br><br>[dongle0]<br>audio=/dev/ttyUSB1<br>data=/dev/ttyUSB2<br>uimlimit=0<br>mindtmfgap=40<br>mindtmfduration=80<br>mindtmfinterval=200<br>resetinterval=100</pre><p><strong>extensions.conf</strong><br> Dialplan logic:</p><ul><li>Outbound: routes calls from FreeSWITCH to GSM</li><li>Inbound: forwards GSM calls to FreeSWITCH</li></ul><pre>[general]<br>static=yes<br>writeprotect=no<br><br>[from-freeswitch]<br>; Qui arrivano le chiamate che FreeSWITCH invia ad Asterisk per uscire su GSM<br>exten =&gt; _X.,1,NoOp(Chiamata in uscita da FreeSWITCH verso GSM: ${EXTEN})<br> same =&gt; n,Dial(Dongle/dongle0/${EXTEN},60)<br> same =&gt; n,Hangup()<br><br>[dongle-incoming]<br>; Chiamate vocali in arrivo dalla SIM Wind<br>exten =&gt; s,1,NoOp(Chiamata GSM in arrivo da ${CALLERID(num)})<br> ; Invia la chiamata a FreeSWITCH (interno 1001 o quello che preferisci)<br> same =&gt; n,Dial(PJSIP/${EXTEN}@fs,30)<br> same =&gt; n,Hangup()<br><br>; Gestione SMS in arrivo<br>exten =&gt; sms,1,NoOp(SMS da ${CALLERID(num)})<br> same =&gt; n,Set(SMS_BODY=${BASE64_DECODE(${SMS_BASE64})})<br> same =&gt; n,System(/usr/local/bin/sms_to_telegram.sh &quot;${CALLERID(num)}&quot; &quot;${SMS_BODY}&quot;)<br> same =&gt; n,Hangup()<br><br>; Esempio invio SMS manuale<br>exten =&gt; 888,1,NoOp(Invio SMS di test)<br> same =&gt; n,DongleSendSMS(dongle0,+391234567890,Test SMS da Asterisk)<br> same =&gt; n,Hangup()<br><br>[alert-calls]<br>exten =&gt; playalert,1,Answer()<br> same =&gt; n,Playback(allerta-batteria)<br> same =&gt; n,Hangup()</pre><p>Asterisk remains intentionally minimal in logic, acting as a <strong>media and protocol adapter</strong>.</p><h3>FreeSWITCH Configuration</h3><p><strong>Purpose:</strong> Act as the central PBX and routing engine.</p><p>Key configuration files:</p><p><strong>SIP Gateway Definition</strong><br> /etc/freeswitch/sip_profiles/external/</p><pre>&lt;include&gt;<br>    &lt;gateway name=&quot;asterisk-gsm&quot;&gt;<br>        &lt;param name=&quot;username&quot; value=&quot;fs&quot;/&gt;<br>        &lt;param name=&quot;password&quot; value=&quot;fssecret&quot;/&gt;<br>        &lt;param name=&quot;proxy&quot; value=&quot;192.168.21.152:5070&quot;/&gt;<br>        &lt;param name=&quot;register&quot; value=&quot;true&quot;/&gt;<br>        &lt;param name=&quot;codec-prefs&quot; value=&quot;PCMA&quot;/&gt;<br>        &lt;param name=&quot;codec-prefs&quot; value=&quot;PCMU&quot;/&gt;<br>        &lt;param name=&quot;extension-in-contact&quot; value=&quot;true&quot;/&gt;<br>        &lt;/gateway&gt;<br>&lt;/include&gt;</pre><p>Defines how FreeSWITCH connects to Asterisk (IP, port, credentials).</p><p><strong>User Directory</strong><br> /etc/freeswitch/directory/default/*.xml</p><pre>&lt;include&gt;<br>  &lt;user id=&quot;1001&quot;&gt;<br>    &lt;params&gt;<br>      &lt;param name=&quot;password&quot; value=&quot;password00&quot;/&gt;<br>    &lt;/params&gt;<br>    &lt;variables&gt;<br>      &lt;variable name=&quot;toll_allow&quot; value=&quot;domestic&quot;/&gt;<br>      &lt;variable name=&quot;accountcode&quot; value=&quot;1001&quot;/&gt;<br>      &lt;variable name=&quot;user_context&quot; value=&quot;default&quot;/&gt;<br>    &lt;/variables&gt;<br>  &lt;/user&gt;<br>&lt;/include&gt;</pre><p>Defines SIP users, credentials, and permissions.</p><p><strong>Dialplan (Outbound)</strong><br> /etc/freeswitch/dialplan/default/*.xml</p><pre>&lt;include&gt;<br>  &lt;extension name=&quot;outbound-gsm&quot;&gt;<br>    &lt;condition field=&quot;destination_number&quot; expression=&quot;^(\+?\d{6,15})$&quot;&gt;<br>      &lt;action application=&quot;bridge&quot; data=&quot;sofia/gateway/asterisk-gsm/$1&quot;/&gt;<br>    &lt;/condition&gt;<br>  &lt;/extension&gt;<br>&lt;/include&gt;</pre><p>Matches dialed numbers and bridges calls to the Asterisk gateway.</p><p><strong>Dialplan (Inbound)</strong><br> /etc/freeswitch/dialplan/public/*.xml</p><pre>&lt;include&gt;<br>  &lt;extension name=&quot;ring_all_10xx&quot;&gt;<br>    &lt;condition field=&quot;destination_number&quot; expression=&quot;^(s|tuo_numero_sim)$&quot;&gt;<br>      &lt;action application=&quot;set&quot; data=&quot;jitterbuffer_msec=60:120:20&quot;/&gt;<br>      &lt;action application=&quot;bridge&quot; data=&quot;user/1000,user/1001,user/1002&quot;/&gt;<br>    &lt;/condition&gt;<br>  &lt;/extension&gt;<br>&lt;/include&gt;<br> Receives external calls and forwards them to internal extensions.</pre><h3>Challenges Encountered</h3><h3>1. SIP Authentication and Realm Mismatch</h3><p>One of the most common issues was a failed PJSIP trunk configuration due to a mismatch:</p><ul><li>Digest realm</li><li>Username</li><li>Password</li></ul><p><strong>Resolution:</strong><br> Strict alignment of SIP credentials between FreeSWITCH gateways and Asterisk PJSIP auth sections.</p><h3>2. NAT and External IP Detection</h3><p>Incorrect NAT handling caused:</p><ul><li>One-way audio</li><li>Registration instability</li></ul><p><strong>Resolution:</strong></p><ul><li>Explicit NAT configuration</li><li>STUN-based external IP detection</li><li>Clear separation between internal and external SIP profiles</li></ul><h3>3. Overloading Asterisk Dialplan Logic</h3><p>Embedding complex routing logic inside Asterisk proved difficult to maintain.</p><p><strong>Resolution:</strong><br> Move all decision-making logic to FreeSWITCH, keeping Asterisk stateless and predictable.</p><h3>Advantages of This Design</h3><h3>Modular and Maintainable</h3><p>Each platform performs the task for which it is best suited. Configuration complexity is reduced rather than increased.</p><h3>Hardware Agnostic</h3><p>While GSM dongles were the initial requirement, the same model applies to:</p><ul><li>Proprietary GSM gateways</li><li>FXO/FXS cards</li><li>ISDN (PRI/BRI)</li><li>Vendor-specific telephony hardware</li></ul><p>Only the Asterisk “hardware layer” needs to change.</p><h3>Scalable and Future-Proof</h3><p>FreeSWITCH can later support:</p><ul><li>WebRTC</li><li>Secure SIP (TLS/WSS)</li><li>Call queues, IVR, conferencing</li><li>External APIs and event-driven logic</li></ul><p>Without modifying the hardware-facing layer.</p><h3>Clear Separation of Concerns</h3><p>One of the most significant benefits of this hybrid architecture is the strict separation of concerns between the two platforms. Asterisk is deliberately confined to the role of a hardware and protocol adapter, interacting directly with GSM dongles, proprietary gateways, and legacy telephony interfaces to handle low-level signaling, media conversion, and device-specific behavior. It does not make routing decisions, manage users, or implement business logic.</p><p>FreeSWITCH, on the other hand, operates as the central decision-making engine of the system. It is responsible for user registration, authentication, dialplan logic, call routing, and policy enforcement. FreeSWITCH treats Asterisk as an external SIP resource, abstracting away all hardware complexity and exposing a clean, consistent SIP interface to internal users and applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*gipMG2zPkvwpeOPjdh-NUQ.png" /><figcaption>MicroSIP VOIP Clienta basic config sample</figcaption></figure><p>This architectural boundary ensures that changes in hardware, vendor-specific technologies, or access networks do not require modifications to the core PBX logic. Conversely, changes in routing rules, user management, or service features can be implemented in FreeSWITCH without impacting the hardware layer. The result is a system that is easier to reason about, simpler to maintain, and significantly more resilient to future changes in technology or vendor constraints.</p><h3>Extending to Proprietary Technologies</h3><p>This architecture is not limited to GSM. Any technology that can be terminated by Asterisk can be exposed to FreeSWITCH via SIP, including:</p><ul><li>Vendor-locked GSM gateways</li><li>Legacy PBX systems</li><li>Radio or VoIP-to-serial bridges</li><li>Custom telephony appliances</li></ul><p>FreeSWITCH remains completely unaware of the underlying hardware specifics.</p><h3>Conclusion</h3><p>A hybrid FreeSWITCH–Asterisk architecture provides a clean, scalable, and professional solution for environments where <strong>hardware integration</strong> and <strong>advanced SIP logic</strong> must coexist.</p><p>By treating Asterisk as a <strong>telephony adapter</strong> and FreeSWITCH as the <strong>decision engine</strong>, the system gains:</p><ul><li>Flexibility</li><li>Reliability</li><li>Long-term maintainability</li></ul><p>This pattern is especially effective when dealing with GSM, legacy telephony, or proprietary technologies that do not natively integrate with modern SIP infrastructures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92e3f11403e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing Low-Resolution Surveillance Footage]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/enhancing-low-resolution-surveillance-footage-ff28724f6045?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff28724f6045</guid>
            <category><![CDATA[videosorveglianza]]></category>
            <category><![CDATA[forensics]]></category>
            <category><![CDATA[ffmpeg]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 08:17:35 GMT</pubDate>
            <atom:updated>2026-09-02T08:17:35.570Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Using FFmpeg Super-Resolution Models (ESPCN, EDSR, DPEDSR)</strong></p><p><em>Improving Evidence Quality Across Linux, macOS, and Windows</em></p><p>A colleague recently asked for a practical way to improve the resolution of footage captured by an older surveillance system after a burglary occurred in his apartment building. The available RTSP stream and archived MP4 files were limited to 640×480, producing insufficient detail for identification or forensic inspection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*wmFwLOxJZ4stYj7C00n1rQ.png" /></figure><p>This article presents a reproducible, cross-platform method for enhancing low-resolution video while maintaining evidentiary integrity, utilizing FFmpeg’s built-in super-resolution filters based on ESPCN, EDSR, and DPEDSR deep learning models. It also discusses container formats, codecs, security implications in video surveillance deployments, and the considerations relevant to forensic workflows.</p><p><strong>1. Understanding Formats, Codecs, and Containers in Surveillance Systems</strong></p><p>Surveillance systems commonly output video using a mixture of:</p><p><strong>Codecs</strong></p><p>A codec defines how the image data is compressed. Common ones include:</p><ul><li><strong>H.264 (AVC)</strong> — the most widely used; good quality/size balance</li><li><strong>H.265 (HEVC)</strong> — more efficient; often used on new NVRs</li><li><strong>MJPEG</strong> — frame-based, less efficient but easier to analyze frame-by-frame</li><li><strong>H.264 Baseline Profiles</strong> — common in low-power IP cameras</li></ul><p><strong>Containers</strong></p><p>A container stores video, audio, timestamps, and metadata. Key types:</p><ul><li><strong>MP4</strong> — most common; widely compatible</li><li><strong>MKV</strong> — robust, ideal for archival or forensic work</li><li><strong>MOV</strong> — useful in editing environments</li><li><strong>AVI</strong> — still used in older DVRs</li></ul><p>Surveillance systems tend to prioritize continuous recording over quality, often producing:</p><ul><li>Low bitrates</li><li>Low resolutions</li><li>High compression ratios</li><li>Missing metadata (creation time, camera identifiers, etc.)</li></ul><p>These limitations motivate the use of post-processing methods such as super-resolution.</p><p><strong>2. Security Considerations for IP Cameras and RTSP Streams</strong></p><p>Many installations expose RTSP endpoints in the form:</p><p>rtsp://admin:password@ip:554/onvif1</p><p>While technically convenient, embedding credentials in the stream URL has security implications:</p><ul><li><strong>Credentials often circulate in plaintext</strong>, visible in logs, browser histories, and third-party tools</li><li><strong>IP cameras commonly run outdated firmware</strong> with unpatched exploits</li><li><strong>RTSP streams are rarely encrypted</strong>, allowing sniffing on the local network</li><li><strong>Default ONVIF profiles</strong> may broadcast unnecessarily high privileges</li></ul><p>Organizations should consider:</p><ul><li>Enforcing <strong>unique, complex passwords</strong></li><li>Using <strong>segmented VLANs</strong> for surveillance networks</li><li>Enabling <strong>SRTP or TLS-wrapped RTSP</strong> (if supported)</li><li>Restricting ONVIF control endpoints</li><li>Hardening firmware and disabling unused services</li></ul><p>Proper hardening reduces the risk of video tampering — an important factor in the evidentiary chain of custody.</p><p><strong>3. Forensic-Grade Video Enhancement: Principles and Caveats</strong></p><p>In forensic video analysis, enhancement must respect the following principles:</p><ul><li><strong>Non-destructive processing</strong></li><li><strong>Repeatability and reproducibility</strong></li><li><strong>Documented parameters</strong></li><li><strong>Preservation of original evidence</strong> (read-only storage, hashing)</li></ul><p>Super-resolution does not “invent” evidence but improves visual clarity by reconstructing plausible details using machine learning models. This can assist investigators, but must be accompanied by:</p><ul><li>Disclosure of algorithms and parameters used</li><li>Acknowledgement that enhanced frames are derived, not original</li><li>Retention of the source video</li><li>Metadata preservation, where possible</li></ul><p>With proper documentation, SR-enhanced footage can serve as an analytical aid without compromising evidentiary integrity.</p><p><strong>4. Deep-Learning Super-Resolution with FFmpeg (ESPCN, EDSR, DPEDSR)</strong></p><p>FFmpeg includes several efficient CPU-based SR models:</p><ul><li><strong>ESPCN</strong> — fastest; good for real-time enhancement</li><li><strong>EDSR</strong> — higher quality; widely used in research</li><li><strong>DPEDSR</strong> — trained on phone-camera datasets; often produces the most natural reconstruction</li></ul><p>These models can upscale by factors of 2×, 3×, or 4×, depending on the input resolution.</p><p>Given a 640×480 source, a 2× upscale produces 1280×960 with improved detail retention.</p><p><strong>5. Automatic Noise Detection and Conditional Denoising</strong></p><p>Low-resolution surveillance footage typically exhibits:</p><ul><li>Temporal noise</li><li>Low-bitrate macroblock artifacts</li><li>Chroma smearing</li><li>Motion noise in low light</li></ul><p>To minimize over-processing, noise reduction should be <strong>adaptive</strong>, applying denoising only when bitrates suggest a significant loss of quality. The hqdn3d filter offers a good balance between clarity and preservation of fine detail.</p><p><strong>6. Cross-Platform Scripts: Linux/macOS, and Windows</strong></p><p>The following scripts provide:</p><ul><li>Automatic analysis of FPS, bitrate, and resolution</li><li>Selection of SR model (ESPCN, EDSR, DPEDSR)</li><li>Choice of output container (MP4, MKV, MOV)</li><li>HEVC encoding (libx265)</li><li>Conditional denoising based on source bitrate</li></ul><p>Both versions follow the same logic; only platform-specific differences are addressed.</p><p><strong>6.1 Linux/OSX Version (Bash)</strong></p><pre>#!/usr/bin/env bash<br><br># --- CONFIG ---<br>MODEL_DIR=&quot;./models&quot;<br>mkdir -p &quot;$MODEL_DIR&quot;<br><br>ESPCN_URL=&quot;https://your.trained.model.url/espcn_x2.onnx&quot;<br>EDSR_URL=&quot;https://your.trained.model.url/edsr_x2.onnx&quot;<br>DPED_URL=&quot;https://your.trained.model.url/dped_x2.onnx&quot;<br><br># --- CHECK INPUT ---<br>if [ -z &quot;$1&quot; ]; then<br>    echo &quot;Usage: $0 input.mp4&quot;<br>    exit 1<br>fi<br><br>INPUT=&quot;$1&quot;<br><br>if [ ! -f &quot;$INPUT&quot; ]; then<br>    echo &quot;Input file not found!&quot;<br>    exit 1<br>fi<br><br>echo &quot;----------------------------------&quot;<br>echo &quot;   ANALISI VIDEO&quot;<br>echo &quot;----------------------------------&quot;<br><br>RES=$(ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height -of csv=p=0 &quot;$INPUT&quot;)<br>FPS=$(ffprobe -v quiet -select_streams v:0 -show_entries stream=r_frame_rate -of csv=p=0 &quot;$INPUT&quot; | awk -F/ &#39;{printf &quot;%.2f&quot;, $1/$2}&#39;)<br>BR=$(ffprobe -v quiet -select_format -show_entries format=bit_rate -of csv=p=0 &quot;$INPUT&quot;)<br><br>WIDTH=$(echo $RES | cut -d&#39;,&#39; -f1)<br>HEIGHT=$(echo $RES | cut -d&#39;,&#39; -f2)<br>BITRATE=$(printf &quot;%.0f\n&quot; $((BR/1000)))<br><br>echo &quot;Risoluzione:  ${WIDTH}x${HEIGHT}&quot;<br>echo &quot;FPS:          $FPS&quot;<br>echo &quot;Bitrate:      $BITRATE Kbps&quot;<br>echo<br><br># --- MODEL SELECTION ---<br>echo &quot;Scegli modello super-resolution:&quot;<br>echo &quot;1) espcn  (più veloce)&quot;<br>echo &quot;2) edsr   (migliore qualità)&quot;<br>echo &quot;3) dpedsr (massima qualità)&quot;<br>read -p &quot;Scelta: &quot; M<br><br>case $M in<br>    1) MODEL_NAME=&quot;espcn_x2.onnx&quot;; MODEL_URL=&quot;$ESPCN_URL&quot; ;;<br>    2) MODEL_NAME=&quot;edsr_x2.onnx&quot;; MODEL_URL=&quot;$EDSR_URL&quot; ;;<br>    3) MODEL_NAME=&quot;dped_x2.onnx&quot;; MODEL_URL=&quot;$DPED_URL&quot; ;;<br>    *) echo &quot;Scelta non valida&quot;; exit 1 ;;<br>esac<br><br>MODEL_PATH=&quot;$MODEL_DIR/$MODEL_NAME&quot;<br><br># --- DOWNLOAD MODEL IF MISSING ---<br>if [ ! -f &quot;$MODEL_PATH&quot; ]; then<br>    echo &quot;Scarico modello $MODEL_NAME ...&quot;<br>    curl -L &quot;$MODEL_URL&quot; -o &quot;$MODEL_PATH&quot;<br>fi<br><br># --- OUTPUT FORMAT ---<br>echo<br>echo &quot;Scegli contenitore di output:&quot;<br>echo &quot;1) MP4&quot;<br>echo &quot;2) MKV&quot;<br>echo &quot;3) MOV&quot;<br>read -p &quot;Scelta: &quot; C<br><br>case $C in<br>    1) EXT=&quot;mp4&quot; ;;<br>    2) EXT=&quot;mkv&quot; ;;<br>    3) EXT=&quot;mov&quot; ;;<br>    *) echo &quot;Scelta non valida&quot;; exit 1 ;;<br>esac<br><br># --- NOISE EVALUATION ---<br>FILTERS=&quot;&quot;<br>if [ &quot;$BITRATE&quot; -lt 500 ]; then<br>    echo &quot;→ Bitrate basso: applico denoise leggero&quot;<br>    FILTERS=&quot;hqdn3d=1.5:1.5:6:6,&quot;<br>fi<br><br>SR_FILTER=&quot;sr=dnn_backend=onnx:model=$MODEL_PATH&quot;<br>FILTERS=&quot;${FILTERS}${SR_FILTER}&quot;<br><br>OUTPUT=&quot;output_${MODEL_NAME%.*}.$EXT&quot;<br><br>echo<br>echo &quot;----------------------------------&quot;<br>echo &quot;   CODIFICA CON SUPER-RESOLUTION&quot;<br>echo &quot;----------------------------------&quot;<br>echo &quot;Eseguo:&quot;<br>echo ffmpeg -y -i &quot;$INPUT&quot; -vf &quot;$FILTERS&quot; -c:v libx265 -preset slow -x265-params crf=18 -c:a copy &quot;$OUTPUT&quot;<br>echo<br><br>ffmpeg -y -i &quot;$INPUT&quot; -vf &quot;$FILTERS&quot; -c:v libx265 -preset slow -x265-params crf=18 -c:a copy &quot;$OUTPUT&quot;</pre><p><strong>6.2 Windows Version (PowerShell)</strong></p><pre>param(<br>    [Parameter(Mandatory=$true)]<br>    [string]$Input<br>)<br><br>$ModelDir = &quot;models&quot;<br>New-Item -ItemType Directory -Force -Path $ModelDir | Out-Null<br><br>$ESPCN_URL = &quot;https://your.trained.model.url/espcn_x2.onnx&quot;<br>$EDSR_URL  = &quot;https://your.trained.model.url/edsr_x2.onnx&quot;<br>$DPED_URL  = &quot;https://your.trained.model.url/dped_x2.onnx&quot;<br><br>if (!(Test-Path $Input)) {<br>    Write-Host &quot;Input file missing!&quot;<br>    exit<br>}<br><br>Write-Host &quot;----------------------------------&quot;<br>Write-Host &quot;   ANALISI VIDEO&quot;<br>Write-Host &quot;----------------------------------&quot;<br><br>$Probe = ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height,r_frame_rate -of json $Input | ConvertFrom-Json<br><br>$Width  = $Probe.streams[0].width<br>$Height = $Probe.streams[0].height<br>$Rate   = $Probe.streams[0].r_frame_rate<br>$FPS    = [double]($Rate.Split(&quot;/&quot;)[0]) / [double]($Rate.Split(&quot;/&quot;)[1])<br><br>$Bitrate = ffprobe -v quiet -select_format -show_entries format=bit_rate -of csv=p=0 $Input<br>$BitrateKbps = [math]::Round($Bitrate / 1000)<br><br>Write-Host &quot;Risoluzione:&quot; $Width&quot;x&quot;$Height<br>Write-Host &quot;FPS:        &quot; $FPS<br>Write-Host &quot;Bitrate:    &quot; $BitrateKbps &quot;Kbps&quot;<br><br>Write-Host &quot;`nScegli modello:&quot;<br>Write-Host &quot;1) espcn&quot;<br>Write-Host &quot;2) edsr&quot;<br>Write-Host &quot;3) dpedsr&quot;<br>$Choice = Read-Host &quot;Scelta&quot;<br><br>switch ($Choice) {<br>    &quot;1&quot; { $ModelName=&quot;espcn_x2.onnx&quot;; $ModelURL=$ESPCN_URL }<br>    &quot;2&quot; { $ModelName=&quot;edsr_x2.onnx&quot;;  $ModelURL=$EDSR_URL  }<br>    &quot;3&quot; { $ModelName=&quot;dped_x2.onnx&quot;;  $ModelURL=$DPED_URL  }<br>    default { Write-Host &quot;Invalid&quot;; exit }<br>}<br><br>$ModelPath = &quot;$ModelDir\$ModelName&quot;<br><br>if (!(Test-Path $ModelPath)) {<br>    Write-Host &quot;Scarico modello...&quot;<br>    Invoke-WebRequest -Uri $ModelURL -OutFile $ModelPath<br>}<br><br>Write-Host &quot;`nScegli formato:&quot;<br>Write-Host &quot;1) MP4&quot;<br>Write-Host &quot;2) MKV&quot;<br>Write-Host &quot;3) MOV&quot;<br>$C = Read-Host &quot;Scelta&quot;<br><br>switch ($C) {<br>    &quot;1&quot; { $Ext=&quot;mp4&quot; }<br>    &quot;2&quot; { $Ext=&quot;mkv&quot; }<br>    &quot;3&quot; { $Ext=&quot;mov&quot; }<br>    default { Write-Host &quot;Invalid&quot;; exit 1 }<br>}<br><br># Noise evaluation<br>if ($BitrateKbps -lt 500) {<br>    Write-Host &quot;→ Bitrate basso: denoise attivo&quot;<br>    $Filters = &quot;hqdn3d=1.5:1.5:6:6,&quot;<br>} else {<br>    $Filters = &quot;&quot;<br>}<br><br>$Filters += &quot;sr=dnn_backend=onnx:model=$ModelPath&quot;<br>$Output = &quot;output_$($ModelName.Replace(&#39;.onnx&#39;,&#39;&#39;)).$Ext&quot;<br><br>Write-Host &quot;`n----------------------------------&quot;<br>Write-Host &quot;   CODIFICA CON SUPER-RESOLUTION&quot;<br>Write-Host &quot;----------------------------------&quot;<br><br>$cmd = &quot;ffmpeg -y -i `&quot;$Input`&quot; -vf `&quot;$Filters`&quot; -c:v libx265 -preset slow -x265-params crf=18 -c:a copy `&quot;$Output`&quot;&quot;<br>Write-Host $cmd<br><br>iex $cmd</pre><p><strong>7. Practical Results</strong></p><p>When applied to legacy 640×480 footage:</p><ul><li>ESPCN provides fast, noticeable clarity improvements</li><li>EDSR and DPEDSR deliver higher fidelity reconstructions</li><li>Conditional denoising reduces compression noise without altering essential details</li><li>HEVC output improves archival size efficiency</li><li>MKV is generally recommended for forensic workflows due to robust metadata handling</li></ul><p>While super-resolution cannot recreate detail that the camera never captured, it significantly increases the legibility of:</p><ul><li>Faces (to a limited extent and with forensic caution)</li><li>License plates</li><li>Clothing textures</li><li>Object contours</li><li>Motion paths</li></ul><p>These enhancements aid human review and automated analysis.</p><p>The approach documented here provides a reproducible, platform-independent method to enhance low-resolution surveillance video using FFmpeg’s integrated SR models. It aligns with forensic analysis practices when applied non-destructively and with proper documentation.</p><p>In scenarios where legacy IP cameras or constrained NVRs produce insufficient image quality, this method provides a practical and secure way to maximize evidentiary usefulness without relying on external cloud-based AI services — an important consideration for maintaining privacy and ensuring chain-of-custody integrity.</p><p><strong>8. Chain-of-Custody Checklists for Video Evidence</strong></p><p>When dealing with surveillance footage after an incident, maintaining a verifiable chain of custody is essential. The objective is to ensure that the evidence is demonstrably unaltered from acquisition through analysis, and that any derivative work is clearly identified as such.</p><p>A standard chain-of-custody workflow for digital video evidence includes:</p><p><strong>Acquisition</strong></p><ul><li>Record the date, time, and person collecting the footage</li><li>Document the source device (IP camera, DVR/NVR model, location)</li><li>Note the method used for extraction (USB export, RTSP capture, NVR download)</li><li>Capture system metadata (camera serial number, firmware version, time settings)</li></ul><p><strong>Integrity Verification</strong></p><ul><li>Compute cryptographic hashes (SHA-256 or stronger) of:</li><li>Raw container file (e.g., .mp4, .avi, proprietary DVR format)</li><li>Associated metadata files</li><li>Store hashes in a tamper-evident log or evidence management system</li></ul><p><strong>Storage</strong></p><ul><li>Retain raw evidence on read-only media or WORM storage</li><li>Maintain redundant copies in secure locations</li><li>Do not modify the original files during analysis</li></ul><p><strong>Analysis</strong></p><ul><li>Conduct all video enhancement (including super-resolution) on <strong>derivative copies</strong></li><li>Document:</li><li>Software versions</li><li>Filters or models used</li><li>Parameters and settings</li><li>Output file hashes</li><li>Label enhanced outputs as <strong>“analytical/derivative material.”</strong></li></ul><p><strong>Transfer and Reporting</strong></p><ul><li>Every hand-off must be recorded with:</li><li>Date/time</li><li>Recipient</li><li>Purpose</li><li>Storage location</li></ul><p>This documentation ensures the footage remains admissible and defensible in legal or investigative contexts.</p><p><strong>9. Hashing (SHA-256) for Evidentiary Preservation</strong></p><p>Cryptographic hashing guarantees that a file has not been modified. SHA-256 is preferred because it is collision-resistant and widely supported in forensic tools.</p><p><strong>Linux / macOS</strong></p><pre>shasum -a 256 evidence.mp4 &gt; evidence.sha256</pre><p><strong>Windows (PowerShell)</strong></p><pre>Get-FileHash evidence.mp4 -Algorithm SHA256 | Out-File evidence.sha256</pre><p>Best practices:</p><ul><li>Hash files <em>immediately upon acquisition</em></li><li>Store hashes in:</li><li>A printed, signed document</li><li>A secure digital log</li><li>A forensic evidence management system</li><li>Recalculate the hash before and after transfers</li><li>Hash both the <strong>original file</strong> and all <strong>derived outputs</strong></li></ul><p>This procedure is critical for demonstrating non-modification and establishing trustworthiness.</p><p><strong>10. Integration with ONVIF Device Management</strong></p><p>Many modern IP cameras expose management capabilities through <strong>ONVIF</strong>, allowing standardized interactions for:</p><ul><li>Querying device configuration</li><li>Obtaining capabilities (resolution, frame rate, supported profiles)</li><li>Pulling RTSP URLs</li><li>Adjusting encoding settings</li><li>Synchronizing time (crucial for incident correlation)</li></ul><p>Tools such as <strong>ONVIF Device Manager</strong> (Windows) and onvif-cli (Linux) can:</p><ul><li>Enumerate camera streams</li><li>Fetch device metadata (serial, firmware version)</li><li>Test user privileges</li><li>Export configuration snapshots</li></ul><p><strong>Why ONVIF matters in forensic workflows</strong></p><ul><li>It provides <strong>vendor-independent</strong> ways to retrieve configuration evidence</li><li>It ensures that <strong>time synchronization</strong> (NTP) is documented</li><li>It helps verify whether the camera’s settings were altered prior to an incident</li><li>It enables reproducible extraction of the same stream profile in future investigations</li></ul><p>Proper ONVIF documentation is often overlooked but can be crucial for evidentiary continuity.</p><p><strong>11. Automating Batch Enhancements from NVR Exports</strong></p><p>Surveillance systems frequently export footage:</p><ul><li>In multiple segmented files (e.g., 1-minute MP4 chunks)</li><li>With inconsistent naming</li><li>From multiple cameras simultaneously</li></ul><p>Automating batch enhancement improves processing efficiency and reproducibility.</p><p><strong>Linux/macOS example (batch super-resolution)</strong></p><pre>#!/bin/bash<br>mkdir -p enhanced<br>for f in *.mp4; do<br>base=$(basename &quot;$f&quot;)<br>ffmpeg -y -i &quot;$f&quot; \<br>-vf &quot;sr=edsr&quot; \<br>-c:v libx265 -preset slow -x265-params crf=18 \<br>-c:a copy \<br>&quot;enhanced/$base&quot;<br>done</pre><p><strong>Windows PowerShell example</strong></p><pre>New-Item -ItemType Directory -Force -Path enhanced | Out-Null<br>foreach ($file in Get-ChildItem *.mp4) {<br>$out = &quot;enhanced\$($file.Name)&quot;<br>ffmpeg -y -i $file.FullName `<br>-vf &quot;sr=edsr&quot; `<br>-c:v libx265 -preset slow -x265-params crf=18 `<br>-c:a copy `<br>$out<br>}</pre><p><strong>Recommended batch-processing practices</strong></p><ul><li>Hash original files before processing</li><li>Use consistent naming conventions (camera ID, timestamp, location)</li><li>Log all processing steps automatically</li><li>Store enhanced output separately from raw evidence</li><li>Maintain a manifest listing:</li><li>Input file hash</li><li>Output file hash</li><li>Filters used</li></ul><p>Such automation is invaluable when dealing with dozens or hundreds of clips exported from multi-camera NVR systems.</p><p><strong>Conclusion</strong></p><p>Super-resolution enhancement, when supported by proper chain-of-custody procedures, hashing, ONVIF-based metadata acquisition, and batch automation, forms a cohesive and defensible workflow for improving the legibility of surveillance footage after security incidents. While enhancement cannot replace high-quality acquisition, it significantly strengthens post-incident analysis capabilities, ensuring that the resulting material is suitable for both investigative use and potential legal proceedings.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff28724f6045" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future-Proofing Digital Evidence: Modernizing Legacy Forensic TIFF Archives into Searchable PDF…]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/future-proofing-digital-evidence-modernizing-legacy-forensic-tiff-archives-into-searchable-pdf-eb02e7e15762?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb02e7e15762</guid>
            <category><![CDATA[forensics]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[tiff]]></category>
            <category><![CDATA[searchable-pdf]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 06:29:52 GMT</pubDate>
            <atom:updated>2026-08-03T06:29:52.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>Future-Proofing Digital Evidence: Modernizing Legacy Forensic TIFF Archives into Searchable PDF Collections</h3><p><em>Digital forensics is often associated with cutting-edge technology, but many investigations still depend on storage media created twenty years ago. Ironically, the greatest challenge is no longer preserving digital evidence — it is preserving its accessibility.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sAqBxkk28WMzEEKYKVLZtw.png" /></figure><h3>The Problem Was Never TIFF</h3><p>Every digital forensic practitioner eventually encounters the same scenario.</p><p>A CD-ROM, DVD, or ISO image arrives as part of a legal proceeding. Inside, everything appears perfectly organized:</p><ul><li>thousands of TIFF images;</li><li>an HTML index;</li><li>a JavaScript-based viewer;</li><li>a small collection of graphical assets;</li><li>sometimes an autorun.inf file designed for Windows XP.</li></ul><p>At the time these archives were generated, this structure made perfect sense. TIFF was the preferred archival format, browsers executed the embedded JavaScript without hesitation, and operating systems automatically launched the forensic index.</p><p>Twenty years later, the situation is very different.</p><p>Modern operating systems ignore autorun mechanisms, browsers have evolved, Internet Explorer has disappeared, and what once represented a convenient investigation package has slowly become an archaeological artifact.</p><p>The evidence itself is still perfectly preserved. The way we access it is not.</p><h3>The Initial Assumption</h3><p>The first instinct is almost always the simplest one.</p><p>Convert every TIFF image into a searchable PDF using OCR.</p><p>Problem solved, or so it seems.</p><p>Very quickly, however, another issue emerges.</p><p>The HTML interface still references the original TIFF files.</p><p>The navigation structure still expects raster images.</p><p>The JavaScript viewer still loads documents through parameters specifically designed for TIFF rendering.</p><p>The archive is now internally inconsistent.</p><p>Replacing images alone does not modernize an archive.</p><p>It merely breaks it.</p><h3>Understanding the Real Problem</h3><p>At this point the focus shifts.</p><p>The objective is no longer image conversion. It becomes <strong>digital archive migration</strong>.</p><p>The goal is preserving the user experience while modernizing the underlying document format. This changes the entire architecture of the solution.</p><p>Instead of thinking in terms of file conversion, the workflow becomes an archive transformation pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHl9kYuE_j6gaRCbr8_LQQ.png" /></figure><p>Notice something important.</p><p>The original documents are never modified.</p><p>A new consultation layer is created while the original evidence remains untouched.</p><p>That distinction matters in forensic environments.</p><h3>Surprisingly, Reading ISO Images Was the Hardest Part</h3><p>One of the most unexpected discoveries involved ISO images.</p><p>Initially, using a Python library to read ISO9660 seemed like the obvious approach.</p><p>After all, parsing an ISO file should be straightforward.</p><p>Reality proved otherwise.</p><p>Modern ISO images may simultaneously contain several filesystem extensions:</p><ul><li>ISO9660</li><li>Joliet</li><li>Rock Ridge</li><li>UDF</li></ul><p>Different operating systems expose these structures differently.</p><p>Windows generally favors Joliet.</p><p>Linux often prioritizes Rock Ridge.</p><p>Other environments may expose UDF metadata.</p><p>Trying to manually interpret every possible variation quickly becomes fragile.</p><p>The most robust solution turned out to be remarkably simple.</p><p>Don’t interpret the ISO.</p><p>Let the operating system do it.</p><p>Instead of parsing filesystem structures directly, mount the image using native operating system capabilities, copy the files exactly as the platform exposes them, and only fall back to library-based extraction when mounting is impossible.</p><p>The resulting algorithm is significantly more resilient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6bFfmDQzDTvO3No_7hnAYQ.png" /></figure><p>Sometimes the most reliable software is the one that delegates responsibility to components specifically designed for the task.</p><h3>Thinking in Workflows Instead of Code</h3><p>The implementation language is almost irrelevant.</p><p>The interesting part is the workflow itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fEn1RvmeraP1sZpKjxBRXQ.png" /></figure><p>This is not an OCR project.</p><p>It is a controlled migration process.</p><h3>Why Searchable PDF Instead of TIFF?</h3><p>TIFF remains one of the best raster image formats ever created.</p><p>It supports lossless compression, preserves image fidelity, and has become a de facto archival standard across libraries, museums, and forensic laboratories.</p><p>Its weakness is usability.</p><p>A scanned TIFF is still just an image.</p><p>A searchable PDF adds an invisible text layer generated through OCR while preserving the visual representation of the original page.</p><p>The practical consequences are significant.</p><p>Instead of scrolling through hundreds of scanned pages, investigators can instantly search for:</p><ul><li>names;</li><li>addresses;</li><li>tax identification numbers;</li><li>phone numbers;</li><li>email addresses;</li><li>invoice references;</li><li>dates.</li></ul><p>The archive becomes queryable without altering the visual evidence.</p><h3>Preserving the Original Chain of Custody</h3><p>One important distinction must always be maintained.</p><p>The generated PDF is <strong>not</strong> the original evidence.</p><p>The TIFF image remains the evidentiary master.</p><p>The searchable PDF is a derivative intended exclusively to improve consultation and accessibility.</p><p>This distinction should never become blurred.</p><p>Every transformation must therefore be documented.</p><p>A recommended validation workflow looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MP3Cl6jLQialxnWe6Kdlww.png" /></figure><p>Notice that cryptographic hashing — not encryption — is the appropriate mechanism here.</p><p>Encryption algorithms such as AES protect confidentiality.</p><p>Legal validation requires integrity verification.</p><p>For that purpose, SHA-256 or SHA-512 are considerably more appropriate.</p><p>Even better is combining cryptographic hashes with qualified digital signatures and trusted timestamps, creating a verifiable transformation history suitable for legal proceedings.</p><h3>Does TIFF Still Have a Place?</h3><p>Absolutely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*NP-KEGui10C_OnafqbeUSA.png" /></figure><p>This project did not convince me that TIFF is obsolete.</p><p>Quite the opposite.</p><p>TIFF continues to be one of the best formats for preserving raster images without introducing compression artifacts or rendering ambiguities.</p><p>What has become obsolete is using TIFF as the primary consultation format.</p><p>There is an important difference between <strong>preservation</strong> and <strong>accessibility</strong>.</p><p>The original forensic acquisition should remain exactly as it was produced.</p><p>The searchable PDF simply becomes a modern access layer.</p><p>This mirrors what many digital preservation institutions already do.</p><p>The archival master is preserved.</p><p>Derivative formats are generated for everyday use.</p><p>Digital forensics can adopt the same philosophy without compromising evidentiary integrity.</p><h3>Lessons Learned</h3><p>The most interesting realization throughout this project was that technology itself was never the primary challenge.</p><p>OCR is a solved problem.</p><p>PDF generation is straightforward.</p><p>Even ISO creation is well understood.</p><p>The difficult part was respecting the original archive while making it usable on modern systems.</p><p>Legacy forensic media are not becoming unreadable because TIFF is a poor format.</p><p>They are becoming difficult to use because the surrounding software ecosystem has disappeared.</p><p>Modernizing these collections is therefore not an exercise in replacing file formats.</p><p>It is an exercise in digital preservation.</p><p>The objective is not to rewrite history.</p><p>It is to ensure that twenty years from now investigators will still be able to search, browse, and understand evidence produced today — without needing a virtual machine running Windows XP.</p><h3>Final Thoughts</h3><p>Digital evidence has a unique characteristic: its value often increases over time. Cold cases are reopened, civil disputes resurface years later, and archived investigations are revisited with new analytical techniques. Preserving the bits is only half the challenge. Preserving the ability to <em>use</em> those bits is equally important.</p><p>By treating legacy forensic archives as preservation projects rather than simple file conversions, we can build workflows that respect evidentiary integrity while embracing modern accessibility. TIFF does not need to disappear. It simply needs a companion: a searchable, standards-based PDF layer, backed by cryptographic hashes, signed manifests, and a documented transformation process.</p><p>In the end, the real goal is not modernization for its own sake.</p><p>It is ensuring that digital evidence remains both authentic <strong>and</strong> accessible, regardless of how much the surrounding technology changes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb02e7e15762" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From USB Debugging to AirPlay: A Journey Through Smartphone Screen Sharing on the Desktop]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/from-usb-debugging-to-airplay-a-journey-through-smartphone-screen-sharing-on-the-desktop-904e592d8168?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/904e592d8168</guid>
            <category><![CDATA[uxplay]]></category>
            <category><![CDATA[desktop-sharing]]></category>
            <category><![CDATA[smart-connect]]></category>
            <category><![CDATA[airplay]]></category>
            <category><![CDATA[scrcpy]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Wed, 01 Jul 2026 13:39:52 GMT</pubDate>
            <atom:updated>2026-07-01T13:39:52.190Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sometimes the Smallest Window Tells the Biggest Story</h3><p>Many technical professionals eventually face the same challenge.</p><p>A VPN is being activated on a smartphone. A remote server is generating logs. Network routes are changing. Authentication flows are being established. Somewhere in the middle of all this, someone needs to explain what is happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5sJv4Eq2mE98wnLSmHwFTA.png" /></figure><p>Showing only the phone is not enough. Showing only the server logs is not enough either. The real story lives in the relationship between the two.</p><p>This realization often marks the beginning of an interesting learning journey: discovering how to bring a smartphone screen into a desktop environment and make it part of a broader technical narrative.</p><p>What initially appears to be a simple screen mirroring problem quickly becomes an exploration of protocols, operating systems, video encoding, networking, and user experience design.</p><h3>The First Lesson: A Smartphone Is Not Just a Display</h3><p>At first glance, displaying a phone on a computer seems straightforward.</p><p>The expectation is simple:</p><pre>+----------------------+----------------------+<br>|                      |                      |<br>|     Smartphone       |      SSH Session     |<br>|                      |                      |<br>|                      |  Logs, Routes, VPN   |<br>|                      |                      |<br>+----------------------+----------------------+</pre><p>Yet achieving this setup efficiently requires much more than copying pixels from one screen to another.</p><p>Every modern solution follows the same fundamental pipeline:</p><ol><li>Capture the device display.</li><li>Encode the video stream.</li><li>Transport the stream.</li><li>Decode and render it on the desktop.</li></ol><p>The differences emerge in how each platform implements these stages.</p><h3>Discovering scrcpy: The Developer’s Perspective</h3><p>For many engineers, developers, and system administrators, the journey begins with scrcpy.</p><p>The project has become one of the most respected open-source tools in the Android ecosystem because it approaches screen sharing from a completely different angle than traditional mirroring applications.</p><p>Rather than repeatedly capturing screenshots, scrcpy leverages Android’s native video encoding infrastructure.</p><p>Its architecture looks remarkably elegant:</p><pre>Android Display<br>       │       <br> MediaCodec<br>(H.264 / H.265)<br>       │<br> ADB Transport<br> USB or TCP/IP<br>       │       <br> scrcpy Client<br>       │       <br> Desktop Window</pre><p>This is often the moment when a deeper understanding emerges.</p><p>The desktop is not receiving images.</p><p>It is receiving a compressed video stream generated directly by the smartphone’s hardware encoder.</p><p>The same technologies used for video recording and streaming are being repurposed to create a responsive desktop experience.</p><p>The result is impressive: low latency, excellent quality, and surprisingly efficient resource consumption.</p><h3>Why USB Still Matters</h3><p>In an era dominated by wireless technologies, it is tempting to assume that cables belong to the past. Experience often teaches otherwise.</p><p>When recording demonstrations involving networking, VPNs, infrastructure, or cybersecurity workflows, reliability becomes more important than convenience.</p><p>With scrcpy over USB, the architecture remains beautifully simple:</p><pre>Android<br>   │<br>MediaCodec<br>   │<br>ADB over USB<br>   │<br>scrcpy<br>   │<br>Desktop</pre><p>The video stream never depends on Wi-Fi quality. It remains unaffected by network congestion. Most importantly, it continues working even when aggressive VPN policies are enabled on the device.</p><p>Many practitioners discover that the oldest connection method often provides the most predictable results.</p><h3>The Wireless Evolution</h3><p>Eventually, curiosity leads to wireless operation. Modern versions of scrcpy make this transition almost effortless. Interestingly, very little changes architecturally. The encoding process remains identical.</p><p>The rendering process remains identical. Only the transport layer evolves.</p><pre>Android<br>   │<br>MediaCodec<br>   │<br>ADB over TCP/IP<br>   │<br>Wi-Fi<br>   │<br>scrcpy<br>   │<br>Desktop</pre><p>This lesson is subtle but important. The challenge is no longer video processing. The challenge becomes networking.</p><p>Signal quality, access point placement, bandwidth availability, and local network design suddenly become part of the user experience.</p><p>The software has not changed. The environment has.</p><h3>Moving Beyond Developer Tools</h3><p>As understanding grows, another realization appears.</p><p>Not everyone wants to think about ADB, debugging interfaces, or transport protocols. Many users simply want their phone to appear on their computer.</p><p>This is where solutions such as Smart Connect enter the picture.</p><p>Rather than exposing technical mechanisms, Smart Connect focuses on continuity between devices. The architecture is conceptually similar:</p><pre>Android<br>    │<br>Smart Connect Service<br>    │<br>Device Discovery<br>    │<br>Wi-Fi / LAN<br>    │<br>Desktop Client<br>    │<br>Desktop Window</pre><p>The same building blocks still exist:</p><ul><li>screen capture;</li><li>hardware encoding;</li><li>network transport;</li><li>desktop rendering.</li></ul><p>The difference lies in abstraction.</p><p>The complexity disappears behind a user experience designed to feel effortless.</p><p>What developers view as protocols and services becomes, for end users, a simple window on the desktop.</p><h3>Learning That Apple Solves the Same Problem Differently</h3><p>The next stage of the journey often begins with an iPhone.</p><p>The first surprise is that the Android approach simply does not apply.</p><p>There is no ADB. There is no USB debugging workflow.</p><p>There is no equivalent to scrcpy. Instead, Apple built its own ecosystem around AirPlay. At first, AirPlay may appear to be just another screen sharing technology.</p><p>A closer look reveals a carefully designed architecture focused on seamless device discovery and media streaming.</p><pre>iPhone<br>   │<br> AirPlay<br>   │<br> Wi-Fi<br>   │<br> Receiver<br>   │<br> Desktop Window</pre><p>Unlike Android’s developer-centric solutions, AirPlay was designed from the beginning as a consumer-facing technology.</p><p>The complexity is almost entirely hidden. Users interact with a single button: Screen Mirroring. Everything else happens behind the scenes.</p><h3>Turning Windows into an Apple TV</h3><p>One of the most interesting discoveries comes when trying to mirror an iPhone to a Windows PC.</p><p>Apple’s ecosystem naturally favors Apple TV and macOS devices.</p><p>Yet open-source communities have a long history of filling gaps.</p><p>This is where UxPlay becomes fascinating.</p><p>Rather than modifying the iPhone, UxPlay transforms the PC.</p><p>The Windows machine effectively pretends to be an Apple TV.</p><pre>iPhone<br>    │<br> AirPlay<br>    │<br> Wi-Fi<br>    │<br> UxPlay<br>    │<br> Video Renderer<br>    │<br> Desktop Window</pre><p>From the iPhone’s perspective, nothing unusual is happening.</p><p>It simply discovers a compatible AirPlay receiver and begins streaming.</p><p>No applications are installed on the phone. No developer options are enabled.</p><p>The intelligence lives entirely on the receiving side.</p><h3>The Unexpected Role of VPNs</h3><p>Eventually, practical experimentation reveals another important lesson.</p><p>Not all screen-sharing technologies interact with networks in the same way. USB-based solutions such as scrcpy operate outside the local network.</p><p>Wireless solutions depend on it. This distinction becomes particularly visible when VPNs enter the picture.</p><p>Some VPN configurations:</p><ul><li>block local network traffic;</li><li>disable multicast discovery;</li><li>force all traffic through encrypted tunnels.</li></ul><p>When this happens, AirPlay and other wireless mirroring solutions may stop functioning entirely.</p><p>The issue is not video. The issue is networking.</p><p>For many professionals, this realization changes how demonstrations, training sessions, and troubleshooting environments are designed.</p><h3>Three Different Philosophies, One Shared Goal</h3><p>After exploring the landscape, three distinct philosophies emerge.</p><p><strong>scrcpy</strong> prioritizes performance, control, and efficiency.</p><p><strong>Smart Connect</strong> prioritizes productivity and seamless integration.</p><p><strong>AirPlay and UxPlay</strong> prioritize ecosystem simplicity and user experience.</p><p>Their protocols differ. Their architectures differ. Their intended audiences differ. Yet all of them solve the same fundamental problem. They transform a smartphone into a desktop window.</p><p>And in doing so, they enable something surprisingly powerful: the ability to observe multiple layers of a system simultaneously.</p><p>A mobile application can be displayed next to VPN logs.</p><p>Authentication flows can be observed alongside server-side events.</p><p>User actions can be correlated with infrastructure behavior in real time.</p><p>What begins as a search for screen mirroring often becomes something more valuable: a deeper understanding of how modern devices communicate, encode, transport, and present information.</p><p>The desktop window is merely the visible result. The real lesson lies in everything happening underneath.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=904e592d8168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Day Thunderbird Stopped Being Just an Email Client for me]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/the-day-thunderbird-stopped-being-just-an-email-client-for-me-8cd2e4e31edc?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cd2e4e31edc</guid>
            <category><![CDATA[mozilla-thunderbird]]></category>
            <category><![CDATA[mail]]></category>
            <category><![CDATA[thunderbird-mail-backup]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 10:21:18 GMT</pubDate>
            <atom:updated>2026-06-08T10:21:18.643Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s a strange moment that happens in many technical projects.</p><p>Special thanks to my colleague Francesco, who first introduced me to FiltaQuilla and indirectly sparked the entire automation architecture behind this project; to my friend Fabio, with whom I often discuss broader email-management and preservation strategies, including the original idea of building an automated system for long-term PEC and email archiving; and to Carmelina, whose office processes massive volumes of PEC messages daily and frequently struggles with storage limitations — providing the real-world scenario that pushed this project from theory into necessity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hk-i1c_QrgnwYpokeasbZQ.png" /></figure><p>At the beginning, everything works “well enough.”<br>You improvise. You adapt. You create folders, filters, and naming conventions. Maybe even a few backup scripts.</p><p>And then, one day, you realize the entire workflow is hanging by a thread.</p><p>That’s exactly what happened while managing PEC mailboxes inside Mozilla Thunderbird.</p><p>What initially looked like a simple email management task slowly transformed into a much bigger problem:<br>How do you reliably archive legally valid communications without turning your email client into a fragile, overloaded database?</p><p>At first, nobody notices the issue.</p><p>A few hundred emails are fine.</p><p>A few thousand?<br>That’s when things begin to break.</p><p>Searches become slower.<br>Attachments become impossible to retrieve quickly.<br>Backups become gigantic.<br>And the mailbox — ironically — becomes the least reliable part of the entire system.</p><p>The real problem is that email clients were never designed to act as long-term document management systems.</p><p>But in professional environments, especially with PEC, that’s exactly what people expect them to do.</p><p>And that expectation creates chaos.</p><h3>When Email Becomes Legal Infrastructure</h3><p>PEC changes the nature of email completely.</p><p>These are not simple messages exchanged between colleagues.</p><p>Inside those emails, there are:</p><ul><li>legal delivery receipts</li><li>acceptance notifications</li><li>digitally signed documents</li><li>certified timestamps</li><li>.p7m files with legal validity</li></ul><p>In practice, every message can become evidence.</p><p>And yet, most companies still archive everything inside the email client itself, as if Thunderbird were some kind of legal vault.</p><p>It isn’t.</p><p>That realization became impossible to ignore after years of accumulated PEC traffic.</p><p>The more emails arrived, the more obvious the limitations became.</p><p>Opening Thunderbird started feeling less like using software and more like walking through a warehouse filled with unsorted boxes.</p><p>Everything was technically there.</p><p>But finding anything quickly became painful.</p><p>Especially attachments.</p><p>That was probably the most frustrating part.</p><p>A signed contract could exist somewhere inside the mailbox, but retrieving it required a ritual:</p><p>Open Thunderbird, search manually, find the conversation, open the email, extract the file, and save it somewhere else.</p><p>Repeat that process dozens of times per day, and you begin questioning the entire architecture.</p><p>So the question became simple:</p><blockquote><em>what if Thunderbird stopped being the archive altogether?</em></blockquote><h3>The First Attempt</h3><p>The first idea was relatively straightforward.</p><p>Thunderbird already had filters.<br>And with FiltaQuilla, those filters became much more powerful.</p><p>FiltaQuilla could:</p><ul><li>save messages automatically</li><li>launch external programs</li><li>interact with the filesystem</li></ul><p>That sounded promising.</p><p>The concept was elegant on paper:</p><p>Thunderbird receives the email → FiltaQuilla triggers automation → Python processes everything.</p><p>Simple, at least in theory.</p><h3>The Architecture Started to Take Shape</h3><p>The system slowly evolved into two separate layers.</p><p>Thunderbird became the “bridge.”</p><p>Python became the “engine.”</p><p>And that distinction changed everything.</p><p>Whenever a PEC email arrived, Thunderbird no longer tried to “manage” it internally.</p><p>Instead, it simply exported the raw .eml file into a temporary folder.</p><p>From there, Python took over.</p><p>The script analyzed the email:</p><ul><li>sender</li><li>recipients</li><li>subject</li><li>attachments</li><li>timestamps</li><li>certified receipts</li></ul><p>Then it generated a real filesystem structure.</p><p>Not mailbox folders.</p><p>Actual folders on disk.</p><p>Human-readable. Searchable. Portable.</p><p>For the first time, the archive existed independently of the email client.</p><p>And honestly, that felt like a small breakthrough.</p><h3>Then Everything Broke</h3><p>Of course, no automation project is complete without a phase where nothing behaves the way documentation claims it should.</p><p>The main issue appeared unexpectedly.</p><p>Different versions of FiltaQuilla handled macros differently.</p><p>On one machine, the workflow worked perfectly.</p><p>On another, the Python script never received the correct message path.</p><p>The system became unreliable in the worst possible way:<br>intermittently.</p><p>Those are always the hardest bugs to solve because they create doubt everywhere.</p><p>Was it Thunderbird?<br>Python?<br>Permissions?<br>Encoding?<br>Windows paths?</p><p>After hours of debugging, the answer turned out to be simpler and more annoying:</p><p>The architecture depended too heavily on Thunderbird internals.</p><p>That dependency had to disappear.</p><h3>The Simplest Fix Became the Best One</h3><p>The solution was almost embarrassingly simple.</p><p>Instead of asking Thunderbird to pass variables, parameters, and message paths, the workflow was reduced to one single responsibility:</p><p>Thunderbird saves the .eml file.<br>That’s it.</p><p>Python independently watches the folder and processes whatever appears inside it.</p><p>No macros.<br>No fragile parameter passing.<br>No version-specific behavior.</p><p>Ironically, the system became far more robust the moment Thunderbird started doing <em>less</em>.</p><p>That was probably the most important lesson of the entire project.</p><p>Good architecture often comes from removing responsibilities, not adding features.</p><h3>The Problem Nobody Expected</h3><p>Just when the system seemed stable, another issue emerged.</p><p>Some emails involved multiple recipients:</p><ul><li>CC lists</li><li>shared PEC addresses</li><li>forwarded conversations</li><li>secondary accounts</li></ul><p>Certain messages failed classification because the destination account wasn’t immediately obvious.</p><p>And in a legal archive, “losing” a message inside the wrong folder is not acceptable.</p><p>The solution became a recursive email-matching system.</p><p>The Python script scanned every relevant header:</p><ul><li>From</li><li>To</li><li>CC</li><li>BCC</li></ul><p>Every address was compared against active accounts defined in a YAML configuration file.</p><p>If no match was found, the email automatically landed inside a protected fallback folder called:</p><pre>others</pre><p>It sounds trivial.</p><p>But that small safeguard eliminated one of the biggest operational fears:</p><p>silent data loss.</p><h3>Why YAML Ended Up Being a Big Deal</h3><p>One unexpectedly powerful decision was using a simple config.yaml file.</p><p>Not a database.<br>Not a GUI.<br>Not a proprietary configuration layer.</p><p>Just YAML.</p><p>That single file defined:</p><ul><li>active accounts</li><li>backup paths</li><li>archive destinations</li></ul><p>Which meant the entire infrastructure became portable.</p><p>To migrate the system to another machine, all that was needed was:</p><ul><li>copy the automation folder</li><li>install Python</li><li>update filesystem paths</li></ul><p>Done.</p><p>No Thunderbird exports.<br>No database rebuilding.<br>No painful migrations.</p><p>The archive became independent from the software used to access it.</p><p>And that’s an incredibly liberating feeling.</p><h3>The Moment It Finally Worked</h3><p>There’s always a moment in automation projects where you realize the system has quietly crossed a line.</p><p>You stop “testing” it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPbFHpzoV-4xZ6Irg_VZmw.png" /></figure><p>And you start trusting it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XdLfitCZvfmr9Rbjb2k3qw.png" /></figure><p>For this project, that moment arrived when retrieving documents became faster directly from the filesystem than from Thunderbird itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LBNqVnKyyGI7JCas2oreQ.png" /></figure><p>At that point, the email client had effectively transformed into something else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*58ynxMdtmIqCwghcYvMU6w.png" /></figure><p>Not an archive.</p><p>Not storage.</p><p>But an ingestion gateway.</p><p>Emails are entered through Thunderbird.</p><p>But the real system lived outside of it.</p><p>Structured folders.<br>Extracted attachments.<br>Portable backups.<br>Searchable documents.<br>Independent storage.</p><p>Exactly the way it should have worked from the beginning.</p><h3>Looking Back</h3><p>What started as a simple automation experiment eventually became a complete rethink of how email archives should work.</p><p>And honestly, the most interesting part wasn’t the Python code.</p><p>It wasn’t the filters.</p><p>It wasn’t even the automation itself.</p><p>It was the realization that most software becomes fragile the moment we force it to do jobs it was never designed for.</p><p>Thunderbird is an excellent email client.</p><p>But it should not be treated as a permanent legal archive.</p><p>Once that distinction became clear, every architectural decision suddenly made sense.</p><p>And sometimes, the best engineering solution is not creating a more complex system.</p><p>It’s finally separating responsibilities the right way.</p><h3>Appendix — Python Automation Logic (Pseudo-Code)</h3><p>The automation engine was designed to transform raw PEC emails into a structured filesystem archive.</p><p>Instead of keeping everything trapped inside Mozilla Thunderbird, the script extracts, classifies, and stores every message independently from the mail client.</p><p>The workflow can be summarized in a few core steps.</p><h3>1. Load Configuration</h3><p>The script reads a YAML file containing:</p><ul><li>active PEC accounts</li><li>backup paths</li><li>archive settings</li></ul><pre>FUNCTION load_configuration():<br>    READ config.yaml<br>    RETURN:<br>        active_accounts<br>        backup_directory</pre><p>This makes the entire system portable across machines and operating systems.</p><h3>2. Scan Incoming Emails</h3><p>Thunderbird + FiltaQuilla save emails as .eml files into a temporary folder.</p><p>The Python engine processes them automatically.</p><pre>FOR each .eml file:<br>    parse_email(file)</pre><h3>3. Parse and Classify</h3><p>The script extracts metadata such as:</p><ul><li>sender</li><li>recipients</li><li>subject</li><li>attachments</li></ul><p>Then it identifies which configured account owns the message.</p><pre>IF account FOUND in headers:<br>    use account folder<br>ELSE:<br>    use &quot;others&quot;</pre><p>The &quot;others&quot; Fallback prevents silent data loss.</p><h3>4. Detect INBOX or OUTBOX</h3><p>PEC acceptance and delivery receipts are automatically recognized.</p><pre>IF subject CONTAINS:<br>    &quot;ACCETTAZIONE&quot;<br>    OR &quot;CONSEGNA&quot;<br>    folder = OUTBOX<br>ELSE:<br>    folder = INBOX</pre><h3>5. Build Archive Structure</h3><p>The system creates organized folders automatically.</p><p>Example:</p><pre>/account/INBOX/20260512_signed_contract/</pre><p>Then it:</p><ul><li>moves the original .eml</li><li>extracts attachments</li><li>preserves .p7m files</li></ul><pre>CREATE destination_folder <br>MOVE original_email<br>EXTRACT all attachments</pre><h3>Final Outcome</h3><p>The result is a filesystem-native archive that is:</p><ul><li>searchable</li><li>portable</li><li>backup-friendly</li><li>independent from Thunderbird</li></ul><p>Most importantly, the archive remains usable even without the original email client.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cd2e4e31edc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Tamed an Old 4G Router to Run a Modern 5G SIM]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/how-i-tamed-an-old-4g-router-to-run-a-modern-5g-sim-788a7a955183?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/788a7a955183</guid>
            <category><![CDATA[5g]]></category>
            <category><![CDATA[tls-connection]]></category>
            <category><![CDATA[openwrt-compatible-router]]></category>
            <category><![CDATA[4g]]></category>
            <category><![CDATA[openvpn]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Tue, 26 May 2026 10:51:10 GMT</pubDate>
            <atom:updated>2026-05-26T10:51:10.302Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s something deeply satisfying about refusing to throw away perfectly functional hardware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QLr0Z9p49JtfbZYFkQ57EA.png" /></figure><p>A few weeks ago, I found myself staring at an old TP-Link MR6400 v5.30 router — a tiny LTE box powered by a Qualcomm MDM9200 modem, with only 64 MB of RAM and a MIPS CPU from another era.</p><p>Officially, it was a basic 4G router.</p><p>Unofficially?</p><p>It became one of the most interesting networking projects I’ve touched in years.</p><p>The challenge started with a Vodafone 5G SIM.</p><p>Not because I expected “real” 5G speeds — the hardware is physically LTE-only — but because modern carrier infrastructures are optimized for newer devices, newer modem stacks, and more advanced network negotiation.</p><p>Most old LTE routers simply fail silently:<br>random disconnects, unstable sessions, VPN failures, or terrible throughput.</p><p>Mine did all of that.</p><p>So instead of replacing the router, I replaced the software stack.</p><p>That’s when the fun started.</p><h3>Installing OpenWrt on Ancient Hardware</h3><p>The first step was installing OpenWrt.</p><p>Immediately, the router transformed from a locked consumer appliance into a tiny Linux networking server.</p><p>But OpenWrt alone wasn’t enough.</p><p>The Qualcomm modem required a very precise QMI stack to communicate correctly with modern mobile networks.</p><p>These were the critical packages:</p><pre>apk add \<br>kmod-usb-net-qmi-wwan \<br>uqmi \<br>kmod-usb-serial-qualcomm \<br>usb-utils \<br>openvpn-mbedtls</pre><p>Here’s what each one actually does.</p><h3>kmod-usb-net-qmi-wwan</h3><p>This is the kernel driver that exposes the modem as a QMI network interface.</p><p>Without it, OpenWrt sees the modem as generic USB hardware but cannot establish a data session.</p><p>This package creates the critical device:</p><pre>/dev/cdc-wdm0</pre><p>That device becomes the communication channel between Linux and the Qualcomm modem firmware.</p><h3>uqmi</h3><p>This utility is the real brain of the setup.</p><p>It sends QMI commands directly to the modem:</p><ul><li>signal quality</li><li>network registration</li><li>APN negotiation</li><li>connection state</li><li>SIM information</li><li>raw IP setup</li></ul><p>Without uqmi, the router can’t properly initialize the LTE session.</p><p>It’s also the foundation for the LED monitoring script later.</p><h3>kmod-usb-serial-qualcomm</h3><p>This enables Qualcomm diagnostic serial ports.</p><p>Even if they’re not used constantly, they are invaluable for:</p><ul><li>debugging modem crashes</li><li>reading low-level modem output</li><li>recovery operations</li><li>AT command fallback</li></ul><p>Old Qualcomm chipsets are notoriously stubborn.<br>Having debug access saved me multiple times.</p><h3>usb-utils</h3><p>Mostly used for diagnostics.</p><p>Commands like:</p><pre>lsusb</pre><p>allowed me to verify:</p><ul><li>USB enumeration</li><li>modem IDs</li><li>power resets</li><li>driver binding</li></ul><p>On embedded Linux systems, visibility matters.</p><h3>openvpn-mbedtls</h3><p>This one became essential.</p><p>OpenSSL was simply too heavy for a 64 MB router.</p><p>Switching to the mbedTLS version of OpenVPN reduced memory usage dramatically while keeping the VPN tunnel stable.</p><p>Without this optimization, the kernel OOM killer regularly terminated OpenVPN during traffic spikes.</p><h3>The Real Breakthrough: QMI Configuration</h3><p>The real magic happened inside /etc/config/network.</p><p>This configuration finally stabilized Vodafone connectivity.</p><pre>config interface &#39;ltewan&#39;<br> option proto &#39;qmi&#39;<br> option device &#39;/dev/cdc-wdm0&#39;<br> option apn &#39;internet&#39;<br> option auth &#39;both&#39;<br> option pdptype &#39;ip&#39;<br> option dhcp &#39;0&#39;<br> option multipath &#39;off&#39;</pre><p>Every single line mattered.</p><h3>option proto &#39;qmi&#39;</h3><p>This tells OpenWrt to use native Qualcomm QMI mode instead of PPP or NCM.</p><p>QMI is faster, cleaner, and significantly more stable on Qualcomm chipsets.</p><p>It also reduces CPU overhead — critical on ancient hardware.</p><h3>option device &#39;/dev/cdc-wdm0&#39;</h3><p>This specifies the modem control interface.</p><p>Without this path, OpenWrt cannot talk to the modem firmware.</p><p>Think of it as the “management socket” for the LTE chipset.</p><h3>option apn &#39;internet&#39;</h3><p>Vodafone accepts several APNs, but surprisingly, the generic:</p><pre>internet</pre><p>worked best.</p><p>Some Vodafone-specific APNs triggered strange filtering or unstable negotiation.</p><p>The universal APN avoided most of those issues.</p><h3>option auth &#39;both&#39;</h3><p>This enables flexible PAP/CHAP authentication negotiation.</p><p>Many carriers technically don’t require authentication anymore, but allowing both methods improved compatibility during session setup.</p><p>Especially after reconnections.</p><h3>option pdptype &#39;ip&#39;</h3><p>This line was absolutely critical.</p><pre>option pdptype &#39;ip&#39;</pre><p>Without forcing IPv4-only negotiation, the modem frequently became unstable during dual-stack IPv4/IPv6 setup.</p><p>Modern carriers heavily prioritize IPv6 infrastructure, but old Qualcomm firmware often behaves unpredictably under mixed-stack negotiation.</p><p>Forcing pure IPv4 made the connection dramatically more reliable.</p><p>This single line transformed the setup from “occasionally usable” to “daily stable.”</p><h3>option dhcp &#39;0&#39;</h3><p>This disables traditional DHCP handling.</p><p>QMI already negotiates IP addressing directly with the modem.</p><p>Using DHCP on top of that created unnecessary delays and occasional conflicts. Disabling it simplified the network stack.</p><h3>option multipath &#39;off&#39;</h3><p>This reduces CPU overhead.</p><p>Multipath routing features are useful on modern systems, but on a tiny MIPS CPU they only waste resources. Disabling it improved responsiveness under load.</p><h3>The Hidden Enemy: RAM</h3><p>At this point, the router connected correctly.</p><p>But stability was still terrible. The real bottleneck wasn’t LTE. It was the memory.</p><p>The router only has 64 MB RAM.</p><p>Modern OpenWrt builds are surprisingly powerful, but every extra daemon costs memory.</p><p>Soon the kernel started killing processes:</p><ul><li>OpenVPN crashed</li><li>network services restarted randomly</li><li>modem scripts failed</li><li>logging froze</li></ul><p>So optimization became mandatory.</p><h3>Survival Optimizations for Legacy Hardware</h3><p>I applied several aggressive optimizations.</p><h3>Packet Steering</h3><pre>option packet_steering &#39;1&#39;</pre><p>This distributes packet processing more efficiently across interrupts.</p><p>On tiny CPUs, every optimization matters.</p><h3>Replacing OpenSSL with mbedTLS</h3><p>This alone reduced VPN memory usage by roughly 15–20%.</p><p>On modern hardware, that’s irrelevant. On 64 MB RAM?</p><p>It’s survival.</p><h3>Disabling Heavy LED Daemons</h3><p>The stock OpenWrt LED management process generated unnecessary overhead.</p><p>So I replaced it entirely with a lightweight shell script.</p><h3>OpenVPN Over TCP: Stability Over Purism</h3><p>A lot of networking purists insist that VPNs should always use UDP.</p><p>Normally, they’re right. But mobile carriers are messy.</p><p>Italian carrier NAT systems sometimes throttle or disrupt UDP sessions unpredictably, especially on older LTE hardware.</p><p>TCP turned out to be far more stable. My final OpenVPN tuning looked like this:</p><pre>proto tcp-client<br>remote myvpn.example.com 443<br>tun-mtu 1400<br>mssfix 1300</pre><h3>Why TCP Worked Better</h3><p>Using TCP over port 443 made the VPN tunnel appear similar to regular HTTPS traffic.</p><p>That helped bypass:</p><ul><li>aggressive carrier NAT</li><li>UDP filtering</li><li>mobile session instability</li><li>packet fragmentation problems</li></ul><p>It also made reconnections much cleaner after LTE signal drops.</p><h3>tun-mtu 1400</h3><p>Mobile carriers often use encapsulation layers that reduce usable MTU.</p><p>Setting:</p><pre>tun-mtu 1400</pre><p>prevented fragmentation inside the VPN tunnel.</p><h3>mssfix 1300</h3><p>This clamps TCP packet size inside the VPN. Without it, some websites partially loaded or stalled completely under LTE. A classic MTU issue.</p><h3>Building a VPN Kill Switch</h3><p>One thing I absolutely wanted:</p><p>If the VPN died, traffic must NOT leak directly through Vodafone.</p><p>So I created a proper firewall kill switch.</p><pre>config zone<br> option name &#39;vpn&#39;<br> option input &#39;REJECT&#39;<br> option output &#39;ACCEPT&#39;<br> option forward &#39;REJECT&#39;<br> option device &#39;tun0&#39;<br> option masq &#39;1&#39;<br> option mtu_fix &#39;1&#39;</pre><p>This defines the VPN as a dedicated firewall zone.</p><p>Then:</p><pre>config forwarding<br> option src &#39;lan&#39;<br> option dest &#39;vpn&#39;</pre><p>This allows LAN devices to use only the VPN tunnel.</p><p>Finally:</p><pre>config forwarding<br> option src &#39;lan&#39;<br> option dest &#39;ltewan&#39;<br> option enabled &#39;0&#39;</pre><p>This is the actual kill switch.</p><p>If the VPN disappears, LAN traffic cannot escape through LTE.</p><p>Internet simply stops. Exactly as intended.</p><h3>Rebuilding the Signal LEDs from Scratch</h3><p>The original TP-Link firmware handled LTE signal LEDs automatically.</p><p>OpenWrt didn’t. So I rebuilt the feature manually using uqmi.</p><p>The script polls the modem RSSI every 30 seconds and directly controls the hardware LEDs through /sys/class/leds.</p><p>Here’s the full script, starting from: “<a href="https://rigacci.org/wiki/doku.php/doc/appunti/hardware/tl-mr6400_openwrt"><em>https://rigacci.org/wiki/doku.php/doc/appunti/hardware/tl-mr6400_openwrt</em></a>”</p><pre>#!/bin/sh<br><br>RSSI=$(uqmi -d /dev/cdc-wdm0 --get-signal-info \<br> | grep &#39;&quot;rssi&quot;:&#39; \<br> | cut -d: -f2 \<br> | tr -d &#39; ,&#39;)<br><br>[ -z &quot;$RSSI&quot; ] &amp;&amp; RSSI=-200<br>echo &quot;$RSSI&quot; &gt; /tmp/lte-rssi<br><br>LED1=&quot;/sys/class/leds/white:signal1&quot;<br>LED2=&quot;/sys/class/leds/white:signal2&quot;<br>LED3=&quot;/sys/class/leds/white:signal3&quot;<br>if [ &quot;$RSSI&quot; -le -110 ] || [ &quot;$RSSI&quot; -eq -200 ]; then<br> echo 0 &gt; &quot;$LED1/brightness&quot;<br> echo 0 &gt; &quot;$LED2/brightness&quot;<br> echo 0 &gt; &quot;$LED3/brightness&quot;<br>elif [ &quot;$RSSI&quot; -le -95 ]; then<br> echo 1 &gt; &quot;$LED1/brightness&quot;<br> echo 0 &gt; &quot;$LED2/brightness&quot;<br> echo 0 &gt; &quot;$LED3/brightness&quot;<br>elif [ &quot;$RSSI&quot; -le -80 ]; then<br> echo 1 &gt; &quot;$LED1/brightness&quot;<br> echo 1 &gt; &quot;$LED2/brightness&quot;<br> echo 0 &gt; &quot;$LED3/brightness&quot;<br>else<br> echo 1 &gt; &quot;$LED1/brightness&quot;<br> echo 1 &gt; &quot;$LED2/brightness&quot;<br> echo 1 &gt; &quot;$LED3/brightness&quot;<br>fi</pre><h3>How the LED Script Works</h3><p>The script does something beautifully simple.</p><p>First:</p><pre>uqmi --get-signal-info</pre><p>asks the modem for signal quality.</p><p>Then the script extracts only the RSSI numeric value.</p><p>Example:</p><pre>&quot;rssi&quot;: -78</pre><p>That value is compared against thresholds:</p><ul><li>worse than -110 dBm → no LEDs</li><li>around -95 dBm → 1 LED</li><li>around -80 dBm → 2 LEDs</li><li>stronger than -80 dBm → 3 LEDs</li></ul><p>Instead of using heavy user-space services, the script directly writes:</p><pre>0</pre><p>or</p><pre>1</pre><p>into Linux LED brightness files. That means almost zero CPU overhead.</p><p>Perfect for legacy hardware.</p><h3>Automating the Monitoring</h3><p>To keep CPU usage low, I avoided real-time polling.</p><p>Instead, cron executes the script every 30 seconds:</p><pre>* * * * * /root/uqmi_led.sh<br>* * * * * sleep 30 &amp;&amp; /root/uqmi_led.sh</pre><p>This creates near real-time LED updates without stressing the tiny MIPS processor.</p><h3>The Final Result</h3><p>After days of tuning, debugging, crashes, kernel logs, and modem experimentation, the result became surprisingly solid.</p><p>This old router is now:</p><ul><li>stable</li><li>VPN-secured</li><li>memory-optimized</li><li>visually monitorable</li><li>carrier-compatible</li><li>remotely manageable</li><li>reliable enough for daily usage</li></ul><p>And most importantly:</p><p>it proved something I strongly believe.</p><p>Hardware becomes “obsolete” mostly because software stops evolving around it.</p><p>Not because the hardware itself is useless.</p><p>That tiny MR6400 will never become a true 5G router.</p><p>But today it handles a modern Vodafone 5G SIM more reliably than many cheap contemporary routers.</p><p>And honestly?</p><p>That feels far more rewarding than buying new hardware.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=788a7a955183" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VXLAN over IPsec for Multi-VLAN Transport in Hybrid Networks]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/vxlan-over-ipsec-for-multi-vlan-transport-in-hybrid-networks-2d388ff933be?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d388ff933be</guid>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[vxlan]]></category>
            <category><![CDATA[vlan]]></category>
            <category><![CDATA[ipsec-vpn]]></category>
            <category><![CDATA[strongswan]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Mon, 04 May 2026 09:45:33 GMT</pubDate>
            <atom:updated>2026-05-04T09:45:33.557Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzpxQHZZwKuT94rYOJCvUg.png" /></figure><h3>Introduction</h3><p>When extending enterprise or ISP-grade networks across data centers or branch offices, engineers often need to preserve <strong>Layer 2 semantics</strong> (VLANs, ARP, broadcast) while securing traffic over untrusted WAN links. While GRE or Geneve encapsulations are common, <strong>VXLAN</strong> has become the de facto standard for cloud and SDN environments thanks to its wide support in NICs, switches, and hypervisors. In this article, we’ll explore how to deploy <strong>VXLAN over IPsec with strongSwan</strong> to carry multiple VLANs across sites, compare it with other tunneling methods, and provide practical configuration examples.</p><h3>Why VXLAN?</h3><p>VXLAN (Virtual eXtensible LAN) encapsulates Layer 2 frames inside UDP packets, using <strong>VXLAN Network Identifiers (VNIs)</strong> instead of VLAN IDs. VXLAN is attractive because:</p><ul><li>It scales to <strong>16 million VNIs</strong> (vs. 4096 VLANs).</li><li>It’s <strong>hardware-accelerated</strong> on many NICs and switches.</li><li>It’s supported across <strong>Linux, VMware, OpenStack, Kubernetes</strong>, and most SDN controllers.</li><li>Its encapsulation is well-understood, making it interoperable in multi-vendor environments.</li></ul><p>Drawback: VXLAN adds more <strong>overhead (~50 B)</strong> than native VLAN bridging, and when combined with IPsec (ESP), the per-packet overhead grows further. MTU tuning is therefore crucial.</p><h3>Design Goals</h3><ul><li><strong>Secure transport</strong> between Host A (site edge router/firewall) and Host B (remote site).</li><li>Carry <strong>five VLANs (10, 11, 12, 20, 30)</strong> across the encrypted tunnel.</li><li>Allow <strong>inter-VLAN routing</strong> at Host A.</li><li>Provide <strong>NAT masquerading</strong> for outbound Internet access from Host B.</li><li>Support <strong>DHCP and DNS</strong> for LAN clients.</li><li>Ensure scalability to <strong>support up to 500–600 clients</strong> with an aggregate throughput of ~600 Mbps.</li></ul><h3>Encapsulation and Overhead</h3><ul><li><strong>VXLAN header</strong>: ~50 B (UDP + VXLAN).</li><li><strong>ESP (AES-GCM)</strong>: ~50 B.</li><li><strong>Total overhead</strong>: ~100 B per packet.</li></ul><p>For 1500 B Ethernet MTU:</p><ul><li>Effective payload ~1400 B.</li><li>MTU should be clamped to ~1380 B in the tunnel.</li></ul><p>Compared to GRE (~80 B overhead), VXLAN is slightly less efficient but <strong>widely supported in SDN/NFV stacks</strong>, making it a strong choice in cloud-native deployments.</p><h3>System and Kernel Tuning</h3><pre>On both hosts (/etc/sysctl.conf):<br><br># Forwarding<br>net.ipv4.ip_forward=1<br>net.ipv6.conf.all.forwarding=1<br><br># Disable ICMP redirects<br>net.ipv4.conf.all.accept_redirects=0<br>net.ipv4.conf.all.send_redirects=0<br><br># Increase buffer sizes<br>net.core.rmem_max=26214400<br>net.core.wmem_max=26214400<br><br># Tunnel performance<br>net.ipv4.tcp_mtu_probing=1<br><br>Interface Configuration (Host A and B)<br><br>Host A (Gateway with NAT):<br><br># VXLAN interface<br>ip link add vxlan1 type vxlan id 42 dev eth0 dstport 4789 remote B.B.B.B<br>ip link set vxlan1 up<br><br># Bridge<br>brctl addbr br-vpn<br>brctl addif br-vpn vxlan1<br>brctl addif br-vpn eth1.10 eth1.11 eth1.12 eth1.20 eth1.30<br>ip link set br-vpn up<br><br><br>Host B (Remote site):<br><br>ip link add vxlan1 type vxlan id 42 dev eth0 dstport 4789 remote A.A.A.A<br>ip link set vxlan1 up<br><br>brctl addbr br-vpn<br>brctl addif br-vpn vxlan1<br>brctl addif br-vpn eth1.10 eth1.11 eth1.12 eth1.20 eth1.30<br>ip link set br-vpn up<br><br>Firewall with nftables (Host A)<br>table inet filter {<br>  chain input {<br>    type filter hook input priority 0;<br>    policy drop;<br><br>    ct state established,related accept<br>    iif &quot;lo&quot; accept<br><br>    # Allow SSH, DHCP, DNS<br>    tcp dport {22, 53} accept<br>    udp dport {67, 68, 53} accept<br><br>    # IPsec<br>    udp dport {500,4500} accept<br>    esp accept<br>  }<br><br>  chain forward {<br>    type filter hook forward priority 0;<br>    policy drop;<br><br>    ct state established,related accept<br><br>    # Allow LAN/VLANs via VXLAN<br>    iifname &quot;vxlan1&quot; accept<br>    oifname &quot;vxlan1&quot; accept<br><br>    # Allow VLAN interfaces<br>    iifname { &quot;eth1.10&quot;, &quot;eth1.11&quot;, &quot;eth1.12&quot;, &quot;eth1.20&quot;, &quot;eth1.30&quot; } accept<br>  }<br><br>  chain output {<br>    type filter hook output priority 0;<br>    policy accept;<br>  }<br>}<br><br>table ip nat {<br>  chain postrouting {<br>    type nat hook postrouting priority 100;<br>    oif &quot;eth0&quot; masquerade<br>  }<br>}<br><br>strongSwan Configuration<br><br>/etc/ipsec.conf<br><br>config setup<br>  charondebug=&quot;ike 1, knl 1, cfg 0&quot;<br><br>conn vxlan-ipsec<br>  auto=start<br>  keyexchange=ikev2<br>  ike=aes256gcm16-prfsha256-ecp256!<br>  esp=aes256gcm16-ecp256!<br>  left=A.A.A.A<br>  right=B.B.B.B<br>  leftid=A.A.A.A<br>  rightid=B.B.B.B<br>  leftsubnet=0.0.0.0/0<br>  rightsubnet=0.0.0.0/0<br>  dpdaction=restart<br>  dpddelay=30s<br><br><br>/etc/ipsec.secrets<br><br>A.A.A.A B.B.B.B : PSK &quot;strongsharedsecret&quot;</pre><h3>Performance Analysis</h3><ul><li>With a 1000 B average packet size, VXLAN+IPsec overhead ≈ <strong>10%</strong>.</li><li>With 1400 B packets, the overhead drops ≈ <strong>7%</strong>.</li><li>On a 600 Mbps link, expect ~540 Mbps usable payload for large packets.</li><li>CPU requirements: An AES-NI capable CPU (with at least 2 cores at 2 GHz) is recommended for throughput greater than 500 Mbps.</li></ul><h3>Comparison with GRE and GENEVE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*Q0Z_E-r5iECdV6aPXRE2cA.png" /></figure><p>VXLAN offers an excellent trade-off: nearly universal support and integration with SDN/NFV systems, at the cost of slightly higher per-packet overhead.</p><h3>Conclusion</h3><p><strong>VXLAN over IPsec</strong> offers a secure and SDN-friendly method for extending Layer 2 and Layer 3 domains across multiple sites. While it introduces slightly more overhead than GRE, it benefits from <strong>broad hardware offload and cloud-native support</strong>, making it an ideal choice for scalable deployments with 500–600 clients and multiple VLANs. With proper MTU tuning, sysctl optimizations, and strongSwan-based encryption, VXLAN over IPsec can deliver <strong>secure multi-VLAN transport at near line-rate performance</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d388ff933be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling VPNs with Thousands of Routes: StrongSwan, WireGuard, OpenVPN, and BIRD]]></title>
            <link>https://medium.com/@antoniofrancesco.gentile/scaling-vpns-with-thousands-of-routes-strongswan-wireguard-openvpn-and-bird-186135ce8292?source=rss-b810bf57d7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/186135ce8292</guid>
            <category><![CDATA[strongswan]]></category>
            <category><![CDATA[scaling-vpn]]></category>
            <category><![CDATA[dynamic-routing]]></category>
            <category><![CDATA[openvpn]]></category>
            <category><![CDATA[wireguard]]></category>
            <dc:creator><![CDATA[Antonio Francesco Gentile]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 10:35:36 GMT</pubDate>
            <atom:updated>2026-04-15T10:35:36.534Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5F1697yLQTcRW6xQ9URsw.png" /></figure><p>When designing VPN infrastructures for mobile users (such as road warriors using smartphones and laptops) or advanced security use cases (blocking thousands of IP addresses), you quickly encounter a challenge: <strong>how to handle thousands of /32 or /128 routes efficiently</strong>.</p><p>In this article, I’ll explain the pitfalls of pushing routes directly to VPN clients, why it fails with StrongSwan/OpenVPN/WireGuard, and how to build a scalable architecture using <strong>VTI interfaces</strong> and <strong>BIRD</strong> to centralize routing on the server side.</p><p><strong>The Problem: Thousands of Subnets in leftsubnet/rightsubnet</strong></p><p>In <strong>StrongSwan</strong>, you can declare local and remote subnets using leftsubnet and rightsubnet. But if you try to stuff 1<strong>000 /32 IPs</strong> in there:</p><ul><li>The configuration becomes unmanageable.</li><li>The Linux kernel may reject or silently drop policies.</li><li>Mobile clients (iOS/Android) <strong>cannot handle thousands of traffic selectors</strong>.</li></ul><p>The result? Only one subset of routes gets negotiated, and the rest never become active.</p><p><strong>First Attempt: Splitting into Blocks</strong></p><p>An obvious first try is to divide the IPs into blocks of 50–100 routes and create multiple conn sections:</p><pre>conn block_ipv4_1<br>    also=roadwarrior-EAP<br>    type=tunnel<br>    leftsubnet=192.0.2.10/32,198.51.100.22/32,...<br>    rightsourceip=10.10.10.0/24,fd00:1234:5678::/64<br>    auto=route</pre><p>Logs show:</p><pre>installing trap failed, remote address unknown<br>routing &#39;block_ipv4_1&#39; failed</pre><p>Or only the <strong>first block</strong> is actually established.<br> That’s because mobile clients negotiate only <strong>one set of traffic selectors</strong>, and additional blocks are ignored.</p><p><strong>The Real Solution: VTI + Server-Side Routing</strong></p><p>The scalable approach is to <strong>decouple encryption from routing</strong>:</p><ol><li>StrongSwan (or Libreswan) sets up <strong>one IPsec tunnel</strong> with a <strong>VTI interface</strong> (vti0).</li><li>Clients only get a virtual IP (rightsourceip=10.100.0.0/24).</li><li>All 1000 routes are installed <strong>on the server VTI interface</strong>, not pushed to clients.</li><li><strong>BIRD</strong> manages static/dynamic routes, reading them from external files.</li></ol><p>Benefits:</p><ul><li>Clients stay light (no 1000 routes on iOS/Android).</li><li>The server centralizes the routing logic.</li><li>Easy to reload/update routes.</li></ul><p><strong>StrongSwan + VTI Example</strong></p><p><strong>/etc/ipsec.conf</strong></p><pre>conn roadwarrior<br>    left=203.0.113.10<br>    @vpn.example.com&quot;&gt;leftid=@vpn.example.com<br>    leftcert=serverCert.pem<br>    right=%any<br>    rightid=%any<br>    rightauth=eap-mschapv2<br>    eap_identity=%identity<br>    rightsourceip=10.100.0.0/24,fd00:1234:5678::/64<br>    leftsubnet=0.0.0.0/0,::/0<br>    mark=42<br>    auto=add</pre><p><strong>Create VTI</strong></p><pre>ip link add vti0 type vti local 203.0.113.10 remote 0.0.0.0 key 42<br>ip addr add 10.200.0.1/30 dev vti0<br>ip link set vti0 up</pre><pre>/etc/bird/bird.conf (IPv4)<br>log syslog all;<br>router id 10.255.255.1;<br><br>protocol device { scan time 10; }<br><br>protocol kernel {<br>    ipv4 { export all; import all; };<br>    persist;<br>}<br><br>protocol static static_routes4 {<br>    ipv4;<br>    include &quot;/etc/bird/routes4.conf&quot;;<br>}<br>/etc/bird/bird6.conf (IPv6)<br>log syslog all;<br>router id 10.255.255.2;<br><br>protocol device { scan time 10; }<br><br>protocol kernel {<br>    ipv6 { export all; import all; };<br>    persist;<br>}<br><br>protocol static static_routes6 {<br>    ipv6;<br>    include &quot;/etc/bird/routes6.conf&quot;;<br>}<br>Example /etc/bird/routes4.conf<br>route 192.0.2.10/32 via &quot;vti0&quot;;<br>route 198.51.100.22/32 via &quot;vti0&quot;;<br># … thousands more<br>Example /etc/bird/routes6.conf<br>route 2001:db8:abcd::1/128 via &quot;vti0&quot;;<br>route 2001:db8:abcd::/48 via &quot;vti0&quot;;<br>________________________________________</pre><p><strong>Bash Script to Generate Routes</strong></p><pre>#!/bin/bash<br><br>ROUTES4=&quot;subnets4.txt&quot;<br>ROUTES6=&quot;subnets6.txt&quot;<br><br>OUT4=&quot;/etc/bird/routes4.conf&quot;<br>OUT6=&quot;/etc/bird/routes6.conf&quot;<br><br># IPv4<br>&gt; &quot;$OUT4&quot;<br>while read -r net; do<br>    [[ -z &quot;$net&quot; ]] &amp;&amp; continue<br>    echo &quot;route $net via \&quot;vti0\&quot;;&quot; &gt;&gt; &quot;$OUT4&quot;<br>done &lt; &quot;$ROUTES4&quot;<br><br># IPv6<br>&gt; &quot;$OUT6&quot;<br>while read -r net; do<br>    [[ -z &quot;$net&quot; ]] &amp;&amp; continue<br>    echo &quot;route $net via \&quot;vti0\&quot;;&quot; &gt;&gt; &quot;$OUT6&quot;<br>done &lt; &quot;$ROUTES6&quot;<br><br>echo &quot;Routes updated in $OUT4 and $OUT6&quot;<br>systemctl reload bird<br>systemctl reload bird6</pre><p><strong>What About the Clients?</strong></p><p>Mobile clients only see their assigned virtual IP.</p><ul><li><strong>Split tunneling</strong>: configure leftsubnet only for internal networks. Internet traffic continues to use the client’s ISP.</li><li><strong>Full tunneling</strong>: configure 0.0.0.0/0, then NAT all client traffic out via the server.</li></ul><p><strong>Extending to OpenVPN and WireGuard</strong></p><ul><li><strong>OpenVPN</strong>: Pushing thousands of routes with the &#39;push route&#39; command is infeasible. Instead, use route-nopull on clients and centralize routing on the server (with BIRD).</li><li><strong>WireGuard</strong>: AllowedIPs can technically hold many prefixes, but it’s not scalable. Instead, set AllowedIPs=0.0.0.0/0 for clients and let the server decide routing with BIRD.</li></ul><p><strong>Conclusion</strong></p><ul><li>Stuffing thousands of subnets into StrongSwan’s leftsubnet is <strong>not scalable</strong>.</li><li>The best solution is <strong>a single tunnel (VTI, TUN, WG)</strong> with <strong>centralized routing on the server</strong> using BIRD.</li><li>Clients stay lightweight, mobile OSes don’t choke, and updating routes is trivial.</li></ul><p>This architecture enables you to scale to 1<strong>000+ subnets</strong> cleanly, without disrupting mobile VPNs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=186135ce8292" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>