** 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
QuickLinks:Part 2 – How to make your RPi into a Wireless Access PointPart 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.confThanks to hunternet93

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:
* IBSS
* managed* AP
* AP/VLAN
* WDS
* 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
address 10.0.0.1
netmask 255.255.255.0

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.DAEMON_CONF="/etc/hostapd/hostapd.conf"

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
driver=nl80211
# The driver that is being used by the WiFi adapter, this could be different for everyone
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon runs.

# Now onto the important WiFi configuration
ssid=RaspAP
# First up, the SSID or Network name. This is what other devices will see when they try to connect.
hw_mode=g
# I'm setting this to Wireless G mode. A, B, and G are available here.
channel=8
# 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
wpa_psk=928519398acf811e96f5dcac68a11d6aa876140599be3dd49612e760a2aaac0e
# 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.
#wpa_passphrase=raspiwlan

wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
# 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.
auth_algs=3
wmm_enabled=1

** 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 and 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=10.0.0.2,10.0.0.5,255.255.255.0,12h # This sets the available range from 10.0.0.2 to 10.0.0.5
# It also sets the subnet mask to 255.255.255.0 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

Thanks
Feel free to ask for help if needed
I’m uploading a “Instant RaspAP Wifi Bridge” image online now to make it easier for people as well so if you wanted that I’ll make a post about it when it’s up

Unfortunately my Pi died before I could properly get the image going. I will be creating a new one based on the recent Pi developments in the coming months. In the meantime, if you use the Raspbian foundation image and follow the steps, it should be pretty easy to setup.

I’ve followed the instructions to the letter. The only part I am not clear on is the “driver=” part of the equation. I have a Realtek RTL8188CUS. Where do I find name of the driver to populate on (driver=?) ?

I got this “semi” working… after the initial setup following the tutorial. I got i working. the AP was detected and I was able to connect a device and got an IP. however, when I rebooted everything worked. except the devices I tired to connect could not get an ip.

AFAIK in the hostapd.conf file is the only place, but check the command line parameters for a driver one. also check WPA_supplicant to see what drivee that is running in case you need a different one for now.

Edit – After having a quick look online, looks like the D-Link DWA-131 does not support AP mode…
If someone donates one to me I can find out for sure though

You cannot use just any driver you would like with hostapd… hostapd currently only supports 7 drivers (hostap/wired/madwifi/test/none/nl80211/bsd). Of which, really only 1 is usefull… nl80211. It’s not as bad as it may look, because the nl80211 driver is just an interface layer and works with the majority of cards. To check if your wifi dongle is supported by nl80211, run the following command:

lsmod | grep mac80211

If you get two lines of output, your in business… If you get no output, chances are very slim that your specific adapter will work with hostapd.

Notes: The above command assumes you have a working wifi dongle. If your wifi dongle has not been configured, chances are that the drivers have not yet been loaded. Therefore, start by trying to use your wifi dongle as a client, and confirm you can connect to a AP.

That seems right based on the kernel.org page for iw. The page further states that nl80211 supports almost ALL network cards. In my experience, it can be a bit of a mission to get your drivers going for wireless cards. This is mainly because they use proprietary firmware. Because the firmware is proprietary, it does not get shipped with any linux distribution because that would violate copyright. Firmware is usually a single file that must be placed in /lib/firmware, and can be obtained from the manufacturer’s website. The second common problem I have found why nl80211 does not work with some wifi cards, is when the user tries to compile the driver from source. This is called a “stagging” driver, and will have “sta” in the driver name. (example: linux driver rt2800, stagging driver rt2870sta) When you compile the driver from source, you have to enable support for nl80211 in the make config file. However this method is prone to failure, mainly because it is dependent on a specific kernel (headers) version, and nl80211 (also cfg80211) version. Definitely not the recommend path unless you are very well versed with linux. Just try and stick to the linux drivers for your card. With the appropriate updated firmware, it should work perfectly.

(Side note: I guess technically it would be more correct to refer to “modules” and not drivers, these two terms are used to indicate the same concept in the linux community depending on the level of experience of the audience.)

I have to the best of my abilities duplicated your set up and it doesn’t send an SSID using the USB dongle RT5370. I configured DAEMON_CONF=”/etc/hostapd/hostapd.conf”. I am not sure what to do at this point to figure out what I have not done correctly. I’m a basic Linux user.

