SemFio Networks

  • Home
  • About
  • Services
    • Wi-Fi DevOps with Mist
  • Partners
    • Mist
  • Training
  • Contacts
  • Blog
  • Home
  • About
  • Services
    • Wi-Fi DevOps with Mist
  • Partners
    • Mist
  • Training
  • Contacts
  • Blog

WLAN Pi - Bridge Wi-Fi Hotspot to Ethernet Interface

10/11/2019

1 Comment

 
In my previous article, I was explaining how you could configure the WLAN Pi to be used in a hotspot mode. Following the article, the configurations have been added to the new WLAN Pi image (starting at 1.7) and it is now part of the default WLAN Pi image (Thanks to Nigel Bowden and Jerry Olla).

​One of the feedback I got is that the Wi-Fi interface is not bridged to the ethernet interface. So, if you are connected to the Wi-Fi network, you will not be able to communicate back to the wired network.

So, in this article, I explain how you can configure the WLAN Pi to allow the Wi-Fi interface to be bridged to the ethernet interface. To make it work, I received huge help from Florent Lassia.

The first thing to do is to enable ip forwarding. To do so, open the /etc/sysctl.conf file and uncomment the following line:

    
This will enable traffic forwarding between the wlan0 and eth0 interfaces.

Then, we need to modify the DHCP server configurations in order to add the default gateway and DNS server information. To do so, open the /etc/wlanpihotspot/dhcp/dhcpd.conf file and add the following lines:

    
​Once this is done, you will have to reload the DHCP service on the WLAN pi using the following command:

    
​Here is the output you should see from running this restart test:

    
Then, we need to configure the firewall to allow communications between the two interfaces. In order to do so,  you need to modify a line in the /etc/default/ufw file. You will need to set the default forward policy to ACCEPT. It is set to DENY by default.

    
​Finally, we need to configure a NAT so that all the traffic coming from the Wi-Fi hotspot is natted behind the eth0 IP address. In order to do so, we need to modify the /etc/ufw/before.rules file. At the bottom of the file, after COMMIT, add the following lines:

    
​Once this is done, you can test your configurations by disabling and re-enabling the firewall. In order to do so, use the following command:

    
​Here is the output you should get:

    
Note: the configuration of both the /etc/default/ufw and /etc/ufw/before.rules will not revert back to the default if you go back to the normal mode of the WLAN Pi. You will have to manually re-configure them if you don't want to allow them in the normal mode.​

You can now reboot the WLAN Pi into the hotspot mode using the buttons and it should reboot in the Hotspot mode supporting these bridging configurations. You should be able to connect a client device to the Wi-Fi network and get network connectivity to the LAN if the WLAN Pi is connected to your LAN.

The plan now is to integrate this into the next version of the WLAN Pi image so it could be enabled by default in the Hotspot mode. To be continued…



written by François Vergès
1 Comment

Customize your WLAN Pi

8/3/2019

2 Comments

 
Picture
In this article, I will show you how you can customize your WLAN Pi and make it your own! Feel free to comment and tell me how you guys customize yours.

Here is the video tutorial that explains these customizations.

Create Your Own User

Creating your own user allows you to have your own password and your own home directory. It is more secure and you are free to modify your profile as much as you want.
Note: I would also recommend you to change the default password for the wlanpi account.

In order to create a new user, you need to ssh into the WLAN. By default, if you connect the WLAN Pi to your laptop via the USB connection, this should establish an Ethernet over USB connection and your laptop should receive an IP address in the 192.168.42.0/24 IP address subnet.

You can now ssh into the WLAN Pi from your laptop using the default username and password:
  • Username: wlanpi
  • Password: wlanpi
Picture
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
Picture
Finally, we will modify the user PATH so we can get access to some basic commands such as ifconfig, iwconfig 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
Picture

Change the Hostname of the WLAN Pi

The name of the WLAN Pi is configured under the /etc/hostname file. In order to change the hostname permanently, you will have to modify this file:
  1. Open the file using the following command: sudo nano /etc/hostname
  2. Modify the hostname to your liking
  3. Save and close the /etc/hostname file
  4. Reboot the WLAN Pi
Picture
When the WLAN Pi comes back online, you should be able to ssh into it and see the new hostname. The new hostname will also appear on the home screen:
Picture
One more thing you need to do here. You need to change the hostname used for dns resolutions. If you don't, you will realize that it takes longer for sudo commands to execute. To do so, open the /etc/hosts file and replace "wlanpi" by your new name:

    

Create Your Aliases

On linux, an alias allows you to create your own command shortcut. For example, instead of typing ls --color=auto, you could create the following alias : alias ls='ls --color=auto'. Then when you type ls, it will execute the full command line.

Everyone has their own set of aliases they like to use. Here I will just share the ones I use. Feel free to use them as well and feel free to create your own.

In order to create your aliases, you need to do the following:
  1. ssh back to the WLAN Pi using your new user: ssh francois@192.168.42.1
  2. Once connected to the WLAN Pi, modify the .bashrc file using the following command: nano .bashrc
  3. Add your aliases at the end of this .bashrc file
  4. Save and close the .bashrc file
  5. Reload your bash profile using the following command: source .bashrc
  6. Validate that your aliases have been applied using the alias command.
Picture
Here is the list of my aliases:

    

Customize Your Prompt

You can also customize your prompt to your liking. You can go wild here. I actually like it simple. I like the default prompt. I just changed the colors for fun!

