Create Your Own Local Wireless Internet

Asceticism is about desire, and specifically how you limit that desire. In relation to digital networks that might consist of making your own, albeit limited, network rather than plugging into the endless fruity possibilities of the www. 

I decided to try to do this. After some research I decided the best way was to try to build a wireless access point that hosted a single website. Geographically local users could access it on laptops/phones etc, view and contribute to content.

Without going too much into the whys a wherefores I wanted to document the process itself so I could share it with others. This presumes you, like me, have not had much to do with raspberry pi’s, ssh, or the command line.

This is mostly based on closedcloud, so massive thanks to Michael Dye. It’s been updated for pi3, with it’s built in Wi-Fi, and a couple of bits added.

Stocking up

First of all you need:

  1. A raspberry pi 3, with a case and power supply.
  2. keyboard & mouse
  3. hdmi cable & monitor
  4. micro sd card and adapter
  5. A network cable
  6. A web connected computer.

Install the OS

First of all you need to install raspian Jesse on your micro sd card. This involves going to here and downloading the zip file of NOOBS. Once you have this unzip it and copy the contents of the folder onto your sd card (which will be in it’s adapter). There is help here too

Once you have done this eject the sd card and put the micro sd into your pi. Connect up the pi to your monitor, keyboard and power supply.

When it asks, you need to install Raspian.

This will take a while, but when it has done this, rebooted, and you arrive at the desktop, plug in your network cable to the pi and connect to to your laptop. Then open terminal and type in hostname -I. The number is the ip address of your Ethernet port (mine is 169.254.28.240). Make a note of this.

Connect via SSH

SSH is a way of working with your pi without a screen or keyboard – you remotely log in via your laptop. PC users can use Putty, Mac users use Terminal. PuTTY is nice as you can copy and paste. I used Putty. Terminal on OS X gave me problems with direct ethernet connection between the mac and pi.

Mac users might better just doing everything in Terminal on the pi, so leave the keyboard and monitor connected and  jump to Update the raspi-config file

However, to SSH using puTTY connect the power to your pi, you don’t need a keyboard or screen any more. Connect your network cable to your pi and your laptop.

Download puTTY from here

When you have done this launch it, enter the ip address of the Ethernet port you noted in the previous step and click open.

This should take you to a blank black screen, type:

 ssh pi@[ip address]

Where [ip address] is what you noted down in the last step (169.254.28.xxx, in my case)

You should then be prompted for a password. The default is raspberry

Update the raspi-config file

All being well you should now be connected to the pi via puTTY or working directly in Terminal on the pi.

At this point I became a root user, it just seemed to mean I got less permissions issues and didn’t have to write sudo a million times.

Write

sudo -i

and the identifier thing on the left should change to root@raspberrypi:~#

Change the password from the default, and hostname by typing raspi-config

Arrow key down to ‘Change User Password’ make the change then follow instructions.

Do likewise down to ‘Advanced Options’ and select ‘Hostname’ and follow those instructions. When it asks you to reboot say <No>

Connect your pi to the Internet

I had loads of issues with wireless lan not working, or getting in the way of my wireless access point, so the easiest thing, I found was to connect, download what I needed, then delete the connection.

Here we enter the murky world of the nano editor and navigating round the file system. Nano is a basic text editor that allows you to change text files on your pi. To open a file you just need to write nano then the path to the document

we’re going to add the ssid (name) of our home wireless network and it’s passkey to a file called wpa_supplicant.conf (I used this as reference for connecting to wifi via ssh. As I’m root user I didn’t need to use ‘sudo’)

to do this we type

nano /etc/wpa_supplicant/wpa_supplicant.conf

this takes us into nano, then use the arrow keys to navigate and add the following at the bottom

network={
ssid=”Your_wifi_network_name”
psk=”Your_wifi_password”
}

my wifi name is SKYAA5FB7 and the passkey is GGGTYJFW, or something like that.

Once you have done this press ctrl and x to save, y, then enter to commit.

The we need to restart wlan0, our wireless port, so it connects to the web.

ifdown wlan0

then

ifup wlan0

Update Your PI

Here we need to make sure our pi has the most recent stuff installed. It’s easy, just type

apt-get update

As far as I can tell apt-get connects to the net and grabs what is needed. Update just, well, updates.

Then upgrade, using

apt-get dist-upgrade

this upgrades loads of packages and takes a while.

