Archive

Archive for the ‘RaspberryPi’ Category

RaspberryPi Wireless Access Point

January 27th, 2015 No comments

RPI_APHello there!

Unfortunately I am very busy so I am not able to add a lot of new project but from time to time
I am publishing something new just like this tutorial about

Setting up a RaspberryPi as a Wireless Access Point to provide Wireless connectivity
on another WiFi Network with a different SSID (WiFi Name) and a WiFi USB Dongle (USB WLan Adapter)

Requirements:
– RaspberryPi, I am using a Model B
– SD Card, I am using a 8Gb Sandisk Class 4
– USB WiFi Dongle, I am using a Kraun. Must support the AP Protocol, later explained
– Raspbian OS installed on the SD Card, I am assuming you know how to do that
– RJ45 UTP Cable connected to your Switching HUB / Router and Internet Connection. uh!
– MicroUSB cable for power supply

You can either log in via SSH from another computer or you can do it locally with a keyboard and
a HDMI Cable hooked to a HDMI Screen

1) Boot the RPi (RaspberryPi and “sudo su” to become root or log in as root
2) run
apt-get install rfkill zd1211-firmware hostapd hostap-utils iw dnsmasq
all together or separately to install the above packets
3) run
iw list
To check if dongle supports AP protocol. Seach for “AP” among the results of “iw list” command
4) run
pico /etc/network/interfaces
To open the file and edit so that it looks like
######################
auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet static
address 192.168.2.1
netmask 255.255.255.0
######################

address 192.168.2.1 (is the new LAN Segment, it cannot be on your other LAN 192.168.1.1 or 192.168 pfiu6ok.0.1 etc
eth0 interface gets IP address from the router’s dhcp while wlan0 interface has a static IP

5) run
ifdown wlan0; ifup wlan0
6) run
pico /etc/hostapd/hostapd.conf
To open the file and edit so that it looks like

######################
interface=wlan0
driver=nl80211
ssid=RPi_WiFi_Name
channel=7
ht_capab=[HT40-][HT40+][SHORT-GI-40][DSSS_CCK-40]
# added for security
hw_mode=g
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=YourWiFiKey
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=TKIP CCMP
#######################
RPi_WiFi_Name is the SSID of this new Wlan
YourWiFiKey is the password or the key

7) run
service hostapd restart
To restart the service

8) run
pico /etc/dnsmasq.conf
To open the file and edit so that it looks like

##########################################################
# Never forward plain names (without a #dot or domain part)
domain-needed

# Only listen for DHCP on wlan0
interface=wlan0

# create a domain if you want, comment #it out otherwise
#domain=google.com

# Create a dhcp range on your /24 wlan0 #network with 12 hour lease time
dhcp-range=192.168.2.2,192.168.2.254, 255.255.255.0,12h

# Send an empty WPAD option. This may be #REQUIRED to get windows 7 to behave.
#dhcp-option=252,”\n”
##########################################################

9) run
hostapd -B /etc/hostapd/hostapd.conf
It will give you something like this:

Configuration file: /etc/hostapd/hostapd.conf
Failed to update rate sets in kernel module
Using interface wlan0 with hwaddr c8:3a:35:ce:4f:ee and ssid ‘RPi_Wifi_Name’

10) run
service dnsmasq restart
To restart the service

11) run
pico /etc/init.d/pipoint
To edit the file so that it looks like

####################################################
#!/bin/sh
# Configure Wifi Access Point.
#
### BEGIN INIT INFO
# Provides: WifiAP
# Required-Start: $remote_fs $syslog
$time
# Required-Stop: $remote_fs $syslog $time
# Should-Start: $network $named slapd autofs ypbind nscd nslcd
# Should-Stop: $network $named slapd autofs ypbind nscd nslcd
# Default-Start: 2
# Default-Stop:
# Short-Description: Wifi Access Point configuration

# Description: Sets forwarding, starts hostap, enables NAT in iptables
### END INIT INFO

# turn on forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# enable NAT
iptables -t nat -A POSTROUTING -j MASQUERADE

# start the access point
hostapd -B /etc/hostapd/hostapd.conf
#####################################################

12) run
chmod +x /etc/init.d/pipoint
To get pipoint being executable

13) run
update-rc.d pipoint start 99 2

To add the pipont to start as a service at every boot
It should reply like this:

update-rc.d: using dependency based boot sequencing

14) run
reboot
To reboot the RaspberryPi. After that you should see a new Wlan available
name RPi_WiFi_Name with password as “YourWiFiKey” and WPA Security

Try to connect to such Wlan and you’re good to rock and roll

Once in a while you could change the SSID Name and Password and reboot

I have tested this with weekly timer which turns on the RPi during
business hours for my customers and turns it off during non business hours

Let me know if this helps you

Cheers Mates!

Raspberry Pi WiFi WLan USB Dongle TP-Link

May 19th, 2013 1 comment

Login in SSH and type

lsusb

U sould get something like

pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 007: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0781:5530 SanDisk Corp. Cruzer
Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 006: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Where the Realtek entry is the TP-Link USB WiFi Dongle

Then edit the following file as below

sudo pico /etc/network/interfaces

The default file should be like

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Change it as below

auto lo

iface lo inet loopback
#iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "your-ssid"
wpa-psk "your-password"
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Change your-ssid and your-password, but please keep the quotation marks around them

Comment out the wpa_supplicant.conf is commented out

Then reboot byt typing sudo reboot and remove the LAN cable

The Raspberry Pi will reboot and should connect to your WiFi Network

Enjoy!

Transmission BitTorrent – Export – Import downloaded torrents

May 11th, 2013 No comments

This article explains how to backup, export and then restore, import your downloaded torrents file into Transmission on a RaspberryPi

For example if you messed up with your SD and want to run the stable non development SD at night while during the day you have the chance to play around with settings

The first time I set up Raspberry + Samba Share NAS on USB Flash Drive + Transmission downloading to another USB Flash drive…it took me about 10 days

Now I am able to replicate the same configuration in less than half hour.

But one thing was still missing.

Where are all my downloaded torrents, seeding for ages?

So I wanted to be able to retrieve them all with no need to re-download them which would be pretty silly.

So here is what I have done with success.

To access the following folder I needed to enable root
sudo passwd root

Create a folder transmission_export in your home folder
mkdir transmission_export in /home/pi or wherever you want

Copy recursively the content of the following 2 folders
cp -R /var/lib/transmission-daemon/info/resume /home/pi/transmission_export

cp -R /var/lib/transmission-daemon/info/torrents /home/pi/transmission_export

Then when you have your new Transmission set up and working on your new Raspberry SD Card or whatever, you should import the files you’ve just backed up

then sudo service transmission-daemon restart and then reload the web interface.

You should find your downloaded torrents ready now to seed again!

I did not need that but you may also right click on each torrent and choose “Verify local data”, plus you may reset file owners

chown -R debian-transmission:debian-transmission resume/

and

chown -R debian-transmission:debian-transmission torrents/