RASPBERRY PI AS A COMMUNITY WIRELESS NETWORK

 

This tutorial is showing how to deploy and implement a local community wireless network by low budget materials and devices.

 

The low cost and development of the follow project consists in an embedded router with built-in services, To build it was used an ARM-based PC called “Raspberry Pi”, and through some operative system and network parameters modification, was possible configure the device as a router, including a web servers with an embedded instant messaging.

You can find the repository of the project in the follow link:

 git@github.com:2ndy/RaspIM.wiki.git

In the next tutorial, it will be show what kind of modifications have to be done to transform the Raspberry Pi into a router, as well as how to run services and include them at the Raspberry Pi.

This is the step by step, enjoy it!

MATERIALS:

  • Raspberry Pi (Model A or B) Model A is enough, and is cheaper
  • SD card memory at least 4Gb
  • Wireless USB adaptor (Careful with Linux support)
  • Power supply 5V from 0.7A to 1 A
  • Batteries and a DC-DC power regulator module (Optional)
  • Raspberry Pi case

 

TOOLS:

  • LAN cable (RJ45) and Internet connection
  • USB keyboard
  • Video cables HDMI or RCA (just for the first time)
  • Laptop or desktop. (I used Ubuntu)

 

PREPARING YOUR RASPBERRY PI

 

  • The first step to start with is  downoalding Raspbian OS, all the concerning information is here http://www.raspberrypi.org/downloads
  • Once the *.img file has been downloaded you will be able to prepare the SD card:

Insert the SD card in the laptop or desktop Sd card adaptor and then type the follow in a console:

~$ dmesg

You will see in your console something similar to the image above, have into account the last line where you might find the SD card identification name, for this case is  “mmcblk0” device. Once you get the SD card Identification name, it will be necessary dismount it from the media directory, in order to do it you have to type the follow command:

~$ umount /media/”yoursdcard”

Once you SD card is unmounted, you have to type the command that is showed i the image below, in order to do a copy of the operative system image directly to the SD card.

This process migh take several minutes. When it will be done, the console will show the records and the date copied, something similar as the image below:

Now you it will be possible to see how the SD Card look like in “gparted” before extend the storage partition:

This is how the SD card look like after extend the storage partition inorder  to get more space for additional packages:

TURNING ON THE RASPBERRY PI

Now it is time to explore the Raspberry Pi, let’s connect all the periferics:

  • Wireless USB adaptor
  • Keyboard
  • HDMI cable
  • LAN cable (RJ45) to an Internet connection
  • Power Supply

After you plug all the periferics above mentioned, it will show how Raspbian boot looks like:

The first time the raspberry pi is turned on, it  will  prompt to setting up some boot package, the tool that prompted you is called “rasp-config”

In this step you will be able to enable the SSH service in order to configure the Raspberry Pi in a remote way. You should select the 8 option “ Advanced options”

Once you choose “advances options”move forward to chose the A4 option “SSH” to enable it, then select finish. Finally you will be prompt to login,  default user is “pi” and default password is “raspberry”

In order to upgrade and update all the software packages you should type this command:

~$ sudo apt-get update && sudo apt-get upgrade

Now Raspberry Pi is able to establish a SSH connection, first step is  plug a LAN cable into the Raspberry Pi, after the router automatically will assign an IP address to the Raspberry Pi. To verify the IP address was assigned, just need type “ifconfig”.

Once you get the IP address, you have to type the follow command to establish the SSH connection

~$ ssh pi@192.168.0.15

RASPBERRY PI AS A HOTSPOT

Once the above steps were  done will be time to unplug the HDMI and keyboard cables.

To become the Raspberry pi in a router is neccesary install “hostapd” and “isc-dhcp-server” software package, to get them type the follow command i the console:

~$ sudo apt-get install hostapd && sudo apt-get install isc-dhcp-server

After installed software packages, those have to be setting up, is ncessary apply changes in hostapd, dhcp server, and interface parameters. Before procede to setting up the packages, be sure the USB wireless adapter has Linux support, you could see the link below to realize what linux wireless adapters are supported:

http://wikidevi.com

In this case was used the TL-WN722N adapter, its chipset is an Atheros and its Linux driver is “ath9k_htc”

Setting Hostapd:

Hostapd is the package that allow put the USB wireless adapter in Master mode. In order to setting up you must create a text file with the command showed below and place it in the follow path:

~$ sudo nano /etc/hostapd/hostapd.conf

Once you tipped the command you will be placed in the “nano” software package editor, in it you will be able to set up the hostapd package, the below code is a basic configuration for an open security access point.

 
interface=wlan0
driver=nl80211
ssid=RP_IS4CWN
channel=6
hw_mode=g
auth_log=-1

Do not forget to save the changes once you finished. In order to make hostapd package starts always at boot time, you should set up a daemon, the below code showed how to do it. Move it into the path ~$ etc/default/hostapd and uncomment the last line [ DAEMON_CONF=”/etc/hostapd/hostapd.conf ].

Now to assign an IP for the Raspberry Pi you should move in the follow path and type:

~$ sudo nano /etc/network/interfaces

Then make sure your configuration look like the below screenshot.

In this case  10.10.0.1 IP address was choose for the Raspberry Pi, ineed you would set the IP you wish. Be sure to erase all the old wlan0 configuration, in this case last 4 lines were commented adding a # at the start of each line.

Now you must to set up the DHCP server to allow connect clients to the Raspberry Pi and get different IP addresses. In this case the “isc.-dhcp-server” software package was choose to assign IP addresses, the way you must setup the DHCP server is showed in the follow path  “etc/default/isc-dhcp-server” this how the file looks like:

In order to set the daemon, you have to uncomment the line related with the configuration server file [ DHCPD_CONF=/etc/dhcp/dhcpd.conf ] then you must write the server network interface you are using. (Note: You can set up more than one interface).

Finally you should edit the configuration DHCP server file, who is in the path “DHCPD_CONF=/etc/dhcp/dhcpd.conf” once you be there, you have to do the follow changes:

Uncomment the line called “authoritative” to assign “isc-dhcp server” as the local dhcp server.

For instance you would implement your own dhcp server as the way we showed in the image above, then save changes and restart.

After all you will be able to connect through your mobile device to the Raspberry Pi via WIFI. In other tutorial I will show how to deploy a web server.

Up votes: Down votes: