From eLinux.org
Revision as of 06:46, 13 November 2012 by Hunternet93 (talk | contribs) (Credits!)
Jump to: navigation, search

What does it do?


What do you need?

  • A Raspberry Pi, model B.
  • A boot SD card for the Raspberry Pi.
  • A USB WiFi device that supports "Access Point" mode.
  • An Ethernet cable to connect to the local network.

What skill level is required?



sudo nano /etc/udhcpd.conf

You will find yourself in a simple editor. Move around using the arrow keys. To save the file press Ctrl-o. To exit press Ctrl-x.

How does it work?

The Raspberry Pi is configured as a WiFi Hotspot, just like you would see in an internet cafe. It allows you to connect to the internet over WiFi using the Raspberry Pi as the bridge to the internet. The basic steps are

  • Enable a WiFi Access Point and broadcast on the channel of your choice
  • Assign dynamic IP addresses to any device that connects to WiFi network
  • Join the WiFi and Ethernet networks together by using Network Address Translation



1. Install the necessary software.

sudo apt-get install hostapd udhcpd


interface wlan0 # The device uDHCP listens on.
remaining yes
opt dns # The DNS servers client devices will use.
opt subnet
opt lease 864000 # 10 day DHCP lease time in seconds






sudo ifconfig wlan0


iface wlan0 inet static


Change the lines (they probably won't all be next to each other):

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


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

3. Configure HostAPD. You can create an open network, or a WPA-secured network. A secure network is recommended to prevent unauthorized use and tampering, but you can also create an open network. To create a WPA-secured network, edit the file /etc/hostapd/hostapd.conf (create it if it doesn't exist) and add the following lines:



If you would like to create an open network, put the following text into /etc/hostapd/hostapd.conf:


Change ssid= and channel= to values of your choice. Note that anyone will be able to connect to your network, which is generally not a good idea. Also, some regions will hold an access point's owner responsible for any traffic that passes though an open wireless network, regardless of who actually caused that traffic.












up iptables-restore < /etc/iptables.ipv4.nat


sudo service hostapd start
sudo service udhcpd start


sudo update-rc.d hostapd enable
sudo update-rc.d udhcpd enable


This tutorial originally was a post on the Raspberry Pi forum here, you can reply to that topic if you have issues. Thanks go to all the people who tested my tutorial on the forum, and to poing who contributed the WPA HostAPD config.