My area was recently hit with a bad hurricane, and in preperation for the storm, we started gathering all the necessities and getting ready for several days without power. As a tech nerd, part of my preperation was making a device that was portable that we could connect to wirelessly and stream media from it while we were sitting around waiting for the power to come back on.
This project is based on the Pirate Box project, which is a wireless device that allows people to connect to it and share documents anonymously. Mine differs slightly in that my focus is on multimedia streaming.
The goal is to make a portable wireless device that can host and stream multimedia. What's the perfect device that can make this happen? A Raspberry Pi, of course! I'll be using a Raspberry Pi 3 B+ with built in WiFi, but this should work with just about any Pi as long as it has a WiFi adapter.
Setting Up the Raspberry PiSetting up the Pi requires installing and setting up the Raspbian operating system. So with a blank MicroSD card inserted into your computer, you can download the latest version Raspbian directly from the Raspberry Pi website. Then you can use a free program like Etcher to burn it to the Micro SD card.
Insert the MicroSD card into the Pi along with a monitor, keyboard, mouse, power, and a WIRED ETHERNET CONNECTION. This won't work without having a wired connection.
Then just run through the automated setup steps to set your locale, set a password and run updates, but DO NOT connect it to wireless.
Right now we should have an ethernet connection and a wireless adapter. To verify that you have both of those, you can use this command.
ifconfig -a -s
It should give you a result containing eth0 (your ethernet adapter) and wlan0 (your wireless adapter).
We want to assign the wireless adapter a static IP address that's seperate from our current network IP addresses. To do this, edit the DHCPCD configuration file
sudo nano /etc/dhcpcd.conf
and add these two lines at the bottom
interface wlan0
static ip_address=192.168.100.1/24
Again, the IP address should be separate from your current networks IP addresses. For instance, my network has an IP set of 192.168.0.X. Therfore, the IP address I'm assigning my wireless adapter is 192.168.100.X
The next step is to add DNS capabilities to the hotspot we're creating. A great tool for doing that is called DNSMasq.
sudo apt-get install dnsmasq
Copy the default dnsmasq configuration file and create a new one.
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.old
sudo nano dnsmasq.conf
In that new file, tell which adapter to use and then set the DNS range. Remember that this should match the static IP that we gave our wireless adapter.
interface=wlan0
dhcp-range=192.168.100.50,192.168.100.200,255.255.255.0,24h
Now we need to install our hotspot software and edit its default configuration file.
sudo apt-get install hostapd
sudo nano /etc/hostapd/hostapd.conf
Inside this file is where we'll have all the settings for our hotspot. The "driver" below is the default driver for the built in Pi wireless adapters. If you're using a third party adapter, be sure to change the driver accordingly. Also, you can change the SSID to be whatever you want, as well as the WPA_PASSPHRASE.
interface=wlan0
driver=nl80211
ssid=tinkerbox
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=password123
After you've saved that file, we need to edit the default hostapd file to point to this new configuration file we've created.
sudo nano /etc/default/hostapd
Find the DAEMON_CONF line and uncomment it and point it to the location of our configuration file.
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Now just start the hostapd and dnsmasq services and reboot the Pi.
sudo systemctl start hostapd
sudo systemctl start dnsmasq
sudo reboot
Comments
Please log in or sign up to comment.