In Monitoring Baby On The Go I mentioned that it would be easier if I were able to connect the Raspberry Pi to new WiFi networks through a web browser. Then I could leave my travel router behind and just use a browser to configure the new network connection on the Pi, without logging in through VNC.

It didn't take long on Google to find RaspAP . This is a software stack for the Pi that effectively turns it into a travel router itself. It configures a hotspot on the Pi's WiFi and a Lighttpd web server that hosts a network configuration portal for the Pi. You can then log on to the portal and configure network access. By default RaspAP bridges the WiFi interface to ethernet. However, when you are travelling you will not find many hotels that offer wired connections, so I wanted to bridge the WiFi hotspot to a second WiFi interface I would provide through a USB dongle. The RaspAP Wiki and forums reveal that this is possible, albeit not supported.

RaspAP is a great idea and the project is off to a good start, but my impression is that it is still alpha quality (to be fair I am aiming for a use-case that isn't officially supported yet). After testing it out for a while, I concluded that the best approach was to edit the configuration files manually rather than through the web portal and once I had it working to use the portal just for monitoring and adding new WiFi networks.

Configuring client Wi-Fi connections using RaspAP

Here's the configuration that worked for me. DHCPCD/HostAPD together control wlan0, with the internal WiFi used as the hotspot.

/etc/dhcdcp.conf

# RaspAP wlan0 configuration
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
require dhcp_server_identifier
slaac private
nohook lookup-hostname
interface wlan0
env ifwireless=1
env wpa_supplicant_driver=wext
static ip_address=192.168.10.1/24
static routers=192.168.10.1
static domain_name_server=1.1.1.1 8.8.8.8

/etc/hostapd/hostapd.conf

driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
auth_algs=1
wpa_key_mgmt=WPA-PSK
beacon_int=100
ssid=APNET-PI
channel=1
hw_mode=g
ieee80211n=0
wpa_passphrase=XXXXXXXX
interface=wlan0
wpa=2
wpa_pairwise=CCMP
country_code=GB
ignore_broadcast_ssid=0

The RaspAP portal scans for WiFi networks and connects, using wlan1, by issuing commands to WPA Supplicant. Currently only my home network is configured, others can be added using the web GUI.

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
        ssid="APNETN"
        #psk="XXXXXXXX"
        psk=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
}

Configure RaspAP to use wlan1 for the client connection.

/var/www/html/includes/config.php

...
define('RASPI_WIFI_CLIENT_INTERFACE', 'wlan1');
...

With my dongle, an Asus N10, a little extra configuration was necessary. The driver only loaded when the dongle was plugged in after startup. To make the dongle functional immediately at boot time, we need to ensure the necessary module is loaded into the kernel by adding the following line to /etc/modules:

r8712u

I also had to change the default service for WPA Supplicant to use the 'wext' driver instead of the default. This involved copying the default file at /lib/systemd/system/wpa_supplicant.service to /etc/systemd/system/wpa_supplicant.service and ammending it as follows:

[Unit]
Description=WPA supplicant
Before=network.target
After=dbus.service
Wants=network.target

[Service]
Type=dbus
BusName=fi.w1.wpa_supplicant1
#ExecStart=/sbin/wpa_supplicant -Dwext -u -s -O /run/wpa_supplicant
ExecStart=/sbin/wpa_supplicant -u -s -i wlan1 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf

[Install]
WantedBy=multi-user.target
Alias=dbus-fi.w1.wpa_supplicant1.service

Lastly, to make sure the dongle always loads as 'wlan1', we add the following udev rule in /etc/udev/rules.d/72-static-name.rules:

ACTION=="add", SUBSYSTEM=="net", DRIVERS=="r8712u", NAME="wlan1"

Previous Post Next Post