In order to change the look of your prompt, you can do the following:
  1. From the WLAN Pi and from your user home directory, open the .bashrc file using the following command: nano .bashrc
  2. Inside the .bashrc file, scroll down until you find the PS1 variable. Then replace the value of that PS1 variable with whatever you would want to use.
  3. Save and close the .bashrc file
  4. Reload your bash profile using the following command: source .bashrc​
Picture
Here is the PS1 value that I used for mine:
​

    
Picture
You can use the following website to customize your prompt to your liking: ​https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/

Change the Picture Displayed when Booting

When the WLAN Pi, you can see an image appearing on the screen. By default, it is the logo of the Wireless LAN Professionals company.
Picture
However you could change it to something else if you want to.

First, you need to retrieve the original image used. It is located on the WLAN Pi at the following location: 
/home/wlanpi/NanoHatOLED/BakeBit/Software/Python/wlanprologo.png

In order to retrieve this image, I used the scp command from my laptop. This command allows you to copy files from the WLAN Pi to your laptop over an SSH connection. Here is the command I used: 

    
This will copy the image on your laptop. Then I studied the picture and retrieve the resolution of it: 128 x 64.

Once I knew the resolution, I created my own image using Illustrator. I actually created the two following ones:
Picture
Picture
Then you need to replace the image that's currently on the WLAN Pi with your new image, freshly created. You won't be able to do it in one shot because you don't have the permission to do so over scp.

So first, you need to transfert the new image back to the WLAN Pi. I transfered mine back to my home directory using the following command: 

    
Second, you need to ssh back into the WLAN Pi.

​And finally, you need to replace the old image with the new one. I used the following command to do so: sudo cp WLANPi-SemFio-StartUp.png /home/wlanpi/NanoHatOLED/BakeBit/Software/Python/wlanprologo.png

Note: It is very important here that you use the same destination name. The picture name will still be the same as before (wlanprologo.png) but its content will be different. I tried to do it a different way by changing the configuration files of the NanoLED program, but it didn't work properly.

Then, you can reboot your WLAN Pi, you should see the new picture when the WLAN Pi boots.
Picture

Ideas

In order to improve this customization, I would like to create a Python script that automates all of these tasks. I will then be able to run the script every time I update my WLAN Pi to a newer image and I will be able to retrieve my customizations.

If you manage multiple WLAN Pi, you could also create a Python script that you could run on multiple WLAN Pi to speed up their configurations and customizations.

Please share how you like to customize yours!

Thank you for reading!


​
Written by François Vergès
2 Comments

WLAN Pi - Setup a Wi-Fi Hotspot

7/22/2019

0 Comments

 
Picture

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:
  • 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:
  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):
Picture
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
Picture
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
Picture
Finally, we will modify the user PATH so we can get access to some basic commands such as ifconfig, iwconfig 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
Picture
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

    
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.
Picture
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
Code Editor

    
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
Picture
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
Code Editor

    
2 - 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

    
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
Picture
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.
Picture
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.
Picture
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.
Picture
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.
Picture

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

    
3 - Save and close the file
​4 - Reboot and see if it works!
Picture

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!


​
written by François Vergès
0 Comments
    Picture

    François Vergès

    François Vergès is the founder of SemFio Networks. As a Network Engineer, he has a real passion for Wi-Fi.

    Picture Picture Picture

    Categories

    All
    5G
    5GHz
    6GHz
    802.11
    802.11ax
    802.11v
    802.1X
    AirConsole
    Aruba
    ArubaOS
    AutoCAD
    Automation
    Brand
    Capture
    Cisco
    Cisco WLC
    CLI
    Cloud
    Co-Channel Contention
    Controller Upgrade
    Course
    CWNE
    CWNP
    Design
    DFS
    Diagrams
    Ekahau
    FreeRADIUS
    Frequencies
    FSPL
    Hotspot
    Ideas
    Industry Canada
    Interference
    ISED
    Jetson Nano
    KRACK
    London
    MagicQuadrant
    MakeWi FiVisible
    MakeWi-FiVisible
    Market
    Meetup
    Mobility Express
    News
    Packet Analysis
    Programming
    Python
    Reference Guide
    Script
    Security
    SemFio
    Site-survey
    Site-survey
    Spectrum-analysis
    Technology
    Timeline
    Tip
    Training
    Validation
    Video
    Warehouse
    WiFi
    Wi-FI
    Wi-Fi
    Wi Fi 6
    Wi-Fi 6
    Wifitraining
    Wi Fi Troubleshooting
    Wi-Fi Troubleshooting
    Wireshark
    WLAN Pi
    WLPC
    WPA2

    Archives

    July 2020
    March 2020
    February 2020
    January 2020
    December 2019
    October 2019
    August 2019
    July 2019
    June 2019
    April 2019
    January 2019
    December 2018
    November 2018
    August 2018
    May 2018
    April 2018
    March 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    May 2017
    April 2017
    February 2017
    January 2017
    November 2016
    September 2016
    August 2016
    May 2016
    April 2016
    March 2016
    February 2016
    December 2015
    November 2015
    September 2015
    August 2015
    July 2015
    April 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    June 2014
    May 2014

    RSS Feed

SemFioNetworks-EmailContact SemFioNetworks-LinkedInProfile SemFioNetworks-YoutubeChannel

Let's Talk

Please get in touch with us if you have any questions. We offer a wide variety of professional Wi-Fi services that can help your wireless environment becoming faster, more secure and more efficient!
Get in touch
SemFioNetworks-Logo
Copyright © 2020 by SemFio Networks Inc.