Friday 26 October 2012

Use for a pi

So I bought a Raspberry Pi, but didn't know what to do with it. After casting around for ideas, and discussing it I came to the conclusion that what I really needed was the ability to add extra storage to an iphone, ipad or nexus 7 (when I say needed....).
Of course I could have gone out and bought a Seagate Satellite but there were two reasons why I didn't :
1. They cost £150
2. Where's the fun in that ?

First thing I needed was to make the Pi wifi enabled, a PiFi if you will, so after a bit of research I was off to ebay to bag a usb dongle :

I got this one because I have read that it's easy to get working and it was. It also has the advantage of having a removable antenna (I've got a remote antenna with a magnetic base which might come in handy). 
Firstly I installed Debian Wheezy and got the dongle working by following instructions on this site.
A bit of tweaking of /etc/network/interfaces to get it working as I wanted :
auto lo
iface lo inet loopback
iface wlan0 inet static
address 192.168.5.1
netmask 255.255.255.0
network 192.168.5.0
broadcast 192.168.5.255
gateway 192.168.5.1
iface eth0 inet dhcp

All ok so far. Next step is to  get it to act as a wireless access point. I had a look here and it pointed me in the right direction; I needed to install hostapd so
sudo apt-get install hostapd
then  created a file called /etc/default/hostapd which contains :
DAEMON_CONF="/etc/hostapd/hostapd.conf"
next I created/edited /etc/hostapd/hostapd.conf :
interface=wlan0
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0

ssid=RaspAP
hw_mode=g
channel=8

wpa=2
wpa_passphrase=wlanpassword

wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
beacon_int=100
auth_algs=3
wmm_enabled=1
Next I installed a dhcp server to hand out ip addresses
sudo apt-get install dhcp3-server
Edit /etc/dhcp/dhcpd.conf :
 DHCPDARGS="wlan0";
default-lease-time 6000;
max-lease-time 72000;
log-facility local7;
subnet 192.168.5.0 netmask 255.255.255.0 {
range 192.168.5.11 192.168.5.35;
option broadcast-address 192.168.5.255;
option subnet-mask 255.255.255.0;
}
Rebooted and BOOM ! it gives out IP addresses and I can ssh into it via wifi.

I then installed and configured samba and can now read files over wifi.