[…] a wireless bridge, taking in Internet from a WiFi dongle and sending it back out via a serial port. Here’s a great guide for enabling PPPD on the Raspi, and giving just about anything with a serial port an Internet […]

Thanks for your guide!
I have an issue where dnsmasq intermittently spews out a ‘warning’ that ‘wlan0′ ‘does not currently exist’, wlan0 does exist. I can’t work out why this is happening (I have dnsmasq starting in rc.local and wlan0 is up at the time), have you come across this/do you have any idea what might be happening? I only want an ‘ad-hoc’ network really (no bridging) but I can’t use ad-hoc mode because android fails to recognise it.Perhaps I need something different?
Many thanks.

Thanks for your reply. Sadly not. I thought I was having some success forcing wlan0 down and back up again before starting dnsmasq and hostapd but when I added this to my startup script I still had issue.
I do sort-of suspect the wireless card might not getting enough power, but I have a hub that is ‘verified’ to work with the rPi and I don’t see anything in the log to suggest that power issues. I don’t really need dns forwarding so perhaps I’ll try dhcpd when I next get the chance.

1. I have the first revision Pi (with the polyfuses).
2. Yes it’s powered w/ 2a PSU – I made a simple mod to stop the hub back-powering the pi (ala http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=8926)
3. The Wifi adapter is made by Edimax (sorry I don’t have it to hand – IIRC lsusb shows it as RT2800) – iw list confirms it runs to nl80211.

Are you using it as an Access Point, Router, or Bridge ?
If you are using it as an Access Point or Router, you will need to give wlan0 a static IP address, and also run dnsmasq or udhcpd as a dhcp server to hand out IP addresses.

I tried this a few month ago. My Dongle was a TP-LINK TL-WN721N.
I used the ath9k_htc driver.
The accespoint could not handle more than 8 station.
Finally it was explicit in the ath9k_htc driver :http://www.mail-archive.com/ath9k-devel@lists.ath9k.org/msg04823.html
quote : ”
The maximum number of stations that can be handled in
the firmware is 8, manage the station slots accordingly.
”

So there are limits but hard to find.

So if somebody knows of a dongle that can manage more station, I would really be interrested.

I have replicated your setup with mostly good results. My problem is that my wlan0 doesn’t have an IP address on boot up completion. if I run ifdown wlan0 then ifup wlan0 if gets the static IP address assigned and everything works swimmingly. I tried creating a script that takes the interface down and back up but it must not run at the end. Any ideas?

Where did you add the script or get it to run ?
You may be able to add it in to the /etc/init.d/hostapd file to get the hostapd startup to take down and bring back up wlan0 when hostapd starts, assuming that you are using Debian.

