Aug 102012

Part 1 – How to create a Wireless Network On Your RPi
Part 3 – How to make your RPi into a Router

In this part, we will turn the Raspberry Pi into a Wireless Access point.
All it will do is forward packets from the WiFi adapter to ethernet and vice versa. It will allow you to access your network via WiFi without needing a WiFi router.

To do this, we need to bridge the ethernet and wifi connections, and tell hostapd that we are now using a bridge connection.
In /etc/hostapd/hostapd.conf, we need to add the following line.


Add the following lines into /etc/network/interfaces to define the bridge connection.

#auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
pre-up ifconfig eth0 up
pre-up ifconfig wlan0 up
pre-up brctl addbr br0
pre-up brctl addif br0 eth0
post-down ifconfig wlan0 down
post-down ifconfig eth0 down
post-down brctl delif br0 eth0
post-down brctl delbr br0

Notice the “auto br0” is commented out. This is so the bridge does not come up automatically, as once the bridge is up, you will not be able to remotely access the Raspberry Pi until the bridge is brought down or until the bridge gets an IP address.

Once the lines are in /etc/network/interfaces, you can type in ifup br0 as root to bring up the bridge. If you are ssh’ed into the Pi, this will drop your connection.
Once it’s up, the Raspberry Pi will forward anything from the WiFi to ethernet and vice versa.

This let’s the Raspberry Pi act as a Wireless Access Point without any sort of routing. On a WiFi device, you will be able to connect to RaspAP, and it will act is if it was on the network, i.e. it will get an IP address from your normal router.

If you have found this post useful, please consider donating by pressing on the button below. Donating will help keep this site up and running πŸ™‚

Aug 092012

** Quick Tip For The QuickLinks **
If you want a wifi router, ignore Part 2, and go from this part straight to Part 3. Need internet access ? Part 2 or 3 is the go depending on your need πŸ™‚
Part 2 – How to make your RPi into a Wireless Access Point
Part 3 – How to make your RPi into a Router

Also if you are using a RTL8188CUS based device check this forum thread
** Update – 2012-11-10 **
Looks like the newest version of the Raspbian distro adds an extra line to /etc/network/interfaces which needs to be removed or commented out.
The line is wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
Thanks to hunternet93

** Update – 2016-11-06 **
As requested, I’ve added some information from the comments – courtesy of Jakimfett
To find out what driver your USB WiFi stick uses, you can use lshw -C network to find out. The driver info is shown under the configuration section. If lshw is not installed, you can install it via apt-get – apt-get install lshw

** Original Post Starts Here **

I recently bought a Wifi dongle for my Raspberry Pi – A Ralink RT5370.
While I was poking around, I noticed that the USB dongle could act as an Access Point.
I haven’t tried with any others, but the way I found out about mine is by using the iw utility.
Running iw list spat out a list of abilities.
This was a part of the list
Supported interface modes:
* managed
* AP
* monitor
* mesh point

So I decided to try it out.
I installed hostapd so that I could run an access point off the Raspberry Pi.
apt-get install hostapd

After I installed hostapd, I had to modify a few files before hostapd would run.

Before I go modifying the files though, I need to give my WiFi adapter a static IP address.
In /etc/network/ there is a file called interfaces. This file contains the details for the network adapters.
I have the lines below in order to set a static IP address.

iface wlan0 inet static

Now, we need to edit some files.
First up, I had to modify /etc/default/hostapd. The DAEMON_CONF variable was not configured, so I pointed it to a configuration file that I was about to create.

After that, I created the configuration file in the location specified.
In the configuration file, I specified the following parameters

# First we configure the interface we'll be listening on
interface=wlan0 # The interface to listen on
# The driver that is being used by the WiFi adapter, this could be different for everyone
ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon runs.

# Now onto the important WiFi configuration
# First up, the SSID or Network name. This is what other devices will see when they try to connect.
# I'm setting this to Wireless G mode. A, B, and G are available here.
# This is setting the channel that the WiFi is on, valid channels are from 1-11, or 1-14 depending on location.

# Wifi Security Settings
wpa=2 # This sets the security settings to WPA2
# The line above sets the wpa passphrase to "raspiwlan", this is obtained via the wpa_passphrase command.
# However, you can also set a passphrase like the line below.

# I've set these to WPA-PSK to indicate that we are using a Pre-Shared Key with CCMP encryption.
# Otherwise, hostapd also has a built in RADIUS server that we can use for authentcation
# But I'll leave that to another post.

# Other settings
beacon_int=100 # This sets how often the WiFi will send a beacon out.

** Note ** You may need to strip out all the comments when you save your configuration file as hostapd does not have consistent comment handling.

With the above configuration file saved, I downloaded dnsmasq in order to give my Raspberry Pi the ability to hand out IP addresses to clients that connected to the RaspAP.
apt-get install dnsmasq

For now, we’ll only do a base configuration of dnsmasq, just enough for it to hand out IP addresses so we can test out our new RasAP.

interface=wlan0 # To get dnsmasq to listen only on wlan0.
dhcp-range=,,,12h # This sets the available range from to
# It also sets the subnet mask to and specifies a lease time of 12 hours.