Install some packages relevant to our wifi access point

We need to grab and install some stuff that will help us do what we need, so use 

apt-get install rfkill zd1211-firmware hostapd hostap-utils iw dnsmasq

I’ll go through what (I think) these do as they crop up.

Also, it’s probably worth installing apache webserver and php 5 now too, as we’re connected to the web, so:

apt-get install apache2 php5

We also need to install persistant ip tables, this is where, for me, it all finally flew over my head. This is how I did it, and it worked.

apt-get install iptables-persistent

Click yes to save both ipv4 and ip v6 tables.

Delete our web connection

As we’ll be using wlan0 to broadcast our wifi signal, we don’t want to tie it up with the internet, so we have to delete the connection.

to do this we go back to

nano /etc/wpa_supplicant/wpa_supplicant.conf

and delete

network={
ssid=”Your_wifi_network_name”
psk=”Your_wifi_password”
}

so it was as before.

Once you have done this press ctrl and x to save, y to commit, then enter.

Configure dhcpcd.conf

dhcpcd.conf allows you to set a static ip address for your server. Don’t what ever you do mess with  /etc/network/interfaces like I did, this causes problems.

So:

nano /etc/dhcpcd.conf

then arrow down to the very bottom and add:

interface wlan0
static ip_address=192.168.79.50/24
static routers=192.168.79.1
static domain_name_servers=192.168.79.1

This means our site will live at address 192.168.79.50

Configure hostapd.conf

hostapd.conf allows you to define the network access point. to edit it go to:

nano /etc/hostapd/hostapd.conf

it will be a blank doc so add

interface=wlan0
ssid=myNetworkName
driver=nl80211
channel=6

where myNetworkName is whatever you want to broadcast as the name of your network – ‘StarbucksWifi’ will get lots of connections 🙂

Start hostapd at boot

I discovered it’s no good just changing hostapd, you need to start it at boot. You can do this by editing

nano /etc/default/hostapd

by commenting out (adding a # to the start of a line of code to make it stop working)

#DAEMON_CONF=””

and below adding the line

DAEMON_CONF=”/etc/hostapd/hostapd.conf”

ctrl x to save, y to commit and enter to return.

Configure dnsmasq.conf

Edit dnsmasq.conf

nano /etc/dnsmasq.conf

This is a long file, but thankfully only involves uncommenting (removing #) a few lines and adding in a tiny bit of text.

domain-needed
bogus-priv
no-resolv
address=/#/192.168.79.50
interface=wlan0
domain=myNetworkName.local
dhcp-range=192.168.79.51,192.168.79.250,2h

Reboot the pi

by typing

reboot

Your pi should now appear as a wireless network you can connect to, on your phone, laptop, whatever.

Direct all sites to us

what will annoy people, but is good for our purposes, is that this is not a portal to the wider web, just a local network, so all websites should come to our index page. This voodoo accomplishes this:

iptables -t nat -A PREROUTING -s 192.168.79.0/24 -p tcp –dport 80 -j DNAT –to 192.168.79.50:80

Then save this to the rule table by typing.

iptables-save > /etc/iptables/rules.v4

Redirect error pages to us

If an existing browser page gets refreshed then we need it to come to our index page too:

We need to edit:

nano /etc/apache2/sites-enabled/000-default.conf

After ‘DocumentRoot /var/www/html’, add:

ErrorDocument 404 /index.html

Ctrl X to save, y, then enter.

Time for a grand, final reboot!

type reboot and press enter.

All being well it all should work after a short wait. Connect your phone or laptop to the network you have made, open a browser and try to navigate to any website, and the apache test page should appear. You have php installed as well, but I haven’t got round to testing this yet.

You now have a pi as a functioning server that broadcasts over wifi. Building a website and adding content is a whole other story. You can do this by connecting your screen and keyboard again and building your site/copying your site into /var/www/html – this is where the apache test page lives, it just needs replacing. You can do this via ssh too, by transferring your website onto a usb and copying it over…but as I say – that’s another story.

Postscript.

I am not a programmer, I did some actionscript programming in the late 90’s early 00’s, but have not done any since. I studied sculpture and printmaking. This how-to has been put together by trial and error, collating lots of different sources, as I could not find a working example for the pi3. I’d be happy to hear from anyone who can help make this better in any way.

This project is born out of an interest in asceticism and DIY networking.