Hi,
thanks for this guide.
I saw that you ask for donations. Have you considered adding flattr (http://flattr.com/) support? This has become very popular for blog donations in europe and I’d much rather use it than paypal.

[…] gem, however, was the blog written by SirLagz, the maintainer of RSE, and specifically his post on how to turn your Raspberry Pi into an access point. While it’s not directly applicable to the current stage of development, once I start testing […]

I am facing some of the same problems as Flybeans: RaspAP visible, but i cannot connect. I looked over his posts, and where he got it to work, mine still will not connect. My connecting divice is an apple ipad2, and a table pc, running arch-linux.

[…] with SpeedBooster (model number WUSB54GSC). While working through SirLagz’s tutorial on how to turn your Raspberry Pi into an access point, I ran into a few issues. Namely, the wifi adapter that I was (attempting) to use has some driver […]

Any ideas on how to offer a BANDWIDTH-LIMITED WiFi access point to visitors. We live in New Zealand and have limited data allowances. I’d like to allow anyone to access email but not for example videos.

My only thought is to connect the Pi using 10M ethernet and configure 80211.b but that is probably still rather too fast.

Thank you for a well written tutorial! Despite that our systems seem very similar (I just bought the Pi also use an RT5370 dongle), I can only see the network but not connect to it. I uploaded some diagnostics aid at http://home.student.uu.se/chba4051/outputs.txt, if you have time to take a quick look I’d be most grateful. I have tried it a few times from scratch already, both on raspbian and raspbmc, and rebooted after I set it up. Could it be a firmware-problem? I’ve been experimenting with that too but not managed to figure out anything.

Not only comments but trailing whitspaces in hostapd.conf also cause trouble, maybe you can add a notice about that?

Yes, that was essentially it. It took me some time though to realize that I should only follow part 1 and 3 of the tutorial, but not part 2 (since I want a router, not a bridge). It is obvious when you think of it (and know what you are doing) but maybe you could add a hint about it? Thanks again!

Thanks for the tutor! It’s the best I’ve found. But I’ve got an issue. Computers in one network(Rpi’s, other Linux machines, Windows) don’t ping each other(and see each other as well). I can only ping other devices from the Rpi with hostapd. Could you please give me a hint?
Thank’s a lot for the article again!

Just been following your pi wireless access point and after some problems have managed to complete parts 1 and 3.

I did try part 2 but as soon as I put the bridge option in hostapd.conf and restarted everything and tried to connect, it kept asking me for the wifi pass phrase and kept asking me. So I moved straight to part 3 which is what I wanted originally anyway.

Biggest problem with part1 was choosing the wifi adapter, started out with a Edimax EW-7811UN which I already new iw didn’t work on this, moved to a Widemac Ralink RT5370 which did work, but won’t work now for some reason, and then finally moved to a more reliable ALFA NETWORKS AWUS036NHA.

The other problem here was the dropping of wlan0 every time hostapd was started which is covered in part3b.

Part 3 went off with out a hitch and I now have a pi raspberry router that works really well, haven’t added wifi down starter script yet or anything else but hope to look at these things when I have a spare min.

Anyway just wanted to say that these are really good how to’s and they helped a lot.

I have been trying to setup my Pi as a router using the Wi-Pi dongle (Ralink RT5370) and Raspbian, but I can’t seem to get it working.

I got to the end of Part 1 so far, but the Pi won’t broadcast an SSID. I have tried restarting the hostapd and dnsmasq services, but no luck.
The WLAN is being assigned its static address correctly, but I can’t see the network on any other computer.

I have tried adding this line: ignore_broadcast_ssid=0, but that doesn’t work either.

While a Linux noob I did manage to to get my access point to work by following these and other directions. Mr. Google is great! My smart phone and iPad both see the AP and get network addresses assigned when they connect. I ended up using udhcpd instead of dnsmasq to provide DHCP.

My end goal is to have a stand alone web server (that is not connected to the internet) that smart phones / iPads, etc can connect to. The web server would provide information to club members at meetings.

So — I got the AP to work. The RPi is configured as a web server and I can get to web pages via the hard wire interface just fine. However, when I connect my smart phone to the AP I can’t see the web server — or anything else for that matter.

I am thinking I need some sort of connection between the AP and the Apache web server. Maybe just a config setting? Maybe another software module?

I am close to my end goal. I have an AP and I have a web server. I am just stuck on this last piece that connects to two.

SirLagz — thank for the hint but I had already configured Apache to look at both interfaces.

The problem was I had set up the wlan0 and eth0 to the same network. One of my Google searches seemed to indicate that was the right thing to do. However after changing the wlan0 address to 192.168.2.121 (it was 192.168.1.121), leaving eth0 at 192.168.1.120 — and updating udhcpd to hand out 192.168.2.xxx addresses it all seemed to work.

So now I can unplug the hard wire Ethernet and still SSH in via WiFi to make changes to web pages and use a web browser to go through the access point and bring up web pages.

I tried working through your tutorial and I seem to be having one persisting issue when I try to run hostapd:nl80211: 'nl80211' generic netlink not found
Failed to initialize driver 'nl80211'
Segmentation fault

I’ve done a lot of googling over the last few days to try to figure it out, and everything I’ve found turned out to be a dead end. This may go without saying, but the iw command gives me the same error. Any help you can provide would be greatly appreciated.

Thank you very much! That was incredibly helpful and got me broadcasting the SSID from my Raspberry Pi. I really appreciate all your help — without it, I would still be bashing my head into my keyboard

does anyone know of a list of usb wlan adapters that can be recommended for AP use, which especially implies running for weeks or months unattended? Currently I’m working with a TP-Link TL-WN821N as a client to some other AP and it locks up randomly after some hours. I don’t think I’ll try using hostapd in the future with this stick. It makes no sense if I always have to run to the AP and replug the WLAN. -.-

So i followed your guide a little time ago, it all seemed to work but after a little while, in about 5 – 10 minutes the connection seemed to drop. The usb-dongle is still “sending signal” because the light is still blinking for activity. But the “RaspAP” is dropped from the menu of available wlan’s on my computer and ipad. Sometimes i can use the wifi for 30 min or more before it drops, and sometimes it doesn’t show at all. I am trying to find some kind of logfile that may explain what is happening, but i don’t know what part of the router that may be the reason for this bug. Do you have any tips on this issue?

If you want some output from ifconfig its the same as in post 31 except in
wlan0
RX bytes:0 (0.0 B) TX bytes:9875 (9.6 KiB)

Thanks for your very informative articles. As a nebie to the RasPi and Linux, is it possible for the RasPi as a router, getting its internet from an AP to route packets to either another wifi dongle or the RJ45 port, as needed?
Thanka

Thanks for the info, very useful. After going through the steps, my iPhone 5 can see the RaspAP. But when I click on it to connect it just try and try …. When I click on it in iPhone RaspAP icon, under IP address the DHCP option is highlighted. Shall I choose static and then input 10.0.0.1 there?

Basically in my project I want to connect my iPhone to a Raspberry PI and read something (like an HTTP file) there with a browser. I don’t want to make it a real AP to connect to the Internet.

You could set a static IP address. But it might be useful to see what the Pi is doing. Check the /var/log/daemon.log file to see if it mentions anything about dhcp trying to assign an ip address to your phone.

Thanks again. It is working now The wlan0 was down, I guess. I need to make sure hostapd is also start running at the time of reboot and the wlan0 10.0.0.1 is up after a reboot. I think you have mentioned somewhere which file I should configure to do these.
I could do this project because of your blog; thanks a lot!

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

Hello Everybody..when mofying a configuration file usin Config::Simple it generate two lines at the beginning at the file: thats what i get after saving with $cfg->save();
; Config::Simple 4.59
; Wed Jun 19 15:17:00 2013
then the rest of the file updated successfully as i want!
i m configuring /etc/hostapd-1.0/hostapd/hostapd.conf and the problem is when starting hostapd with the command:
hostapd /etc/hostapd-1.0/hostapd/hostapd.conf
i get an error message
Line 1: invalid line ‘; Config::Simple 4.59′
Line 2: invalid line ‘; Wed Jun 19 15:17:00 2013′
2 errors found in configuration file ‘/etc/hostapd-1.0/hostapd/hostapd.conf’!!

So is it possible to generate a configuration file without those two lines causing errors?? thx for helping me :)))))

