WLAN Pi – Setup a Wi-Fi Hotspot
UPDATE (OCTOBER 2019)
UDPATE (AUGUST 2019)
Thanks to Nigel Bowden and Jerry Olla. This feature has been incorporated into the image of the WLAN Pi OS starting with version v1.7. Visit this link to see how it has been implemented: https://github.com/WLAN-Pi/wlanpi-hotspot
In this article, I will explain how to configure the WLAN Pi so you can use it as a Wi-Fi hotspot. You could then use your WLAN Pi to perform the following:
- Use it as a source to measure wall attenuation (see this article by Nigel Bowden for more details on how to do these measurements: https://www.ekahau.com/blog/2015/09/07/wi-fi-planning-walls-and-dbs-measuring-obstruction-losses-for-wlan-predictive-modelling/)
- Use it to perform Wi-Fi speedtests (I personally use this to show the students what a typical OFDM signal looks like on the spectrum)
Here is the video tutorial that explains the whole setup. You can also find the same steps detailed in this article.
INITIAL STEPS
I started this configuration from scratch so you can (hopefully) replicate it on your end. I started from the newest wlanpi image available on github. Follow these steps to start the process:
- Download the latest version of the wlanpi image on this website: https://github.com/WLAN-Pi/wlanpi/releases
- Load it unto the microSD card that you will use for your wlanpi (I use the program called etcher on macOS)
- Insert the microSD card into the wlanpi
- Connect the wlanpi to your network (via the ethernet interface)
- Connect the Wi-Fi NIC to the wlanpi (via the USB port)
- Power the wlanpi ON
Once the wlanpi is UP and RUNNING, you should be able to see the IP address that the wlanpi received on its Ethernet adapter. Use this IP address to establish an SSH connection between your computer and the wlanpi. By default, the following credentials are used to connect to the wlan:
- Username: wlanpi
- Password: wlanpi
Once connected, we will create a new user and give this new user some privileges.
- Use the following command to create a new user: sudo adduser username
- In the following prompts, specify which password you want to use for this user
- Use the following command to give this user sudo privileges: sudo usermod -aG sudo username
- Finally, try to connect using this new username and password: su – username
Finally, we will modify the user PATH so we can get access to some basic commands such as ifconfig, iwconfig or iw.
- In the home directory of the user, open the .profile file using the following command: sudo nano .profile
- Modify this file by adding the following line at the end of the .profile file: PATH=$PATH:/sbin:/usr/sbin
- Save and close the .profile file
- Once back in the shell, reload the profile using this command: source .profile
- You should now be able to use the ifconfig command
CONFIGURE HOSTAPD
In order to configure the Hotspot, we are going to use a linux program called hostapd. This program should already be installed on the wlanpi based image.
If hostapd is not installed, you can install it using the following command: sudo apt-get install hostapd
2 – Then, we need to configure hostapd so it create a Wi-Fi network. In my case I create a network on channel 36 called “Allez Les Bleus”. I defined it on 5GHz as I would use the tool to perform my wall measurements attenuations. In order to modify the configurations, you need to modify the file called /etc/hostapd.conf. You can open it with nano to modify it: sudo nano /etc/hostapd.conf
## WLAN SSID ssid=Allez Les Bleus ## WPA-PSK wpa_passphrase=championsdumonde ## Mode options: a=5GHz / g=2.4GHz hw_mode=a ## Set 2.4GHz Channel - 1,6,11 ## Set 5GHz Channel - 36,40,44,48,149,153,157,161,165 channel=36 ## Set Interface and Driver to user interface=wlan0 driver=nl80211 ## Set Country Code (Use your own country code here) country_code=CA ## IEEE 802.11n SETTINGS ieee80211n=1 #ht_capab=[HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40] ## IEEE 802.11ac SETTINGS ieee80211ac=1 #vht_oper_chwidth=1 vht_capab=[SU-BEAMFORMEE-1][HTC-VHT-1][VHT-LINK-ADAPT2][MAX-AMSDU-7935][GF] #vht_oper_centr_freq_seg0_idx=42 ## Set Security Parameters (WPA2-Personal here) wpa=2 wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP ## Enable WMM :) wmm_enabled=1 uapsd_advertisement_enabled=1
CONFIGURE THE NETWORK INTERFACES
Now we need to modify the way the W-Fi NIC interface (wlan0) is configured. By default, it will be configured to be used in monitor mode in order to perform Wi-Fi analysis. In order to use it to start up a hotspot, we need to change its configuration and give it an IP address.
# Wireless adapter #1 # Armbian ships with network-manager installed by default. To save you time # and hassles consider using 'sudo nmtui' instead of configuring Wi-Fi settings # manually. The below lines are only meant as an example how configuration could # be done in an anachronistic way: # allow-hotplug wlan0 #iface wlan0 inet dhcp iface wlan0 inet static address 192.168.88.1 netmask 255.255.255.0 #gateway 192.168.0.1 dns-nameservers 8.8.8.8 8.8.4.4 # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf # Disable power saving on compatible chipsets (prevents SSH/connection dropouts over WiFi) #wireless-mode Monitor wireless-power off
Feel free to choose whichever IP network you want to use.
CONFIGURE THE DHCP SERVER
This task gave me a little bit more work. I originally tried to make it work with dnsmasq but failed. I couldn’t make it work. So I started to look at alternatives and came across a program called isc-dhcp-server. It also turns out that the package is already installed on the wlanpi base image. In this section, we will explain how to configure the isc-dhcp-server to provide IP address to our hotspot Wi-Fi network.
INTERFACESv4="usb0 wlan0"
# WLAN Pi DHCP Hotspot Server Config subnet 192.168.88.0 netmask 255.255.255.0 { range 192.168.88.100 192.168.88.200; default-lease-time 600; max-lease-time 7200; }
TEST & VALIDATE
RUN IT AT STARTUP
We will use the crontab program to tell the OS to start hostapd when the WLAN Pi boots up.
1 – Enter the following command to configure the crontab configuration file: sudo crontab -e
2 – In the configuration file, add the following line: @reboot sudo hostapd -d /etc/hostapd.conf
@reboot sudo hostapd -d /etc/hostapd.conf
3 – Save and close the file
4 – Reboot and see if it works!
IDEAS
Working on this a couple of other ideas came to mind on how we could improve this:
1 – Work on a script that would active the hotspot automatically when the Wi-Fi NIC is connected
2 – OR EVEN BETTER, reprogram one of the button to start the hotspot when pressed and disable it when pressed again. UPDATE: this is now part of the standard WLAN Pi image starting at v1.7. See https://github.com/WLAN-Pi/wlanpi/releases.
3 – Complete the configuration to bridge the Wi-Fi Hotspot to the Ethernet interface so we can pass traffic through. You could then use it to setup your own local connection when the Hotel Wi-Fi is bad ;). UPDATE: we made it work, check out this blog post: https://www.semfionetworks.com/blog/wlan-pi-bridge-wi-fi-hotspot-to-ethernet-interface.
Please let me know if you have more ideas and please let me know if you have the skills to make the three listed above happen!
I hope this can be useful for some.
Thank you!