SongNet: Building a Wireless Private LAN with a Raspberry Pi and a pocket router
By Gene Wilburn
There are times when you meet with a group and want to share documents in common, but your meeting place doesn’t have WiFi Internet access. It could be an informal classroom situation, a regular meetup group, or, as in my case, two music-jam/singing groups.
In one of my groups we use Dropbox for sharing electronic versions of lyric and chord sheets. In the other we use Google Drive. These work well enough when there is Internet access, but often the places we meet to set up and play don’t have WiFi available.
Dropbox and Google Drive also have two disadvantages: every time a new member joins the group, we have to set them up with Dropbox or Google Drive and Google Docs apps for sharing. Even worse is helping them make local copies of the lyric sheets on their tablets for offline access.
This was technically challenging for some members, not to mention that it requires each member to personally update their local storage regularly. In order to create a more user-friendly experience I put together a solution that I’ve dubbed SongNet.
It occurred to me, as I’m certain it must have occurred to many others, that a nifty solution would be to create a small private wireless LAN, or Intranet, that could be set up in the meetup venue room, creating a private hotspot that could be accessed by any device that members preferred, whether it was a smartphone, tablet computer, or laptop. The only required app is a web browser.
The gear needed to set up a private local wireless LAN has been around for some time and you might even have some of this in your parts bin.
- A router that also serves DCHP addresses
- A Raspberry Pi computer or equivalent
I focused on small size and portability by selecting the following three pieces of hardware:
- Raspberry Pi Zero W Linux computer
- TP-Link TL-WR802N Wireless N300 Travel Router
- High-performance 32GB MicroSD card
Any Raspberry Pi model with a built-in or external USB WiFi adapter would work. I acquired the TP-Link travel router from Amazon for around $35 Canadian. Because the MicroSD card holds the operating system, the web server, and the web contents, I wanted one with plenty of storage and one that is as fast as possible. I selected a Samsung EVO Select 32GB microSDHC UHS-I U1 Memory Card with Adapter from Amazon for around $12 Canadian.
Setting up Raspberry Pi
The first order of business with the new MicroSD card is to set it up so it can boot the Raspberry Pi. Using the SD adapter that comes with the MicroSD card, put the card into an ordinary SD slot of a Windows, Macintosh, or Linux computer download NOOBS and add the NOOBS files to the MicroSD card, following these instructions and the ones that come with the download.
This done, remove the MicroSD card from the adapter and insert it into the Raspberry Pi and boot it, connected to a monitor, external keyboard, and mouse. When it boots, choose to install which version of Raspbian you prefer. I selected Raspbian (not Raspbian Complete or Raspbian Minimal). When that’s done, reboot the Raspberry Pi and follow the prompts for resetting the password to one of your choice and selecting an active WiFi network. More prompts will follow for updating the files. This takes awhile.
The Raspberry Pi Zero has so little RAM (512MB) it strains to run the graphical desktop environment and the GUI is a significant drain on system resources, so we want to eliminate it from regular use once we’re set up. We also want to activate the SSH server in order to log into the Raspberry Pi when it’s “headless” — that is, unattached to an external monitor or keyboard.
To so this, open a Terminal application and type the following:
$ sudo raspi-config
This brings up an easy-to-follow, character-based menu.
3 Boot Options and press Enter.
Next Select B1 Desktop / CLI and press Enter.
B2 Console Autologin hit the TAB key and press
What this does is deactivate the GUI desktop environment from loading automatically, presenting you instead with a console screen with user pi already logged in. Should you need to boot up the GUI for any reason, when you’re attached to an external monitor, type the following at the Command-Line prompt:
The next step is to activate the Raspberry Pi’s SSH server so you can log in from other machines using an SSH client:
Put the cursor line on
P2 SSH then tab to
Select and press Enter.
On the next screen tab the cursor to “Yes” and press Enter.
Setting up the web server
Next, in a Terminal window or at the console, type the following commands to set up the directories to prepare for installing the web server.
$ cd /var $ sudo mkdir www $ sudo mkdir www/html $ sudo chmod -R 755 $ sudo chown -R pi
Because the Raspberry Pi Zero W is a minimalist Linux computer, I elected not to use the fully-featured Apache2 web server. Instead I opted for the simpler Webfs, a lightweight web server that is more than sufficient for serving static pages such as song lyrics.
To install webfs on the Raspberry Pi, type the following commands in a Terminal or at the Console and follow the prompts:
$ sudo apt update $ sudo apt upgrade $ sudo apt install webfs
In order to add content, we need to know the IP address of the Raspberry Pi. To find this out, type the following:
And look at the IP address for wlan0, the WiFi adapter. The IP address is the set of numbers just to the right of inet, in this case
We can first test this by opening a Terminal on a Macintosh, Linux, or Windows Subsystem for Linux (WSL2) computer and typing:
$ ssh -l pi 10.0.0.10
or whatever your IP address is for the Raspberry Pi. Answer
yes to accept the security credentials and if all is well you should now be logged into the RPi.
To populate the Raspberry Pi’s web site, we turn to another command-line utility called rsync. Go to the directory where your lyric sheets are stored on your Mac or PC and type the following in a Terminal window:
$ cd Lyrics (or whatever your directory name is) $ rsync -avz * firstname.lastname@example.org:/var/www/html/
Of course you use your IP address rather than the 10.0.0.10 for my Raspberry Pi. Then you can watch as the files transfer to the Raspberry Pi’s web directories.
To test the site, first log onto SongNet (password: singalong):
Then open a browser and point it to the IP address of the Raspberry Pi: e.g.,
You should see an alphabetical listing of your song sheets. Webfs by default allows directory listing, which, if you don’t mind scrolling, may be all that’s needed for your site. The web listing will look something like this and you simply scroll and click on the song you want to see:
If you know some HTML and want to create your own index.html page for the site, log into the Raspberry Pi and type the following:
$ sudo nano /etc/webfsd.conf
Go to the line that reads
And change it to
Because Webfs defaults to port 8000, it’s also preferable to set the port to the standard 80. This too is located in the webfsd.conf file. Go to the line that reads
And change it to
Save the changes and reboot.
$ sudo shutdown -r now
Because my groups have accumulated a very large number of files, I wrote a Perl script called buildIndex.pl that pretties this up by putting an Alphabet Selector at the top of the lyrics page and Anchors within the listing for quicker access. It also looks nice.
Setting Up the Router
Following the instructions that come with your router, log into the router using a browser. The first thing to do is to set the IP address of the LAN (Local Area Network). Choose a network IP range that is different from the one you have at home to assign what is called a “non-routable IP” range, which is a set of numbers set aside for LANs that are not connected directly to the Internet. To make typing the addresses easy, I set my router to a 10.0.0.0 network, subnet 255.255.0.0.
It’s important that the Raspberry Pi have a fixed IP address or the system won’t work. You can do this in one of two ways. One is to use the RPi’s graphical interface to log onto the portable router hotspot and follow the menus to manually assign a fixed, or static, IP address. Another way to do this is, if your router permits it, is to put the MAC address of the Raspberry Pi’s WiFi adapter in the router itself and have it automatically assigned by the router:
Users of SongNet need to type this IP address into their browsers to access the songs, so I chose to assign the address 10.0.0.10 for ease of entry.
One of the critical functions of the router is that of a DHCP server that serves dynamic IP addresses to the users of the network. When they log into SongNet they get a 10.0.0.X address that connects them to the system. This is handled in the router’s DHCP section where you set aside the range of IP addresses that are available. In this case the addresses from 10.0.0.100-199 (100 addresses) have been made available.
Test Out the System
Now that it’s all put together, it’s time for a test. Disconnect the travel router from the Internet by removing its ethernet cable, disconnect the Raspberry Pi from its external monitor and keyboard, and put the router and RPi together in a room and plug them in.
At this point it’s necessary to use your tablet or computer’s WiFi setting to join SongNet. I assigned the password singalong for joining SongNet.
Now open a browser and enter:
This should show you (and everyone logged in) your songs and allow you to select them for display.
Finally, before you unplug the local WiFi network to carry it or put it away, you should shut down the Raspberry Pi properly. To do this SSH into the Pi and type the following:
$ sudo shutdown -h now
Give it a minute to finish closing all its files then it’s ready to tote to the next gig.