Thanks for the tutorial. Parts are on order. I would like the access point p to create a log of every client device that comes in range. At a high level, is it possible and how could I achieve that? Thanks

[…] Part 1 — How to create a Wireless Network On Your RPi Part 2 — How to make your RPi into a Wireless Access Point Part 3 — How to make your RPi into a Router Part 3B – Issues with HostAPD ? Click here! […]

Great tutorial,
Trying to configure the my wireless dongle, but it seems hostapd is failing to start, got a generic usb dongle based on ralink rt5370 and everything else seems to be okay, modules, etc,
restarting hostapd yields

[FAIL] Starting advanced IEEE 802.11 management: hostapd failed

removed all comments and spaces from hostapd but so far no luck, will be really grateful for pointers.

Hi all,
I have trouble with my USB adapter, but after 2 days I see a good step ahead :D, I read a lot of instructions and installed in my RPi I dont know what, but I see blue light on my USB adapter and It is good, but I used wicd-curses, and in ifconfig I see interface ra0, not wlan0 it is problem? or not?…Can I go by this tutorial and everywhere is wlan0 I must rename ra0, or must I do something more?. Thanks for answer

Ralink RT5370, but version with antena, maybe it make a problem? I will test RT5370 without antena, but I dont know if it help. In lsusb I see Ralink RT5370, in dmesg with basic drivers couldnt load device or something else and blue light on adapter doesnt light up, but with rt5370sta drivers light up, but it doesnt work with hostapd…

I dont know, what you mean. But I installed driver/firmware from CD, what I have by USB wifi adapter, I copied it from CD into Raspberry Pi and next I use make,make install and modprobe rt5370sta I followed one guy, who wrote tutorial and it is working,but still is problem in hostapd.

Btw Can you give me another conact to you?..maybe facebook, or skype, or not?

Wtf about mon.wlan0?..In etc/hostapd/hostapd.conf I have interface=wlan0, but what about mon.wlan0? And in IP_forwarding and in dhcp server application I must change interfaces into mon.wlan0?..or what?..Thanks for answer

I am trying to set up hostapd with an rt2800usb dongle. However, no matter what I put for the driver in hostapd.conf, it says: “failed to initialize driver.” It doesn’t recognize my driver and I have been at my wit’s end for 3 weeks!

