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 πŸ™‚
QuickLinks:
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:
* 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 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=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 πŸ™‚




Share

  242 Responses to “How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 1”

  1. Still waiting for my USB Wifi adaptor to arrive – but this looks like a great little guide. Will let you know how it goes!

    • 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 πŸ™‚

      • Where is this image on your site?

        • 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.

          Feel free to contact me if you have questions πŸ™‚

          • 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=?) ?

          • Did you run iw list to see if your adapter is capable of running hostapd ?

          • I did and yes iw list revelad under supported interface modes:
            *AP
            *AP/VLAN

          • In that case, you should be able to use nl80211 for the driver parameter πŸ™‚

  2. 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.

  3. How can I set this to automatically start when I turn the PI on?

    • You can add it into a startup script to turn it on, or add it into a script in /etc/network/if-up.d so it only turns on if the networking on the Pi goes up. Otherwise it won’t turn the AP on.

  4. i have a rt2800usb dongle connected to the pi.

    this dongle supports the master mode and i want to use it as an accesspoint.
    but it failed to start hostapd and failed to set the master mode.

    does the rt2800usb driver support the master mode ?

    in windows it works as accesspoint.

    • Theoretically it should work in Linux if it works in windows. what does iw list show ?
      what’s the error message that hostapd spits out ?

      • first, thank you for your fast reply.

        hostapd says FAIL/failed at start. i tried -v(vvvvv) but nothing appears.
        iw list dont work ! command not found

        now i have pwnpi 2.0 on the card but it is the same. i tried rt2800usb and ath9k_htc.

        alfa ubdo-n and tl wn-422g.

        • have you checked the syslog or anything for any error messages ?
          install iw and make sure AP mode is there, just in case.

          I’m not too familiar with those USB sticks as I don’t have one so I’m doing a best guess here lol.

  5. So working with a D-Link DWA-131. Driver is r8712u. When I run iw wlan0 I get a message of nl80211 not found.

    So I changed the Driver to r8712u in the hostapd.conf file. But it appears the system is trying the other. Where do I change that instance of the driver variable?

    • 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.

      • Thanks for all that extra information.

        Correct me if I’m wrong, from what I understand, the iw command makes use of nl80211, so if the iw command doesn’t work, it’s a safe bet that hostapd won’t either.

        • 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.)

  6. I have an Alfa AWUS036EH with a rtl8781 chipset. iw list says:
    *IBSS
    *managed
    *AP
    *AP/VLAN
    *mesh point
    *P2P-client
    *P2P-GO

    Haven’t finished your tut though, I’ll report back later.

  7. 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.

    hostapd:
    interface=wlan0
    driver=nl80211
    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0
    ssid=RaspAP
    hw_mode=g
    channel=10
    wpa=2
    wpa_psk=928519398acf811e96f5dcac68a11d6aa876140599be3dd49612e760a2aaac0e
    wpa_passphrase=raspiwlan
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP
    rsn_pairwise=CCMP
    beacon_int=100
    auth_algs=3
    wmm_enabled=1

    dnsmasq.conf
    interface=wlan0
    dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h

    • You may need to restart hostapd if you haven’t already using the /etc/init.d/hostapd restart command

      Also. Your config should have either WPA_passphrase or WPA_psk but not.both.

  8. I figured it out. hostapd was not starting

  9. I’ve seen a new shield to add Wifi to our Raspi. Have you heard about that? http://www.cooking-hacks.com/index.php/documentation/tutorials/wifi-module-for-raspberry-pi-roving-rn-xvee

  10. […] 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 […]

  11. 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.

    • I haven’t come across that before unfortunately. When that happens, if you restart dnsmasq, does it work ?

      • 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.

  12. I ran into some issues figuring out which driver my card uses. If you do “sudo apt-get install lshw” and then “lshw -C network”, it will display your driver info under the “configuration” section.

  13. Hi !

    First, great article. But I still have questions.

    Have you tried to connect several device to the RPi ? So if you did, how much ?

    I ask because I can’t find what’s the maximum of connexion, and what it’s depending on : the RPi, the dongle, both ?

    My point is to make an offline node.js server on witch I could connect 20 wi-fi device. You think it’s possible and rather easy ?

    And, sorry for my low level in english … french guy inside πŸ˜‰

    • Hi thanks for reading !

      I only tried with a phone and a laptop together, so only 2 devices.
      If there is any limit, it would be from the USB wifi adapter.

      I think making an offline node.js server would be a piece of cake. Assuming that the Dongle works properly of course.

  14. […] How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 1 […]

  15. small typo found. You have put ‘iw list’ instead of ‘iwlist’.
    Great tutorial though my dongle, a rtl8191, wont work as an access point so it off to the market for me.

  16. oops. bit of a linux newb, guess it shows. Shot my keyboard off before i did enough research. Please kill my previous post,
    sorry

  17. […] WiFi adapter seems to turn up everywhere you Google “raspberry pi access point” (e.g. here, here, and here)-Β primarilyΒ because its driver actually implements the nl80211 interface public […]

  18. Hi.
    Step by step with part one, I met one trouble.
    Using a RT3370 dongle, I made the RaspAP visible, but could not connect to it.

  19. Hi.
    According to Part one, I made the RaspAP visiable, but I could not connect it.
    The following is the output of ifconfig


    mon.wlan0 Link encap:UNSPEC HWaddr C8-3A-35-CF-97-B1-00-00-00-00-00-00-00-00-00-00
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:75227 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:21467123 (20.4 MiB) TX bytes:0 (0.0 B)

    wlan0 Link encap:Ethernet HWaddr c8:3a:35:cf:97:b1
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:706 errors:0 dropped:503 overruns:0 frame:0
    TX packets:651 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:181201 (176.9 KiB) TX bytes:186132 (181.7 KiB)

    • 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.

      • Yes! I made a mistake. There was a line in the intefaces “iface default dhcp”.
        I remove it and restart. Now wlan0 has IP andress.

        wlan0 Link encap:Ethernet HWaddr c8:3a:35:cf:97:b1
        inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
        inet6 addr: fe80::ca3a:35ff:fecf:97b1/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:0 (0.0 B) TX bytes:8948 (8.7 KiB)

        But the client still could not connect it .

        • Do you have dnsmasq or udchpd running to hand out IP addresses ?
          What sort of client is it ?
          What’s the config of the dhcp server ?


  20. sudo service dnsmasq status
    [ ok ] Checking DNS forwarder and DHCP server: dnsmasq[....] (running).

    dnsmasq.conf

    server=8.8.8.8
    interface=wlan0
    dhcp-range=192.168.0.50,192.168.0.150,24h

  21. Hi.

    Do you know how many station your dongle can manage ?

    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.

  22. […] Setup went roughly along the lines of this Raspberry Pi Access Point guide. […]

  23. […] This post is a copy from how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/ […]

  24. […] to install the drivers and configure the WiFi network on the Pi. The RT5370 can also be used as an Acess Point/Router, follow this tutorial to know more about these advanced […]

  25. 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?

    Rod

    Thanks for your documentation!!

    • Thanks for reading !

      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.

  26. 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.

  27. […] 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 […]

  28. 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.

    my hostapd.conf is the same as Jim.

    my dnsmasq.conf is:
    interface=wlan0
    dhcp-range=192.168.0.2,192.168.0.199,255.255.255.0,12h

    ifconfig displays this:

    eth0 Link encap:Ethernet HWaddr b8:27:eb:56:9e:f7
    inet addr:192.168.1.199 Bcast:192.168.1.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:1827 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1408 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:151447 (147.8 KiB) TX bytes:262040 (255.8 KiB)

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:8 errors:0 dropped:0 overruns:0 frame:0
    TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)

    mon.wlan0 Link encap:UNSPEC HWaddr F0-7D-68-F7-D8-FC-00-00-00-00-00-00-00-00-00-00
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:1721 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:450494 (439.9 KiB) TX bytes:0 (0.0 B)

    wlan0 Link encap:Ethernet HWaddr f0:7d:68:f7:d8:fc
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

  29. Rebooted and now it connected. YEY! A question, i am running an airplay server on this raspberry pi: http://trouch.com/2012/08/03/airpi-airplay-audio-with-raspberry/

    Is it possible to make it visible on the internal web i just created?

  30. […] 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 […]

  31. 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.

  32. 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?

    • Looks like wlan0 has no ip address. Run ifdown wlan0 && ifup wlan0 after hostapd starts and see how you go

      • 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!

  33. I have had this working but now I cannot get an ip address from dnsmasq. When I attempt to connect I get authenticated but no ip is issued.

    /etc/network/interfaces
    iface wlan0 inet static
    address 10.0.0.1
    netmask 255.255.255.0

    /etc/dnsmasq.conf
    interface=wlan0
    dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h

    There does not seem to be much to setup for dnsmasq. Any ideas on how to investigate this would be greatly appreciated

    thanks

    • you’re using the wrong netmask – should be 255.0.0.0 for a 10.x address.

      • doesn’t have to be, though in general that’s what people use for the 10.x.x.x range.

        In my example, I’ve just restricted it to 10.0.0.x for simplicity’s sake.

  34. okay thanks for the tip..:)

  35. Iv followed these instructions but i cant seem to get my pi to broadcast an ssid….has anybody had any problems with getting the ssid to broadcast? any help would be much appreciated πŸ™‚

  36. 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!

  37. 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.

  38. 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.

    Any suggestions?

  39. hii…
    if have to just create an hotspot and ssh wirelessly into my pi which are the tutorials should i follow…??

  40. 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.

    Any advice would be appreciated.

    • You may need to configure apache to listen on the wifi interface

    • Never mind. I was able to get things to work.

      Solved!

      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.

      So cool!

      -Mike

  41. 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.

    Thanks for the guide and your continued help.

  42. Hi,

    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. -.-

    Thanks!

    Joachim

  43. 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)

  44. The previous statement was wrong, here is the output:

    eth0 Link encap:Ethernet HWaddr b8:27:eb:56:9e:f7
    inet addr:192.168.1.199 Bcast:192.168.1.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:2577 errors:0 dropped:0 overruns:0 frame:0
    TX packets:2010 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:235286 (229.7 KiB) TX bytes:1600111 (1.5 MiB)

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    mon.wlan0 Link encap:UNSPEC HWaddr 00-0E-2E-4C-55-DB-00-00-00-00-00-00-00-00-00-00
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    wlan0 Link encap:Ethernet HWaddr 00:0e:2e:4c:55:db
    inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:9875 (9.6 KiB)

    root@raspberrypi:/home/pi# ip addr show
    1: lo: mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:56:9e:f7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.199/24 brd 192.168.1.255 scope global eth0
    3: wlan0: mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0e:2e:4c:55:db brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.1/24 brd 192.168.0.255 scope global wlan0
    5: mon.wlan0: mtu 1500 qdisc mq state UNKNOWN qlen 1000
    link/ieee802.11/radiotap 00:0e:2e:4c:55:db brd ff:ff:ff:ff:ff:ff

  45. […] Inspiration to this tutorial, and thanks goes toΒ sirlagz.net […]

  46. […] Raspberry Pi β€’ View topic – 16 x 2 LCD case screen pwnieexpress/Raspberry-Pwn Β· GitHub How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 1 Β» The Rantings and Ravings o… raspbian – Boot without starting X-server – Raspberry Pi Beta – Stack Exchange […]

  47. Thanks for these instructions.

    After following all the steps as close as possible and when running hostapd I get:

    Could not read interface wlan0 flags: No such device
    Could not read interface wlan0 flags: No such device
    nl80211 driver initialization failed
    rmdir[ctrl_interface]: no such file or directory

    however, when running iwconfig, I can see the wlan0 interface…
    could you please help me?

    • What device are you using ?

      • I am using a BI687 based on the RT5370 chipset

        • Have you install the firmware for the RT5370 via apt-get ?
          Can you also run a lsmod and make sure you have the rt2800usb module loaded ?

          • [Thanks for the great tut]

            Going through it right now, running into the same issue.

            No, I haven’t specifically installed the firmware via apt-get. Is there a package I should find/download?

            Here’s what lsmod shows:

            $ lsmod | grep rt2800usb
            rt2800usb 14940 0
            rt2800lib 55351 1 rt2800usb
            rt2x00usb 11215 1 rt2800usb
            rt2x00lib 42334 3 rt2x00usb,rt2800lib,rt2800usb

          • If you run ifconfig -a
            do you see wlan0 ?

            dpkg -l | grep ralink will tell you whether the firmware is installed

          • It looks like the firmware is installed:

            $ dpkg -l | grep ralink
            ii firmware-ralink 0.36+wheezy.1 all Binary firmware for Ralink wireless cards

            If I run $ifconfig -a, here is my output:

            $ifconfig -a
            eth0 Link encap:Ethernet HWaddr b8:27:eb:23:2d:bc
            inet addr:10.168.2.3 Bcast:10.168.2.255 Mask:255.255.255.0
            UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
            RX packets:1111 errors:0 dropped:0 overruns:0 frame:0
            TX packets:574 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:169815 (165.8 KiB) TX bytes:78264 (76.4 KiB)

            lo Link encap:Local Loopback
            inet addr:127.0.0.1 Mask:255.0.0.0
            UP LOOPBACK RUNNING MTU:16436 Metric:1
            RX packets:8 errors:0 dropped:0 overruns:0 frame:0
            TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)

            So no, I don’t see wlan0.

            For what it’s worth, the output of iw list is empty.

          • Ok. I think I’ve figured out the problem.

            If I run lsusb, it appears that my RT5370 is actually not a RT5370, but a RT2870/RT3070.

            Found this thread (thanks for being there – it looks like you’re everywhere)

            http://www.raspberrypi.org/phpBB3/viewtopic.php?p=361671

            Which points me to:

            http://www.geekamole.com/2013/rt2800usb-fix-for-ralinkmediatek-3070-gentoo-linux/

            I’ll see how this works.

            [Sidenote: This is the dongle that I bought. I received a refund, and bought a different one that should be on the way.]

          • Ah. That explains it somewhat.
            Cool, Hopefully the new dongle will work better πŸ™‚

  48. 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

    • Glad it helped !

      Yes, the Pi can route packets whichever way you want. As long as IP tables is setup properly.

  49. 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.

    Thanks again.

    • 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!

  50. srr im new at this. can u tell me were to put this

    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.

    thnx!! ^_^

  51. Hi!!! I finish all the steps and getting this error

    pi@raspberrypi ~ $ /etc/init.d/hostapd restart
    [ ok ] Stopping advanced IEEE 802.11 management: hostapd.
    [….] Starting advanced IEEE 802.11 management: hostapdrmdir[ctrl_interface]: No such file or directory
    Segmentation fault
    failed!
    pi@raspberrypi ~ $

    do u think u can help me..
    thnx for ur time!! ^_^

    • Hey,

      I guess you already found a solution, but maybe someone else may discover the same issue, as I also stumbled over the this problem. After some trying, this is how I was able to fix it:

      I changed the hostapd configuration file name to
      “/etc/hostapd/hostap.conf”

      note, that following the instructions above, you will also need to change this information in “/etc/default/hostapd” for the “DAEMON_CONF”

      This did the trick for me.

    • Hey,

      I guess you already found a solution, but maybe someone else may discover the same issue, as I also stumbled over this problem. After some trying, this is how I was able to fix it:

      I changed the hostapd configuration file name to
      “/etc/hostapd/hostap.conf”

      note, that following the instructions above, you will also need to change this information in “/etc/default/hostapd” for the “DAEMON_CONF”

      This did the trick for me.

  52. 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 :)))))

    • So is this a PERL script you’re using to update the config ?
      Can you paste the contents of the PERL script ?

      Maybe try this –
      Config::Simple(syntax=>’simple’);

  53. 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

    • Hi,

      I don’t think it’d be possible as the access point can’t see devices until the device connects to the AP. You could log all clients that connected to the AP though.

      It’d be possible with bluetooth, but then you’d need to make sure the device has bluetooth, AND the device has to be discoverable.

  54. Looking for some advice/ideas
    I’m looking to stream video from a GoPro (that’s wifi enabled) from one room to another (+- 40meter apart) where a screen is situated.
    Could I use this method of yours?

    • Possibly…Will you have the Pi connected to the screen ?
      If you have a big WiFi antenna, it’ll work.

  55. […] 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! […]

  56. Thank you, this made my day!

  57. 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.

  58. 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

  59. lsmod

    Module Size Used by
    snd_bcm2835 16432 0
    snd_pcm 77728 1 snd_bcm2835
    snd_page_alloc 5169 1 snd_pcm
    snd_seq 53482 0
    snd_seq_device 6462 1 snd_seq
    snd_timer 20110 2 snd_pcm,snd_seq
    snd 58744 5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
    rt5370sta 777914 1
    leds_gpio 2243 0
    led_class 3570 1 leds_gpio

    I added rt2800usb drivers into blacklist, because it didnt go and here is my lsmod, what show, that I use rt5370sta, but when I write driver=rt5370sta it doesnt work, any solution? Thanks

    • The Ralink rt5370sta drivers don’t support hostapd by default. You’ll need to use the stock linux kernel drivers to use hostapd from the repository.

      • Fuf, I am beginner in linux, can you write me how to do it?

        • don’t blacklist the rt2800usb drivers, and don’t load the rt5370sta drivers

          • but with rt2800usb drivers it doesnt work πŸ™‚

          • Which device do you have ?
            What’s the output of lsusb ?

          • 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…

          • Do you have the firmware installed ?

          • 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? πŸ™‚

            S3ky

          • Can you reflash Raspbian ? That would make things easier

            You can find me on Raspbian or Raspberrypi IRC channels if you want to chat.

    • Ok, now, when I change another WiFi USB adapter it works!, I mean I see AP as WiFi network, but when I type iwconfig I see that:

      mon.wlan0 IEEE 802.11bgn Mode:Monitor Frequency:2.437 GHz Tx-Power=20 dBm
      Retry long limit:7 RTS thr:off Fragment thr:off
      Power Management:on

      wlan0 IEEE 802.11bgn Mode:Master Tx-Power=20 dBm
      Retry long limit:7 RTS thr:off Fragment thr:off
      Power Management:on

      lo no wireless extensions.

      eth0 no wireless extensions.

      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

  60. but with rt2800usb drivers it doesnt work πŸ™‚

  61. […] How to use the Raspberry Pi as a wireless access point router […]

  62. Hi, i followed your tutorial and i have configured according to your tutorial my /etc/network/interfaces file looks like this..

    auto lo
    iface lo inet loopback

    iface eth0 inet static
    address 192.168.2.30
    netmask 255.255.255.0
    gateway 192.168.2.30
    iface default inet dhcp

    auto wlan0
    #allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.137.30
    netmask 255.255.255.0
    gateway 192.168.137.1
    wpa-ssid “hotspot”
    wpa-psk “raspberry”
    #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    #iface default inet dhcp
    #up iptables-restore < /etc/iptables.ipv4.nat

    when i try to ping to this ip address it says request timed out… can you please tell me thy this is happening ..?? i just want to ssh into that wireless hotspot from raspberry pi..

  63. 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!

    • iw list says there is ap mode.

    • You should be using the nl80211 driver. What’s the output of lsusb ?

      • ‘rt2800usb’

        • what’s the vendor and device IDs ?

          • Well, it’s something different: Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

          • Well, it’s something different: Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

            With the nl driver, sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf says:

            β€œConfiguration file: /etc/hostapd/hostapd.conf
            Could not read interface wlan0 driver=nl8 flags: No such device
            ioctl(SIOCGIFINDEX): No such device
            rtl871xdrv driver initialization failed.”

            I think I’m using a hostapd from adafruit,
            wget http://www.adafruit.com/downloads/adafruit_hostapd.zip
            unzip adafruit_hostapd.zip
            sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
            sudo mv hostapd /usr/sbin
            sudo chmod 755 /usr/sbin/hostapd

          • Well, it’s something different: Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

            With the nl driver, sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf says:

            β€œConfiguration file: /etc/hostapd/hostapd.conf
            Could not read interface wlan0 driver=nl8 flags: No such device
            ioctl(SIOCGIFINDEX): No such device
            rtl871xdrv driver initialization failed.”

            I think I’m using a hostapd from adafruit,
            wget http://www.adafruit.com/downloads/adafruit_hostapd.zip
            unzip adafruit_hostapd.zip
            sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
            sudo mv hostapd /usr/sbin
            sudo chmod 755 /usr/sbin/hostapd

          • With the RT5370, don’t use adafruit’s version of hostapd.
            Just use the version of hostapd that is in the repositories of Raspbian.

          • How do I get that version back?

          • I’d start from scratch. It’d be easier than trying to remove it.

          • How?

          • Reflash the SD card with a Raspbian image

          • So there is already hostapd in Raspbian by default? Because I have 4 preloaded SDs, 3 boards, and all the components.

          • There is hostapd in the Raspbian Repositories, which you can then install via apt-get. However it’s not installed by default on the Raspbian Images.

      • With the nl driver, sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf says:

        “Configuration file: /etc/hostapd/hostapd.conf
        Could not read interface wlan0 driver=nl8 flags: No such device
        ioctl(SIOCGIFINDEX): No such device
        rtl871xdrv driver initialization failed.”

  64. 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”

  65. 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 started off using this tutorial http://elinux.org/RPI-Wireless-Hotspot but could not get it to work and yours is a lot clearer. Hence why ip address are different – so I’ve also run

    sudo ifconfig wlan0 192.168.42.1

    output of ifconfig

    eth0 Link encap:Ethernet HWaddr b8:27:eb:f1:0d:93
    inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:1275 errors:0 dropped:0 overruns:0 frame:0
    TX packets:785 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:981876 (958.8 KiB) TX bytes:79062 (77.2 KiB)

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:8 errors:0 dropped:0 overruns:0 frame:0
    TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)

    wlan0 Link encap:Ethernet HWaddr 00:0f:54:0d:8e:69
    UP BROADCAST MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    ouput lsusb

    Bus 001 Device 005: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

    /etc/hostapd/hostapd.conf

    interface=wlan0
    driver=n180211
    ctrl_interface =/var/run/hostapd
    ctrl_interface_group=0
    ssid=My_AP
    hw_mode=g
    channel=8
    wpa=2
    wpa_passphrase=raspberrypi
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP
    rsn_pairwise=CCMP
    beacon_int=100
    auth_algs=3
    wmm_enabled=1
    ignore_broadcast_ssid=0

    /etc/default/hostapd
    DAEMON_OPTS=”/etc/hostapd/hostapd.conf”

    /etc/network/interfaces

    auto lo

    iface lo inet loopback
    auto wlan0
    iface wlan0 inet static
    address 192.168.42.1
    netmask 255.255.255.0

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

    /etc/dnsmasq.conf

    interface=wlan0
    dhcp-ranhe=192.168.42.2, 192.168.42.20, 255.255.255.255.0, 12h

    • 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

      • Do you get any messages in the logs ?
        /var/log/daemon or /var/log/dmesg or /var/log/messages ?

        Also, what’s the output in the terminal say ?

        • Thanks for the reply

          sudo /etc/init.d/networking start
          >> [….] configuring network interfaces..ifup: interface wlan0 already configured done.

          sudo service hostapd start
          >> [ ok ] Starting advanced IEEE 802.11 management: hostapd

          sudo service dnsmasq restart
          >> [ ok ] Restarting DNS forwarder and SHCP server: dnsmasq

          pastebin.com/6ZHKqQGw for output of ifconfig after starting services

          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!!!!

          • solved! just needed to put in the ipaddress of the pi 10.0.0.1 rather than that of the macbook 10.0.0.13. cheers for your help.

          • Awesome, good to hear ! πŸ™‚
            Have fun with your new AP πŸ™‚

  66. Hi Sirlagz, thanks for the tutorial; but my AP is not visible. Any help appreciated.

    Wifi Dongle Chipset: Ralink rt5370
    sudo update
    sudo upgrade …
    uname -a
    ————–
    Linux raspberrypi 3.6.11+ #538 …

    sudo vi /etc/network/interfaces
    ——————————————–
    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp

    #allow-hotplug wlan0
    #auto wlan0
    iface wlan0 inet static
    address 192.168.42.1
    netmask 255.255.255.0
    #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    #iface default inet dhcp

    ifconfig
    ———–
    I can see the mon.wlan0 and wlan0 interfaces up. wlan0 interface has ip 192.168.42.1

    sudo vi /etc/default/hostapd
    —————————————–
    DAEMON_CONF=”/etc/hostapd/hostapd.conf”

    sudo vi /etc/hostapd/hostapd.conf
    ————————————————-
    interface=wlan0
    driver=nl80211
    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0
    ssid=myAP
    hw_mode=g
    channel=6
    auth_algs=3
    beacon_int=100
    wmm_enabled=1
    wpa=2
    wpa_paraphrase=test
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP
    rsn_pairwise=CCMP

    lsmod | grep rt2800
    —————————
    I see rt2800usb, rt2800lib, rt2x00usb, rt2x00lib, mac80211

    sudo /usr/sbin/hostapd -d /etc/hostapd/hostapd.conf
    —————————————————————————-
    hostapd starts, did not see any errors in the log

    But can not see “myAP” listed on my laptop WiFi n/w list. My laptop is next to my RPi.

    I have setup isc-dhcp-server, but I guess that will come into play only when connecting so not giving that config
    I use my Samsung G3 power adapter (5V 1A) to power pi

    • Can other devices see the AP ?
      Everything looks ok to me…

      • 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.

  67. 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.

    Follow the instructions in the guide about installing and setting up hostapd.
    – If you have driver issues try this . I had to build hostapd myself from a download on the realtek site.
    – You need to add a line to the hostapd.conf file as defined in this guide
    bridge=

    Install bridge utilities (sudo apt-get install bridge-utils)
    – Now modify your interfaces file (/etc/network/interface). The bridge utilities will do a lot of the work, so it’s pretty simple.

    auto lo

    allow-hotplug wlan0
    auto wlan0
    auto eth0

    iface lo inet loopback
    iface eth0 inet manual
    iface wlan0 inet manual

    auto access_point
    iface access_point inet dhcp
    bridge_ports eth0 wlan0

    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.

  68. hi, could you help me out on this problem.
    The rPI access point is not showing up. I received this error when i run :

    pi@raspberrypi ~ $ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
    Configuration file: /etc/hostapd/hostapd.conf
    Line 2: invalid/unknown driver ‘nl80211’
    1 errors found in configuration file ‘/etc/hostapd/hostapd.conf’

    i am using RT5370. I’m a little confused of why did you put nl80211 ?
    am i wrong in thinking that RT5370 is the driver?

    • RT5370 should use the nl80211 driver when running hostapd. Not sure why it’s doing that. Make sure you don’t have any whitespace where you shouldn’t have.

  69. hi, sorry for my bad english
    i have tried this guide with same exact configuration and seems all went good but when i digit

    sudo /usr/sbin/hostapd -d /etc/hostapd/hostapd.conf

    seems rasPi is in “listen mode” but when i try to connect with pc or tablet or anything alse keep coming out those messages:

    wlan0: STA mac_address IEEE 802.11: did not acknowledge > authentication response
    wlan0: STA mac_address IEEE 802.11: did not acknowledge > authentication response
    wlan0: STA mac_address IEEE 802.11: did not acknowledge > authentication response
    etc

    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

    anything else to try?
    thanks

  70. 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

    sudo service hostapd start
    [….] Starting advanced IEEE 802.11 management: hostapdIllegal instruction
    failed!

    Being a complete beginner I have no idea where to start to debug this, can you give any pointers

    • Sounds like somehow Debian ARMHF sources got mixed in. You’ll need to remove all the Debian ARMHF packages and install *RASPBIAN* packages for hostapd.

      • Could you point me to somewhere that will help me to do this, or suggest the commands needed as I am a complete newbie to this.

        And thank you for taking the time to reply

  71. Hi i am using the TL-WN725N Adapter. I get an error on my driver nl80211 generic netling not found.
    can someone help me?

  72. […] mobility, I already had the Pi as WiFi access point using hostapd (check these steps) and power bank, so it’s now matter of performance. In the case of rsync, initial sync of […]

  73. […] said, I must admit, I wasn’t all that crazy about Conroy’s setup, so I used this guy’s setup […]

  74. I see the connection and all, but when I connect to it I get “Windows was able to connect to PiFi”

    What can I do to fix that?

    • Double check that the security is configured correctly. You could try without security altogether to make sure that the WiFi AP is working properly.

  75. 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

  76. […] 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 […]

  77. I use MT7601U adapter. So what should i write in driver parameter?? Help plz

  78. Hello,

    First of thank you very much for such a detailed tut. I am having an issue and I believe that it is that wlan1 (this is the interface that I want as I have both wlan0 and wlan1) will not obtain a static ip of 10.0.0.1.

    my network/interfaces file is:

    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet dhcp

    iface wlan1 inet static
    address 10.0.0.1
    netmask 255.255.255.0
    ————————————–

    my dnsmasq.conf

    interface=wlan1

    dhcp-range=10.0.0.2,10.0.0.50,255.255.255.0,12h
    ——————————————————————-

    I can see my test SSID but it continuously tries to connect and my hosted output keeps repeating

    Data/PS-poll frame from not associated STA ac:fd:ec:41:14:25
    Association Response to the STA has already been sent, but no TX status yet known – ignore Class 3 frame issue with ac:fd:ec:41:14:25

    Anyone have any ideas? Thank you in advance!

    Gags

  79. Those steps are the same to configure to what wifi i want to connect? i want to configure from a html page. (like arduino run does).
    Thanks.

    • No, These steps are for a raspberry pi to act as a wireless network.

      I’m unsure if there are any web pages dedicated to configuring which network a Pi connects to, however my RaspAP project does have this functionality included.

  80. I did all correctly and I did not see any error but in the end I canΒ΄t see the access point on my laptops or smartphones.

    Can you help me? Is there any way to see if it is really working?

    • You can check if hostapd is actually running with the command /etc/init.d/hostapd status. If it’s not running then you will need to check the logs to see why it’s not running.

  81. Hey,
    I did all the things right in your tutorial, but the AP is not showing up.

    And yes… Hostapd is running.

    Heres my hostapd.conf:
    interface=wlan0
    drive=rt2800usb

    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0

    ssid=RaspberryPi
    channel=1
    hw_mode=g
    ieee80211n=1
    ignore_broadcast_ssid = 0

    wpa=2
    wpa_passphrase=1234567890
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP
    rsn_pairwise=CCMP

    country_code=DE

    My daemon_conf path is correct.

    Thanks!

    • Ok, Im a step further.
      I want to do this:
      sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

      It threw some errors I fixed, like the typo in “driver” or the driver itself. It it the same, as in your tutorial now.

      Now, the only error is:
      Failed to initialize interface

      Why?

      • One thing more:
        When I type in “/etc/init.d/hostapd status” I get:
        Feb 17 16:51:57 raspberrypi hostapd[640]: Starting advanced IEEE 802.11 management: hostapd failed!

        • Ok… I got it. What shitty error… let me explain:
          I used this to got more information about the error: sudo hostapd -d /etc/hostapd/hostapd.conf

          It was saying, that in line 4 (see first post) there are some spaces behind 0.
          The error was showing something like this: ‘0 ‘
          I removed the space… AAAAAAND it worked!

          • Awesome to hear that you got it working.
            Seems hostapd gets a bit nitpicky about spaces in the configuration file

  82. First of all, thanks for the great tutorial.

    I’m having difficulties setting it up. I follow your tutorial (difference being in the driver, although it is exactly the same device) and I get it working (at least I can see and connect to the network. Can’t browse any website). Then I reboot my Pi and I can’t see the network anymore. Any clues?

    • Is hostapd starting up when you reboot?

      • No, I start it up manually after reboot

        • Update: ran sudo hostapd -dd /etc/hostapd/hostapd.conf and realized my issue was a too small wifi password… With that out of the way I can now connect after reboot, but I can’t seem to be able to browse any websites. Tried accessing with my phone, same thing, but I keep getting app notifications… Any clue?

          • Can the RPi access the internet?

          • Yes, the Pi is working normally and can access the internet. Does this from daemon.log tell anything?
            raspberrypi hostapd: wlan0: STA **:**:**:**:**:** IEEE 802.11: authenticated
            raspberrypi hostapd: wlan0: STA **:**:**:**:**:** IEEE 802.11: associated (aid 1)
            raspberrypi hostapd: wlan0: STA **:**:**:**:**:** RADIUS: starting accounting session XXXXXXXX-XXXXXXXX
            raspberrypi hostapd: wlan0: STA **:**:**:**:**:** WPA: pairwise key handshake completed (RSN)
            raspberrypi dnsmasq-dhcp[474]: DHCPDISCOVER(wlan0) **:**:**:**:**:**
            raspberrypi dnsmasq-dhcp[474]: DHCPOFFER(wlan0) 10.0.0.3 **:**:**:**:**:**
            raspberrypi dnsmasq-dhcp[474]: DHCPREQUEST(wlan0) 10.0.0.3 **:**:**:**:**:**
            raspberrypi dnsmasq-dhcp[474]: DHCPACK(wlan0) 10.0.0.3 **:**:**:**:**:** *computer name*
            raspberrypi systemd[1]: Starting Session c2 of user pi.
            raspberrypi systemd[1]: Started Session c2 of user pi.

  83. THIS SHOULD BE BOLDED AND FLASHING IN RED AND BEEPING:
    ** Note ** You may need to strip out all the comments when you save your configuration file as hostapd does not have consistent comment handling.
    I received various issues (mostly, Could not open file /sys/class/net/wlan0 … ) until i found this hint.

  84. […] from a working device.Β  (Here’s an interesting example demonstrating how to use a Pi as a wireless card.)Β  Today, we’ll use ppp to assign an IP address to our Psion, and pass along a DNS server […]

  85. Hello,

    I am having a problem that I have not seen anyone else have. I am trying to set up my raspberry pi 3 as an access point using the built in wifi instead of a dongle and have tried multiple instructions by the book and all have failed at the same spot. This spot is that I can see the AP, but every time I try to connect to it, I type in the correct password and it always responds with invalid password. Since I am using the built in wifi, I have seen multiple sites say to comment out or delete the driver line in hostapd.conf, so I have.

    When using sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf, I get:
    Failed to create interface mon.wlan0: -95 (Operation not supported)
    wlan0: Could not connect to kernel driver
    Using interface wlan0 with hwaddr b8:27:eb:46:a6:73 and ssid “RaspAP”
    wlan0: interface state UNINITIALIZED->ENABLED
    wlan0: AP-ENABLED

    Then when I try to connect to the AP, I get:

    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: associated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: associated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    wlan0: STA 28:cf:da:d3:98:12 IEEE 802.11: disassociated
    –this repeats with varying amounts of disassociated until is stop trying to connect.

    I have only done this first part in your series and can not make a connection. Any help would be appreciated and if you need more info let me know. Thanks.

  86. You may need this

    atp-get -y install dos2unix
    dos2unix /etc/hostapd/hostapd.conf

    my line endings where causing all sorts of errors

  87. […] 2: Access Point part 1Β There is some overlap between these two what you want to focus on here is the configuration files. […]

  88. I have followed your instruction, but I can’t connect to the Rasp AP with my computer or my cell phone. Actually, I have tried several instructions provided online and the results are same.
    I have tried to see the status of dnsmasq and hostapd, which shows they are both active.
    So can you give any advice about how to solve this problem?
    Thank you very much.

    • Bit hard to troubleshoot on a blog. If you use IRC, feel free to hit me up on #raspberrypi on irc.freenode.net if you need a hand.

  89. hi i have a problem with my pi AP i can connect all devices android but in IOS (iphone) if i put a phrasse i cant connect, but if i quit the phrasee i can connect and i dont know what is the problem, thank you for your help

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.