This tutorial gives a step by step guide to setting up your Raspberry Pi to work as a wifi hotspot, and to share an internet connection from the Ethernet port of the Raspberry Pi. Check out the first part of my MultiCam tutorial if you just want a standalone Raspberry Pi that gives out its own IP addresses, without connecting to a router via Ethernet.
These instructions are for usb wifi adaptors with the popular Realtek RTL8188 chipset (mine is a cheap “comfast” model, but I believe the popular “Edimax” model also has this. There is a tutorial on the Raspberry Pi wiki, however this does not seem to assign an IP address to any device wanting to connect to the hotspot, and it simply says “Edimax does not work”, which it does, but just requires a little extra work. You can check that your usb wifi adaptor uses the Realtek RTL8188 chipset by using the following command:
lsusb
Hopefully, you’ll see something similar to this: (Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter), listing the WLAN/wifi usb adaptor chipset.
Guide:
1. Update, and install a some required software packages
sudo apt-get update
sudo apt-get install bridge-utils
2. Install hostapd using the following commands. This is the custom version for the RTL8188 chipset by Jens Segers. If you have a different chipset, it may work by just installing the standard hostapd (sudo apt-get install hostapd).
wget http://download.andypi.co.uk/v1.1.tar.gz
tar -zxvf v1.1.tar.gz
cd RTL8188-hostapd-1.1/hostapd
sudo make
sudo make install
3. Edit the hostapd configuration file (should have a list of comments already):
sudo nano /etc/default/hostapd
Add the line:
DAEMON_CONF=”/etc/hostapd/hostapd.conf”
4. Edit the hostapd.conf configuration file, but choose your own “ssid”, “wpa_passphrase” (8 – 63 charaters long) and “country_code” (Note: My auto install script originally replaced this file directly, however for some reason this fails on startup of hostapd, so editing the original file seems to be the most reliable method. Not sure why, its a bizarre problem.)
sudo nano /etc/hostapd/hostapd.conf
5. Modify your network interfaces file
sudo nano /etc/network/interfaces
Add the lines / change so the file reads:
auto lo
auto br0
iface lo inet loopback
iface br0 inet dhcp
bridge_fd 1
bridge_hello 3
bridge_maxage 10
bridge_stp off
bridge_ports eth0 wlan0
allow-hotplug eth0
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
6. Make hostapd start at boot time.
sudo update-rc.d hostapd defaults
7. Restart the networking and hostapd services, and you’re good to go.
sudo service networking restart
sudo service hostapd restart
AndyPi sources and info on the same topic:
http://blog.sip2serve.com/post/48420162196/howto-setup-rtl8188cus-on-rpi-as-an-access-point
http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=19120&start=250
http://www.jenssegers.be/
http://follywood.no-ip.org/docs/Raspberry%20Pi/pi_wifi_ap.pdf
http://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software
13th May 2014 at 3:53 pm
Hi, First a gigantic thank you for this awesome skript !!!! I spent days trying to get it running by following several frustrating tutourials, this worked out of the “box”.
One question though, the connection is rather slow, my internet connection is not the weak point, but loading youtube videos at higher quality is not smooth and the speed over all is not really consistent, sometimes i have to wait for google, some times its instant, is there a way i can change that by configuring or is it just a restriction of my hardwre?
Thanks again!
George
2nd April 2014 at 11:24 am
Hello Andy
This is exactly what I’ve been looking for step by step instructions, looking forward to trying out when I get home from work. Please can you tell me if there is a way to set it up so there is no wireless connection with the internet? All I would like to do is wirelessly communicate from my laptop to my Pi which will be on a moving time lapse rig. I’m happy for ‘normal’ internet connection to the Pi to be via ethernet. Apologies if I’ve completely misunderstood what you describe above.
Cheers
Mike
15th March 2014 at 9:06 pm
Hi all. I am trying to get my Pi to become a hotspot but for some reason something isn’t working.
This is the message I got: Stopping advanced IEEE 802.11 management: hostapd.
Starting advanced IEEE 802.11 management: hostapdioctl(RTL_IOCTL_HOSTAPD): Operation not supported
22nd February 2014 at 11:07 am
Hey,
I’ve just executed the automatic script and everything went fine until the RPi reached a point stuck at “Re-configuring wifi adapter” as i remember.. anyway i rebooted it and saw that it started to broadcast its signal but when i connect my android phone to it, it freezes at obtaining ip address.
so my questions are:
1- what’s the problem with the previous issue?
2- how can i rename my wifi network/passowrd?
3- can i reverse the operation? so the RPi will no longer be access point.
Thx alot and nice work 🙂
10th February 2014 at 9:27 pm
Thank you ! 🙂 Work fine !
8th February 2014 at 12:19 pm
Hi Andy,
Thank heaps for this article. I want to remove the bridge between the ethernet and the wifi hotspot and use the RPi to directly provide IP addresses to the connecting devices, could you please give me pointers on how to get started with that. My idea is to just have the Pi become a server to which other devices directly connect.
Any help will be great!
Thanks in advance.
20th October 2013 at 8:07 pm
Hi Andy,
I can see the ssid but cannot connect from a smart phone. I have 8188eu driver installed. I have run your script. And changed key and ssid in config file. I am using tplink wn725n USB nano dongle. I can connect to internet from pi on eth0. Any ideas why the phone cannot associate with AP
cheers
ted
p.s. Excellent work btw
26th October 2013 at 10:00 am
Hi Ted. My first guess would be that the issue is with the phone rather than the hotspot, since I think some phones don’t allow you to connect to this type of wifi AP. Try connecting to the AP with a laptop and see if that works, then you’ll know for definite if its the phone or the Pi setup that is the problem.
Cheers
Andy
7th October 2013 at 3:01 pm
I relish, result in I discovered exactly what I was having a look for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye
9th August 2013 at 11:58 pm
Great tutorial… worked first time for me 🙂
Any chance dhcp could be added?
Thanks Again
Ben
29th July 2013 at 12:16 am
Works Like a charm 🙂 tried it with the latest Raspbian July 24th and It’s up an running without me doing any thing ..
although the execution is unaffected I just noticed that bash complained about the script file starting with some unreadable characters (probably UTF-8 BOM) or something .. wouldn’t hurt to strip those out..
this is actually my second attempt .. I tried the script earlier today on RaspBMC and it ended up with broken interfaces config even on the wired connection ..
I understand RaspBMC lacks some of the essential tools (I noticed a missing “make”) that would definitely require some configuration prior to running the guide .. I think it would be really helpful if you try the guide on Raspbmc and (please) make a script that prepares raspbmc for this guide .. I mean, XBMC as a UPNP server + autonomous wireless hotspot would definitely be something …
18th July 2013 at 2:31 pm
Andypi
I guess I am doing the reverse of what you are doing.My pi is connected wireless and I want to
use the free ethernet port to connect my smart blue-ray player to the internet through the pi.(bridging)
I have found many guides but none of them work so far.Yours is the easiest by far.
Paul
11th August 2013 at 5:48 am
Hi Paul, yep that makes sense. Basically you need to totally ignore my tutorial! There’s not much that can help you. If you haven’t found something already, try this blog which has very detailed instructions on exactly what you are looking for: http://rbnrpi.wordpress.com/project-list/wifi-to-ethernet-adapter-for-an-ethernet-ready-tv/
Hope you get it working!
14th July 2013 at 12:56 am
I tried the automatic script.Then edited /etc/hostapd/hostapd.conf to my ssid and password,also changed the channel to 11.This does not work for me.I have tried other guides and I always get the same problem,as soon as i have anything in /etc/network/interfaces I lose internet connection and have to pull my card put it in a linux machine and delete the interfaces file to get connection back.I don’t know much about linux so i cant figure this out.I want my wifi connected pi to connect to my blue-ray player through ethernet.
Been trying for months! Help please
14th July 2013 at 7:54 pm
Hi Paul,
if you change /etc/network/interfaces then yes, you will change your internet connection. In this guide, the internet connection is provided TO the raspberry via ethernet (i.e. CAT5 network cable between ethernet and pi). The wifi is then set-up as a hotspot, which serves the internet connection FROM the raspberry to another device which can conenct via wifi. It sounds like you are trying to do something different to with your blu-ray player – but I’m not sure exactly what??!
AndyPi