thanks so much for posting this – followed the access point guide and this and it works great.

i noticed that on os x (10.8), i get a true “captive portal” popup window when i connect to the ap, but i don’t on iOS (7). any ideas about what each os is checking for and how to make the pop work on everything?

Unfortunately, I’m not too familiar with the Apple side of things. Sorry !
What you could possibly do though, is do a tcpdump while the devices connect. That way you’ll be able to see what IP addresses / hostnames they are trying to resolve when they access the “captive portal”

Thanks for the post and I’m trying to follow it, but I cannot get the SSID to be visible as a network. Below are my settings. Any thoughts as to why this might be? Fantastic to see you are still supporting a post a year after writing it. Many thanks.

When I run sudo service hosted start should I see any output in the terminal window? Currently there is none .
sudo service dnsmasq restart displays [ok] restarting fns forwarder and dhcp server:dnsmasq

I reinstalled a fresh copy of the os and followed your instructions again and now I can get when i run ifconfig a inet address of 10.0.0.1 in my wlan0 settings. However I cannot see the SSID name as a wifi point to connect to. sudo hostapd start is now running and I’m getting an output in the terminal

in the log/dmesg the only thing I see that is relevant is
usbcore: registered new interface driver rt2800usb which i think relates to the ralink RT5370 I am using this messages also appeasrs in log/messages. There is nothing in the log/daemon. Can do a full pastebin of these if it helps.

Stuck a different USB dongle in the PI and now I can see and connect to the access point. None of the WPA pass key security is working but that is not a major issue. Only thing is with I put the ip address of the raspberry pi from my network settings – in this case its http://10.0.0.13 it is resolving to the localhost on my machine rather than the localhost on the pi – which works fine when viewing on the pi. Donation your way if you can resolve this!!!!

Hi SirLagz,
Figured out that my wifi adapter has gone bad. Not sure why; I had kept it plugged-in to the pi overnight once. Ordered a new one, I can see my AP and connect to it. Thanks a lot for this very helpful tutorial and your support.

If you want to set up your RPi as a true access point (not a router), that means no DHCP server on the pi – your clients will get their address from your router. This allows you to use the pi to extend your wifi network. You need to set bridging. Here’s how it worked for me after a lot of research and trial and error. Basically you set up hostapd and bridge-utils, modify the interface file and that’s it. No DNS, no DHCP. Your device will boot up, get an IP from your home router, and allow devices to connect and get their IP’s from your home router.

That last section is the key. You are defining a bridge that takes traffic from one device and just passes it on to the second device. By configuring the interface as dhcp it’s getting it’s IP (plus gateway, netmask, dns servers, etc) from your home router.

The name of the device (access_point) must be the same as in the bridge statement in the hostapd.conf file. You can call it whatever you want, I’m sure there is a limit but access_point seems to work.

There are more things you can do with bridge. You can find a good reference

Hope this helps someone. If you have two wifi dongles you can use this same logic/setup to make a range extender (i.e. no wire needed). Instead of bridging from eth0 to wlan0 you just bridge from wlan0 to wlan1.

i have one difference in wlan0 usb adapter, mine is a belkin n150 enhanced wifi usb F6D4050 (ralink rt3070) with AP mode when i give iw list command, seems have rt2x00 drivers but with nl80211 drivers loaded in hostapd.conf it did not give me any errors

My problem is a little different as I am actually trying to run this on RasPBX and I have had it running once but had problems before I took an image. Now having started again from scratch, when I try to start hostapd I get

Hello,
I am having issues starting dnsmasq
when I start dnsmasq ‘sudo service dnsmasq start’ I get the following massage:
—————————–
[….] Starting DNS forwarder and DHCP server: dnsmasq
dnsmasq: failed to create listening socket for port 53: Address already in use
failed!
——————————-
I used ‘sudo netstat -ap’ to figure out what is using that port and not sure how to read it but this is the important output I believe
—————-
tcp 0 0 *:domain *:* LISTEN
—————-
I am connected to my Pi using putty terminal putty is using port 22
I also attempted to release port 53 and obtain a new IP no luck
I dont have Network-Manager installed on my PI I am using Raspian OS

[…] with SpeedBooster (model number WUSB54GSC). While working through SirLagz’s tutorial on how to turn your Raspberry Pi into an access point, I ran into a few issues. Namely, the wifi adapter that I was (attempting) to use has some driver […]