Monday, 31 October 2022

Connecting back to my home LAN/WAN from remote country unknown Wifi

I am preparing for a presentation in a remote country unknown Wifi environment where I need to demonstrate a Wifi capable unit that can not run VPN natively but requires a connection back to my home LAN/WAN environment.

This is more challenging then what I described in my previous blog detailing how do I connect back with my parents.

Connecting with my parents

Firstly, I will need 2 Wifi interfaces here: one in client mode that connects to the unknown foreign Wifi and another in AP mode that enables Wifi connection from the unit that I need to demonstrate.

I had this Wifi USB hub in my drawer for a long time waiting for its use case:

Wifi USB hub from Pi Hut 

It took me a while to make it work with legacy wext driver option configured for wpa_supplicant. Details are in this forum post:

RTL8188EU configuration 

Unfortunately it turned out that its throughput performance is only 3-4 Mbps that is so poor that my demonstration unit complains about it.

Fortunately, I have a unit from both generations of Raspberry Pi Zero (2) W providing me two Wifi adapters but I would need to connect them somehow. I played with the idea of connecting two computers with USB back to back for a long time. As hostapd keeps disconnecting on Raspberry Pi Zero W, I use Raspberry Pi Zero 2 W at home to connect to my parents LAN/WAN by means of an Ethernet enabled Chromecast power supply hence I wanted to keep its USB configuration intact. So this is how I configured OTG driver on Raspberry Pi Zero W:

jordana@pi0w:~ $ sudo nano /boot/config.txt
dtoverlay=dwc2
jordana@pi0w:~ $ sudo nano /boot/cmdline.txt
modules-load=dwc2,g_ether

This has made usb0 interface appear on Raspberry Pi Zero W. The cable I have found working is an ordinary micro USB cable with an OTG adapter on the Raspberry Pi Zero 2 W side. This has not only provided power either way but also changed NO-CARRIER to BROADCAST on the usb0 interface on the Raspberry Pi Zero W side and created a usb0 interface on the Raspberry Pi Zero 2 W side also.

I also had to add DHCP configuration on the Raspberry Pi Zero W side:

jordana@pi0w:~ $ sudo nano /etc/dnsmasq.conf
interface=usb0
dhcp-range=192.168.10.2,192.168.10.20,255.255.255.0,24h
 

Finally, I enabled routing and masquerading on Raspberry Pi Zero W side and hostapd, dnsmasq and source based policy routing into zerotier VPN on the Raspberry Pi Zero 2 W side as described in my previous blog post about connecting to my parents.