WLAN Pi – Setup a Wi-Fi Hotspot

UPDATE (OCTOBER 2019)

Thanks to Florent Lassia, we were able to configure the Wi-Fi NIC to bride to the Ethernet NIC. In the Hotspot mode, you can now have your Wi-Fi hotspot running, connect a client device to that Wi-Fi network and receive network connectivity to the LAN if your WLAN Pi is connected to the LAN via its Ethernet interface. We have detailed how to do it on this blog post: ​https://www.semfionetworks.com/blog/wlan-pi-bridge-wi-fi-hotspot-to-ethernet-interface

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

It has also been implemented as a new “Action” mode in the new NanoLED menu: https://github.com/WLAN-Pi/wlanpi-nanohat-oled
I love the fact that the WLAN Pi is very small and compact. It is very easy to have it always available with me in my backpack. So I like to use it as a Wi-Fi source when I measure wall attenuation. In order to do so, you need to setup a Wi-Fi hotspot so that the WLAN Pi can broadcast a Wi-Fi signal when you connect a Wi-Fi NIC.

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:

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:

  1. Download the latest version of the wlanpi image on this website: https://github.com/WLAN-Pi/wlanpi/releases
  2. Load it unto the microSD card that you will use for your wlanpi (I use the program called etcher on macOS)
  3. Insert the microSD card into the wlanpi
  4. Connect the wlanpi to your network (via the ethernet interface)
  5. Connect the Wi-Fi NIC to the wlanpi (via the USB port)
  6. Power the wlanpi ON
Here is a picture of my setup (I connected the wlanpi directly to my laptop):

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.

  1. Use the following command to create a new user: sudo adduser username
  2. In the following prompts, specify which password you want to use for this user
  3. Use the following command to give this user sudo privileges: sudo usermod -aG sudo username
  4. 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 ifconfigiwconfig or iw.

  1. In the home directory of the user, open the .profile file using the following command: sudo nano .profile
  2. Modify this file by adding the following line at the end of the .profile file:  PATH=$PATH:/sbin:/usr/sbin
  3. Save and close the .profile file
  4. Once back in the shell, reload the profile using this command: source .profile
  5. 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.

1 – Verify that the hostapd is installed by using the following command: dpkg –list | grep hostapd

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
If you want to modify other settings, feel free to take a look at the hostapd documentations: ​https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf

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.

1 – Validate that the wlan0 interface is UP (it should be up if you connected the NIC) using the following command: ifconfig.
2 – The network interfaces configurations are located in the following file: /etc/network/interfaces. Update the wlan0 configurations as follow by opening the file with nano: sudo nano /etc/network/interfaces
# 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.

Note: some Engineers had to add the following line in the /etc/network/interface file in order to make it work: hostapd /etc/hostapd.conf. You could try it out if this is not working out for you after the first try.

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.

​1 – Verify that the isc-dhcp-server is installed by using the following command: dpkg –list | grep isc-dhcp-server
2 – We need to tell the isc-dhcp-server that we will be expecting to receive DHCP requests on the wlan0 interface. To do so, modify the /etc/default/isc-dhcp-server file as follow: sudo nano /etc/default/isc-dhcp-server
INTERFACESv4="usb0 wlan0"
3 – Then, we need to configure the new DHCP pool that we will be using for our Wi-Fi Hotspot network. To do so, we need to update the following configuration file: sudo nano /etc/dhcp/dhcpd.conf
# 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;
}
Make sure that the pool is within the subnet you are using for the wlan0 interface.

TEST & VALIDATE

All we have to do now is test and validate that everything is working well.
1 – Start the hostapd application using the following command: sudo hostapd -d /etc/hostapd.conf
2 – Validate that the SSID is broadcasting. In my case, I used my iPad to validate that the “Allez Les Bleus” SSID was broadcasting. You can also use a Wi-Fi scanner to validate that it is broadcasting on the configured channel.
3 – Try to connect to this SSID and see if you receive an IP address within the pool configured. In my case, I used my iPad to connect and I received the following IP address: 192.168.88.100.
4 – Navigate the http://192.168.88.1 to validate that you can reach the HTML5 speedtest installed on the wlanpi. From there, you can start a speedtest and validate that everything works fine.
5 – (optional) Open up a spectrum analyzer and look at the activity on the channel while performing the speedtest. This can help you to understand what a Wi-Fi signal (OFDM) looks like on the spectrum.

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!

Leave a Reply

Your email address will not be published. Required fields are marked *