After the configuration file has been created in /etc/dnsmasq.conf, start up hostapd and restart dnsmasq.
You should now be able to see the WiFi network “RaspAP” and be able to connect to it and get an IP address.

In the next post, we will turn the Raspberry Pi into a bridge so that it can act as a wireless access point.

If you have found this post useful, please consider donating by pressing on the button below. Donating will help keep this site up and running πŸ™‚

Aug 082012

I’ve just installed CUPS to play around with on my Raspberry Pi, and it seems that the default configuration file is very restrictive. I am unable to even access the Web Interface from another machine as Remote Administration is not enabled.

First thing to do – allow other machines to access CUPS.
Changing Line 20 from
Listen localhost:631
fixed that first problem.

Now, I can access the CUPS Forbidden page, but nothing else.
On line 36, the code below should be present.

<Location />
Order allow,deny

Looks like CUPS is not explicitly set to allow connections from the local LAN.
Changing it to this has allowed me access from another machine, however I cannot access the “Administration” page.
That still gets me a forbidden error.

<Location />
Order allow,deny

Looking at the configuration file, again it has not explicitly specified that access from the LAN is allowed.
On line 41, the code below should be present.

<Location /admin>
Order allow,deny

Changing it to this seems to solve it

<Location /admin>
Order allow,deny

Now I can access the CUPS server from another machine on my network to configure CUPS as my Raspberry Pi is headless at the moment. Just make sure you restart the CUPS service by running /etc/init.d/cups restart after you’ve changed your configuration file !

Hope this helps people !

Aug 072012

Well, I didn’t get any response to my last post about advertisements on my blog, but I figured it must annoy everyone. So I’ve decided to remove ALL advertisements from my blog.
So from now on, if you see any advertisements on my blog, shoot me an email through the contact me form, and I will ensure that they will no longer appear.

Hopefully it makes my blog a more enjoyable read from now on πŸ™‚

Aug 042012


An updated version of this post is –>here (Part 3) <–.

Or to stream via Motion, check out this blog post !


There have been quite a few people wanting to stream a webcam from the Raspberry Pi.
If all you want is to view a webcam stream, without any motion detection, then you’ve come to the right post.
Otherwise, I’ll have a blog post up about motion later on for motion detection.

This guide should get you to the point where you can view the webcam stream from another machine via a web browser, or a media player capable of viewing mjpeg streams – e.g. VLC.

1. Compiling FFMpeg

First thing we need to do is to get a version of ffmpeg that can stream. The version that comes with the current version of Raspbian and Debian have issues streaming, so the sources from deb-multimedia are needed. All the below commands are run as root. If you are not running as root, prepend sudo to all the commands.

If you need sound for ffmpeg, you will need to also install the libasound2-dev package which enables ALSA.
– Thanks to fbutler for this

  1. Add the following lines into /etc/apt/sources.list
    deb-src sid main
    deb wheezy main non-free
  2. Run apt-get update
  3. Run apt-get install deb-multimedia-keyring
  4. Remove the second line from /etc/apt/sources.list
    deb wheezy main non-free
  5. Run apt-get source ffmpeg-dmo
  6. You should now have a folder called ffmpeg-dmo-0.11 <-- The version will change as time goes by.
  7. Change the directory to the folder containing the source. e.g. cd ffmpeg-dmo-0.11
  8. Run ./configure to setup the source.
  9. Run make && make install to compile and install ffmpeg
  10. if you are not running as root like I am, then you will need to run the above command with sudo

2. Configuring ffmpeg

Once ffmpeg is installed, we need to create a configuration file to enable ffmpeg to stream to ffserver.
ffserver is what will host the stream.

  1. We need to create a configuration file for ffserver, we will place it in /etc/ and call it ffserver.conf

    Port 80
    MaxClients 10
    MaxBandwidth 50000

    <Feed webcam.ffm>
    file /tmp/webcam.ffm
    FileMaxSize 10M

    <Stream webcam.mjpeg>
    Feed webcam.ffm
    Format mjpeg
    VideoSize 640x480
    VideoFrameRate 10
    VideoBitRate 2000
    VideoQMin 1
    VideoQMax 10

    The last stanza defines the size of the stream, and bitrate. If the parameters don’t suit each other, then the stream will not be smooth.

  2. Next, the following command needs to be put into a .sh file. This will allow you to start streaming by just running the .sh file. Let’s call it and put it in /usr/sbin as the file needs to be run as root.
    ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 5 -s 640x480 -f video4linux2 -i /dev/video0 http://localhost/webcam.ffm
  3. Once the .sh file has been created, and the above code has been placed into it, you need to make the file executable by running chmod +x /usr/sbin/

3. Start Streaming

Once the shell script and configuration file has been created, you can start streaming by running /usr/sbin/
When you run it, you should start seeing lines like this

** 1 dup!2 fps= 5 q=2.6 size= 51136kB time=00:06:56.40 bitrate=1006.0kbits/s dup=359 drop=0

This means that ffmpeg is now streaming, and you should be able to access the stream via the web address of http://<YOUR WEBCAM SERVER>/webcam.mjpeg

** Update of sorts – I continue my webcam experimentation here

If you have found this post useful, please consider donating by pressing on the button below. Donating will help keep this site up and running πŸ™‚