Hotspot – WiFi Access Point

When I was thinking of buying Raspberry Pi few months ago, I was also about to buy 3G router/AP. When I learned what RPi is, and I saw people trying to make AP out of it, I knew where to place my money :) I know I’ve chosen right… RPi as AP gives you enormous number of possibilities: wireless streaming of cartoons to your tablet when you’re in the car. Your wife (if you have one already ;) ) in the same time can watch Desperate Housewives… and you can focus on pleasure from driving. I hope you’re interested already so let’s do it.

Note: this tutorial assumes that your RPi already detects your WiFi dongle. If you need to install it, please check our other tutorial.
Please make sure your WiFi dongle supports AP mode. This tutorial and script was tested with TP-LINK WN725N based on RTL8188CUS chipset.

I know there have been many tutorials on how to do this, but I believe there is none that would be a complete guide for total newbie. I had to compile information from few tutorials to set everything right. Let’s go step by step and I will try to explain what and why you need to set up. There will be surprise at the end of article so so not miss anything :)

Before we’ll go to WHAT, I will try to explain WHY.

What AP needs to be capable of to be AP :) :

  • 1. Inform devices about AP existence (Broadcast SSID) or at least allow clients to connect
  • 2. Authenticate client
  • 3. Assign IP to the client devices
  • 4. Route packages to the “output” network and the other way around

In order to handle all of this, RPi needs the following tools:

  • hostapd – Host AccessPoint Daemon – will take care of 1.
  • wpa-supplicant – tool responsible for WPA authorization for 2.(most likely you have it installed already)
  • isc-dhcp-server – will take care of 3.
  • ip-tables – will take care of 4. (most likely you’ll have this installed already)

Let’s install these tools:

First we’ll take care of configuration of AP daemon and it’s security – we do it in /etc/hostapd/hostapd.conf .

NOTE: If you copy-paste hostapd.conf from our tutorial, remove comments. (thanks Arnold)

Now we need to set up /etc/hostapd/hostapd.conf as the configuration file. We do it in /etc/default/hostapd. Put the following line there:

OK, perfect. Now let’s configure the network settings for clients connecting to AP. We do it in /etc/dhcp/dhcpd.conf

Again we need to make sure that DHCP server uses this configuration. In /etc/default/isc-dhcp-server put the following lines:

The last line indicates network interface that will be serving DHCP requests.

We’re almost done. Let’s configure wlan0 for static IP adress (the same as router IP in dhcpd.conf file.
We do it in /etc/network/interfaces:

The last line will set routing rules after restart.
Let’s turn on packet forwarding in /etc/sysctl.conf by making sure that line

is un-commented or added.

We will configure routing now by executing (assuming eth0 is your WAN interface):

and lets save these setting in a file:

Because I had bloody RTL8188CUS chipset I had to replace original hostapd with the one prepared for my chipset.

In order to start AP on boot run the following commands:

We are done! Now restart your RPi:

There is much easier way to do all of this :) Use our configuration script and have AP set up in 2 minutes!

If something does not work, please check if there are any duplicate entries in /etc/network/interfaces – if true, remove them and check again.

Let me know if something does not work! just comment on the article.

Great articles that helped a lot:

Here is your raspberry pi ampilight system!
  • Martin Webb

    One thing not clear from this article or any other article on hotspots and ad-hoc networks, is once set up and fully working, is it possible to SSH into the RPi from an ipad/iphone, or does setting the hotspot up just allow the ipad/iphone to simply use the RPi as a means to connect onwards through the RPi to other networks?
    I really need to be able to simply SSH into the RPi from an ipad/iphone when there are no other networks avaiable – e.g. when both the RPi and ipad/iphone are side-by-side, and I have no other keyboard/screen.

    • Tomasz Szczerba

      Martin, I tested your scenario – raspberry pi served as a router with no connection to internet. I was able to connect with putty to it. I don’t own ipad/iphone and cannot test them but that should make no difference ;) Great idea btw. full control of raspi with only tables/smartphone :)

      • Jacek

        I have tested Raspi AP with an iPad. I was able to connect via SSH without any problem.

        • Arnold Kok

          Me too… I used ServerAuditor which is for free in the store.

        • Toni Torres Marí

          I also was able to connect with my android mobile phone via ssh to the rpi, but only if it’s connected to the ethernet cable, otherwise doesn’t connect. Can you confirm if this is it or only happening to me because I did something wrong? Thanks for this great script bdw

  • William Louis Roach-Barrette

    First I want to say, thanks for the article. I have been working on a rover using a RPi as a learning tool. Your script should help me no longer require a router to accompany the rover as I take it to classrooms. I do have a question however regarding how exactly to see what the RPi’s default ip address is so i can ssh into it. When i do an ifconfig I see no address to connect to and I will admit I no very little about the subtleties of networking. So, how exactly do i go about figuring out or assigning an ip address to the RPi so i can ssh into it?

    On another note, I also need to host a webpage on the Pi that students can access once they are connected. As it stands, when i try to launch the server “using a python script that I designed with the webiopi libraries” It throws up an error and will not display the ip address and port needed to access the webpage. Any ideas? Thanks for all your help thus far with the tutorial, If you could assist me with this it would be greatly appreciated

    • Jacek

      William, let me address your first question (I can’t tell how to help you with the second one)…

      The IP that your looking is defined in /etc/dhcp/dhcpd.conf as

      option routers ; #your client’s gateway / router IP.

      Of course, your IP can be different depending on what the IP is in this line in your particular configuration. The other way to get the IP is to check network settings of the device you connect to RPi AP. RPi AP IP will be always a gateway at client’s network configuration.

      Let me know if that’s not clear…

      • William Louis Roach-Barrette

        Jacek, Thanks for the response. I examined the dhcpd.conf file and found:
        option router ;
        to be the ip address. However, when I tried to ssh into the pi from a computer connected to it via wifi it timed out. I am sorry but I did not understand your second explanation about how to check the network settings. Could you explain it to me in greater detail?

        Here is some additional information that may or may not be causing an issue. On boot up I receive a few failed messages. These are the failures I receive as I launch the pi:
        [….] Configuring network interfaces…/etc/network/interfaces:11: interface wlan0 declared allow-hotplug twice
        ifup: couldn’t read interface file “/etc/network/interfaces”

        [FAIL] check syslog for diagnostics …. failed!
        [FAIL] startpar: service(s) returned failure: isc-dhcp-server … failed!

        • Jacek

          That’s weird. Can you share your interfaces file?

    • Tomasz Szczerba

      Hi William,

      About hosting webpage on raspi, you gave us too little information to work with. What does error message say? What kind of web server you use?

      On a side note, I’m working on a couple of articles about using raspi as a web server but they are yet to come. Just to give you heads up – try cherooke ( ) it looks promising, it isn’t a resource hog as apache and it’s easy to setup and work with. Hovewer, if you have some time to spare try lighttpd ( ) it’s faster and lighter than above but more complicated to setup.

      • William Louis Roach-Barrette

        Sorry for not being clear before. I modified the code from this tutorial to both create and program the rover I am using.

        when I launch the server I receive the following output:

        2013-06-14 14:31:02 – WebIOPi – INFO – GPIO – Native mapped to RESET API /GPIO
        2013-06-14 14:31:02 – WebIOPi – INFO – Access protected by using login/password
        2013-06-14 14:31:02 – WebIOPi – INFO – HTTP Server binded on http://localhost:8000/

        Traceback (most recent call last):
        File “”, line 93, in

      • William Louis Roach-Barrette

        Sorry for not being clear before. I modified the code from this tutorial to both create and program the rover I am using.

        The web server worked fine until I ran this script, which im assuming has caused some conflicts that need to be resolved. When I launch the server I receive the following output:

        2013-06-14 14:31:02 – WebIOPi – INFO – GPIO – Native mapped to RESET API /GPIO
        2013-06-14 14:31:02 – WebIOPi – INFO – Access protected by using login/password
        2013-06-14 14:31:02 – WebIOPi – INFO – HTTP Server binded on http://localhost:8000/
        Traceback (most recent call last):
        File “”, line 93, in
        2013-06-14 14:31:02-WebIOPi-INFOO-CoAP Server binded on coap://localhost:5683/

        File “/usr/local/lib/python2.7/dist-packages/WebIOPi-0.6.0-py2.7-linux-arm61.egg/webiopi/”, line 153, in _init_ self.coap_server.enableMulticast()
        File “/usr/local/lib/python2.7/dist-packages/WebIOPi-0.6.0-py2.7-linux-arm61.egg/webiopi/”, line 469, in enableMulticast return getattr(self._sock,name)(*args)
        socket.error: (Errno 19) No such device

        Thanks again for all your help thus far, I am at this point a little in over my head

        • Tomasz Szczerba

          Perhaps you should try and find which line fails. Unfortunately It’s hard for me to say anything more helpful than that.

  • Arnold Kok


    After having tried several forum posts, using your post, I finally got my Raspberry Pi to work as an Access Point. I am very new to Linux, so I most of the time literally copied your suggestions (unless I know that I wanted something else (i.e. IP-ranges)).

    I had to install isc-dhcp-server twice… got a message about LSB script. The hostapd didn’t start. Seems like the issues I had before.

    Used the following command to troubleshoot:
    sudo hostapd -dd /etc/hostapd/hostapd.conf

    It showed that the information in /etc/dhcp/dhcpd.conf was incorrect.
    As I literally copied your suggestions there, I also included the remarks trailing on each line. Appearently that is not allowed. Removed all remarks. And now it seems to work!

    • Jacek

      Thanks for the comment. I’m happy that the article was helpful. Thank you for the note about comments in hostapd.conf. I have added appropriate warning in the article.

  • Baseer

    I had to update this file to get this going

    /etc/network/interfaces:11: interface wlan0 declared allow-hotplug twice
    ifdown: couldn’t read interfaces file “/etc/network/interfaces”
    /etc/network/interfaces:11: interface wlan0 declared allow-hotplug twice
    ifup: couldn’t read interfaces file “/etc/network/interfaces”

    GREAT ARTICLE btw!!!

  • Paul

    Can’t believe how long I’ve been trying the various methods out there to set my Pi as an Access Point on Raspbmc, and finally this foolproof guide did the trick! You’re a star, thanks very much!

    P.S. Any idea why hostapd still works if I don’t specify the driver? It’s always been like that for me… The driver within syslog says it is rt2800usb. No matter, it works! :)

    • Jacek

      Thanks :)

      Your “P.S.” is quite interesting :) Are you using Raspi default version of hostapd?

      • Paul

        Yep, nothing changed there. I just don’t have the driver entry at all within /etc/hostapd/hostapd.conf

  • Ender

    So everything worked except when I reboot my RPi and check the status of isc-dhcp-server ($ sudo service isc-dhcp-server status) it says it is not running. I then check hostapd and that is running fine. So I try to manually start isc-dhcp-server ($ sudo service isc-dhcp-server start) and it fails. It is not until I “$ sudo ifdown wlan0” and then “$ sudo ifup wlan0” that I can manually start isc-dhcp-server. I have a TP-Link 725N v2.

    Any help on this matter would be greatly appreciated as I have searched the internet and not been able to find anything similar. Thank you.

    • Ender

      Nevermind. It seems to be working now. Was not working on the first 3 reboots or so and then all of a sudden, now it works with every reboot. Did not change anything so I am not sure what happened.

      • Jacek

        Actually I had exactly the same issue with v1 of 725N after latest Raspbmc update. I was about to put a note in the article that it is not working anymore and suddenly it got fixed :)
        You wrote that you managed to start AP on 725N v2 – i tried to do this but couldn’t start hostapd. Could you share what hostapd version are you using (default or downloaded from our site) and what is in your hostapd.conf file?

        • Ender

          The original problem I posted still remains. I thought it had fixed itself but alas it has not. isc-dhcp-server fails to start on boot up and when I try to start it manually it fails unless I do ifdown/ifup wlan0.

          Hostapd, on the other hand, is working fine. It loads on boot up everytime. I am not sure exactly what version of hostapd I am using since I followed so many tutorials to try to get this to work (without success). I am pretty sure I am using whatever hostapd was downloaded when I did $ sudo apt-get install hostapd. As for the .conf file, it is exactly how you have it in your article (minus the comments).

  • thomas

    Great article JaceK! Thank you.

    The script worked perfect on “Rasbian 2013-05-25-wheezy-raspbian” fresh install, with TL-WN725N. I also had the problem with dhcp server. I solved it by restarting both hostapd and isc-dhcp-server on start up. I used /etc/rc.local file for this.

    $ sudo nano /etc/rc.local

    and added these lines:

    sudo service hostapd stop
    sudo service isc-dhcp-server stop
    sudo ifdown wlan0
    sudo ifup wlan0
    sudo service hostapd restart
    sudo service isc-dhcp-server restart

    and then reboot rasp.

  • Chris Blaxhall

    Awesome work.
    I couldn’t get the RPI to reload iptables on boot with any combination of up, pre-up or post-up and instead used a script in if-up.d as per
    Now works a treat.
    Thanks for the great work.

  • drmaq

    I have a problem where the script terminates after I choose one of my two wireless adapters. please see attached log output form the program

    • Jacek

      Does the script terminate at this step?

      • drmaq


      • codac

        I have the same problem, as I’d love to use your script in order to create a wifi repeater without eth0

        • Jacek

          Have you tried to go through the tutorial and change the parts that are responsible for routing? Script may not be prepared for your needs.

          • codac

            Yes I’ve done that. The AP works, but all of a suddon I can’t ping the router, neither or any other IP outside of the RasPi. Any idea what might be the issue?
            How do I check if the client has properly connected to the specified WiFi?
            Maye its the iptables?

  • Andrzej Pruszynski

    I’ve got D-Link Wireless N150 Micor USB Adapter which announces itself as Realtek RTL8188CUS (lsusb). I used Jacek / Tomek script and near everything went as expected but double entry: ‘/etc/network/interfaces:11: interface wlan0 declared allow-hotplug twice’ reported already too months ago by Baseer.

    In order to be able to configure Access Point (AP) on the fly and see clients status, etc., I suggest to add ‘ctrl_interface=/var/run/hostapd’ line to /etc/hostapd/hostapd.conf file. After restarting the hostapd or your PI AP, you can use command:

    sudo hostapd_cli

    Another interesting thing about RTL8188CUS is a possiblity of reducing power consumption by using appropriate parameter while inserting driver module.

    Consumed current (in mA), by default, is:

    – associated idle: 85.6
    – unassociated idle: 80.2
    – associated Idle (enable power save) – LPS: 34.5
    – unassociated Idle (enable power save) – IPS-NORMAL: 18.9
    – unassociated Idle (enable selective suspend): 0.72

  • Jaap van den Dries

    Hi Jacek,

    Before I buy an TP-LINK WN725N (I’ve now a wrong adapter) I want to ask you this: I have a model A, without ethernet. My intention making the RPi an AP is to download pictures from it made with a time-lapse script, somewhere in the field. I just want to connect to the RPi with SSH, sharing internet or 3G is not important.

    Is that possible, can I just follow your instructions to the letter?

    • Jacek


      I cannot think of a reason why it would not. Please remember to download hostapd and remaining packages first.

  • devnull

    Thanks, nice job, it works like a charm but I need I little help from my friends :)
    I configured wlan0 as AP (192.168.10.X) and wlan1 as WAN, yes, I’m using my rpi as a WiFi repeater and my problem is that I’d like to use a printer connected to eth0 (static via CUPS but clients connected to wlan0 (AP) can’t see, ping says that IP is unreachable
    What I’m doing wrong? Any ideas?

    • Jacek

      I assume you’re using DHCP server… What is the netmask in /etc/dhcp/dhcpd.conf?

      • devnull


        auto lo
        iface lo inet loopback

        iface eth0 inet static

        auto wlan0
        allow-hotplug wlan0
        iface wlan0 inet static
        up iptables-restore < /etc/iptables.ipv4.nat

        allow-hotplug wlan1
        iface wlan1 inet dhcp


        ddns-update-style none;
        default-lease-time 86400;
        max-lease-time 86400;
        subnet netmask {
        range ;
        option domain-name-servers, ;
        option domain-name "home";
        option routers ;

        Printer has an static IP too.
        Hosts connected to wlan0 can't reach eth0 (now neither printer on eth0 (

        • Jacek

          Hi devnull,
          How did you configure iptables? You should have replaced eth0 with wlan1.
          If you did that, can you share your client (connected via wlan0) network settings? Can you reach (ping) your printer directly from Raspberry?


          • devnull

            I fixed the problem making a bridge between wlan0 and eth0

            iface br0 inet static
            bridge_ports eth0 wlan0

            Thanks a lot

  • Jaap van den Dries

    Damn, first step! I get an error after typing “sudo apt-get -y install hostapd isc-dhcp-server iptables wpa_supplicant” > Unable to locate package wpa_supplicant, rebooted, I get many red warning from dhcp-server and more, and the same error when I try “sudo apt-get install wpa_supplicant” for the second time.

    • Jacek

      Jaap, as I wrote previously, you need to download all packages required for the installation and install them using offline. I guess you can also try connecting through your wifi adapter to the Internet and install packages online. At some point you will loose connection (especially, if you’re using our script), but at that time all packages should be already downloaded and installed.

  • Jaap van den Dries

    I have a model A so i presume that i can/must skip the routing and iptables

    • Jacek

      Yes, you don’t have a target to route to :)

  • Mario Neudeck

    Thanks for the good how to.
    My question regards to the weak signal. I use the RTL8188CUS chipset.
    Do you agree that one has only a good signal if one is in the same room like the Pi? When I leave the room the signal becomes very weak. Only if I’m in front of the Pi the signal is really good.
    I’m asking because it could also be possible that there is a misconfiguration. But I don’t think so because I took your how to.
    I would like to use the Pi to connect to a tor network. But if the signal is as weak as now it does not make any sense.

  • Albol

    I have certainly had much more success with your method than any of the other net-postings and have reached a stage where my pi is broadcasting it’s SSID. Devices trying to connect cannot get an IP and when I try to ping the pi’s eth0 static IP it returns no results. Also, if I run X on the pi with startx, then run Midori, it will not connet to the net. Something is obviously screwing eth0’s connection during your process, as eth0 initially works as I have done the whole procedure using SSH. I’ve tried this now from scratch, reinstalling Wheezy twice. Any ideas?

    • Jacek

      Can you share your interfaces file together with /etc/network/interfaces.bak file (produced by our script)? please send it to my email jacek @ raspberry – at – home . com

      As with regards to the problem with clients of AP, have you checked the logs of isc-dhcp-server?

  • Herschelle

    hey. thanks for the awesome script.
    i tried many others and none worked.

    i ran your script and rebooted and i could see the RPi SSID but not connect.
    i removed the “allow-hotplug wlan0” from /etc/network/interfaces and rebooted and my phone connected on the first try.

    so something in your script works where the others did not.

    now to figure out how to get the xbmc remote on my phone to connect to the pi :)

    thanks again

  • Wrechid

    Hello, this is a great script for raspbmc… I tried it on xbian and it wouldn’t work… After running the script, xbian wouldn’t boot… :/ With raspbmc the wifi dongle indicater did not start blinking until I ran your script, but with xbian it’s blinking right after initial install of xbian… Is it possible that since xbian has already initialized the dongle that your script is unable to gain access to it…?

    • Jacek

      I would check /etc/network/interface if there are any diplicated entries. Our script is NOT the state of the art. It can do some misconfiguration if assumptions that we’ve made, are not true in particular version of the linux distribution. I would advice you to go through our tutorial and verify all the steps if they are not corrupting your default setup on Xbian.

      • Wrechid

        hello again… you was right… not sure about diplicated entries, but
        the interface file needed a few changes… one of the devs (mk01) over
        at the XBian forums help me through it… thanx again for the script…

        • codac

          Hello, your script got the same error, if two wifi adapters are present. The menu asks which adapter you want to chose. As soon as you select the adapters number, the script just quits.
          Furthermore I have the problem that with eth0, I have a proper internet connection. I can ping from the RasPi. I do see the AP from wlan0 as well. Connecting to the AP with a netbook requires much longer than a normal connection. After the netbook is connected it shows, that the connection is limited. The netbook can’t ping eth0 or wlan0 and the RasPi cannot ping the netbook, although its connected to wlan0’s AP.
          Anny suggestion what the root cause might be?

          • Wrechid

            hello codac… yea, both scripts have the same objective, mine just has modified user inputs… i’ve never tried using 2 wifi dngles but now that it is brought up i’m looking into it now…

            as for the prolonged connect time while using eth0 as internet (WAN) connection, try using a different wireless channel… channels 1, 6, and 11 are the common ones…
            also, which xbmc distribution are you using, RaspBMC, XBian, etc…?

          • codac

            Thanks a lot Wrechid! Looking forward to the fix.

            Alright, I’ll try to change the channel.
            Unfortunately I’m not using XBMC, I’m using Wheezy Raspbian 25.09.2013 ( and (
            As I’m using the RTL8188CUS chipset I’ve already changed the hostapd version to the one described by the tutorial.

          • Wrechid

            ok, i’m not setup for rasbian at the moment… i’ll install that later and verify it there… i did fix the little glitch after selecting which wlan to use… download my script from above, i updated it… also, try to keep eack wifi dongle on different channels… since they are so close to each other, they’ll interfere with each other…

          • codac

            Hey Wrechid, sorry for the very late reply.
            I was finally able to successfully test your two wifi dongle script ( on the newest version of Wheezy (2014-01-07).
            I’ve made some changes to the script in order to improve the dialogue and in order to enable my iPhone 4S to connect to the Pi as well.
            I’d like to share the script, where am I supposed to send it to?

          • Wrechid

            hello codac,
            i didn’t forget about ya… i did get it to work on Raspbian, i’m just trying to fix the script so that it makes the adjustments for Raspbian…

          • codac

            Heya Wrechid, you’re a true lifesaver!
            I’ll test your script today as soon as I’m back home.
            Two things that I already recognized is:
            1. It would be nice to make the DHCP optional. In my case there is already a router running the DHCP, unfortunately I am not the owner of that router, so currently with the RasPi there would be two DHCP servers in one network.
            2. The AP always gets the “.1” at the end of the network-ip address (for example As I mentioned at 1. there is already a router present which has and is actually the gateway. So I would need to set the APs IP address to another one (in my case, which I currently do on the last step where the menu offers to manually edit the /etc/network/interfaces file.

          • Wrechid

            Hello codac,
            I do see your point, but with an AP, it’s usually better to put it in a different IP range than what your primary router… Notice that the default IP for the AP is set at… That way the second dhcp server doesn’t interfere with the common or ones… And you’ll still get Internet through the RPi… :)
            I will look into the optional last number, but allowing to many variables gets confusing and more problems to the less experienced… :)

          • codac

            I have to admit you’ve got quite a point there :D
            Ok, so I’ve tried to set up two wifi adapters wlan0 being the WAN port and wlan1 being the ap. I can connect to the ap but with a limited connection and I won’t get a dhcp assigned ip address.

            # WPA and WPA2 configuration
            # Hardware configuration

            auto lo

            iface lo inet loopback
            iface eth0 inet dhcp

            allow-hotplug wlan0
            ##iface wlan0 inet manual
            ##wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
            ##iface default inet dhcp
            iface wlan0 inet dhcp
            wpa-ssid “WLAN 12”
            wpa-psk “supersecret”
            allow-hotplug wlan1
            iface wlan1 inet static
            up iptables-restore < /etc/iptables.ipv4.nat

            # Generated by iptables-save v1.4.14 on Mon Dec 2 21:53:00 2013
            :INPUT ACCEPT [0:0]
            :FORWARD ACCEPT [0:0]
            :OUTPUT ACCEPT [0:0]
            -A FORWARD -i wlan0 -o wlan1 -m state –state RELATED,ESTABLISHED -j ACCEPT
            -A FORWARD -i wlan1 -o wlan0 -j ACCEPT
            # Completed on Mon Dec 2 21:53:00 2013
            # Generated by iptables-save v1.4.14 on Mon Dec 2 21:53:00 2013
            :PREROUTING ACCEPT [0:0]
            :INPUT ACCEPT [0:0]
            :OUTPUT ACCEPT [0:0]
            :POSTROUTING ACCEPT [0:0]
            -A POSTROUTING -o wlan0 -j MASQUERADE
            # Completed on Mon Dec 2 21:53:00 2013

            ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


            ddns-update-style none;
            default-lease-time 86400;
            max-lease-time 86400;
            subnet netmask {
            range ;
            option domain-name-servers, ;
            option domain-name "home";
            option routers ;




          • Wrechid

            hello codac,
            everything there looks correct… one thing that caught my eye though is the wlan0 connecting to a ssid with a space in it… normally that isn’t a problem, but it still makes me wonder… are you able to ping after setting up the first wlan0…? try “ping -c 1”… i’ll add a space to my setup and see if it still works…
            what method are you using to set this up…? (ssh or terminal from Raspbian desktop)

            if you are using a usb hub, remember to give the hub separate power… the rpi will also need good power since wifi dongles do require a lot…

            when i set it up on my end, i do everything from ssh, without loading the raspbian desktop… i’m pretty sure that the wifi config tool that comes with raspbian would cause problems… what size sd card are you using…? i think a minimum of 4gb would be needed…

          • Wrechid

            just verified that it does work with spaces in the ssid… another thing, after the script is completely done and you do the last reboot, did you unplug the wired network…? with that plugged in, it will cause the dhcp server to fail…

          • codac

            Wrechid I didn’t forget to reply, I’m currently waiting for the delivery of new wifi adapters (EDIMAX EW-7811UN) as I currently think there might be hardware issues in the way…

          • Wrechid

            hello codac,
            i’ve tested this many more times… i even hooked up my usb hub so i could use a keyboard and mouse to try without ssh… i’ve tried it without loading Raspian desktop, and also tried it from with in the desktop using the LXTerminal… the only problem i had was when i try to put both wifi dongles in the usb hub at once… the hub kept freezing… as long as i unplugged the wired network afterwards and did a reboot, it worked every time… only other thing i can think of is something with your hardware setup… :/ keep me posted, will do what ever i can…

          • Wrechid

            i’ve verified that the space in ssid is not a problem… i did notice
            that both wifi adapters in the usb hub can be a problem… try putting
            one adapter in the rpi and the other in the usb hub… you’ll have to
            re-setup everything from scratch when moving the adapters to different
            usb ports…

          • Wrechid

            hello codac,
            i got a beta setup, would you please try it for me…? i’ve tested it a few times on a fresh install of Raspbian… i did everything from a ssh shell with both wifi dongles plugged in and wired connection (eth0) for ssh… before you run the script be sure to Expand Filesystem option from within raspi-config… i found that to be one problem for the iptables running out of room…

          • mk01


            there is no difference between XBian (apt-get upgraded on 25.9.2013 by user) and Raspbian/Wheezy 25.9.2013.

            XBian is installed on top of it from standard .deb packages located at 3rd party APT repository.


          • Wrechid

            i did notice some resemblances… :)

      • Wrechid

        Hello Jacek, I use your script often… I have been tinkering with it some and edited the user input of it… Applied some goof-proof, and the ability to make corrections… Added default value so a user could just hit all the way through it… :) also added the option to edit interfaces file before hostapd is started last time… Here’s a temporary link to what I have, not sure if I’m allowed to post this here…

        • Jacek

          Wrechid, thanks a lot. I will check it out in my free time. Would you agree to put it in our tutorial as better version of what we did? (so that people won’t need to go through the comments :) ). All credentials will be kept :)

          • Wrechid

            I don’t mind… I don’t want any credit, I just like playing with scripts and writing different codes… :) Next I’m working on a way to add specific settings to interfaces file according to which distribution is installed… :)

  • Miguel Neto

    Hey, i had a raspberry model B,with the TP-LINK WN725N, and the wifi adapter are not detected, i had instaled berryboot on raspberry and try do what you say, but the berryboot console not understand the first code line (sudo apt-get update) . sorry my inglish. thanks for the help.

  • ToddB

    Awesome work guys – I’m not great with Linux and I tried on my own for a few weeks to make this work but struggled; your script did what I needed in minutes.
    Now to really take things to the next level, how hard do you think it’d be to make a script that checks to see if your home wifi is in range, and if so – running something like rsync to sync the local USB disk with a share on your home network? How awesome would it be if your car’s video library self-updated as you made new rips to a certain folder? Then I could have one in each car and never have to take them out – they’d get updated as movies are added/deleted provided we keep the source folder within the size limits of the USB drive we’re syncing too. Even better if we can trigger XBMC to rebuild the library while we’re there!

  • Steve Pearson

    Hi I’m new to this and I’m stuck close to the beginning, I cant find /etc/dhcp/dhcpd.conf so cant edit it, or do I need to make it ? the only .conf file in that directory is dhclient.conf

    Thank you

    • Jacek

      Have you installed hostapd first?

      • Steve Pearson

        Hi Jacek thanks for your reply

        I’ve started again with a fresh install just to make sure I’n not missing something

        this is what I get

        pi@raspberrypi ~ $ sudo apt-get -y install hostapd isc-dhcp-server iptables wpa_supplicant

        Reading package lists… Done

        Building dependency tree

        Reading state information… Done

        E: Unable to locate package wpa_supplicant

        pi@raspberrypi ~ $

        • Jacek

          Try to run this command first:
          sudo apt-get update

          • Steve Pearson

            Hi I ran that first

          • Bat!

            According to the Debian reference on my Pi, it should be wpasupplicant with no underscore, could that be the problem? I’m new at this so I don’t know.

          • StackLinux

            yes it’s wpasupplicant. Don’t think the author used/tested these instructions. hehe

      • Steve Pearson

        also when you say

        NOTE: If you copy-paste hostapd.conf from our tutorial, remove comments. (thanks Arnold)

        do you mean like this ?




        # WPA and WPA2 configuration



        #WPA settings






        #Hardware configuration






        • Jacek


  • Simon

    Hi. The script seems to be working pretty well, but when i run sudo hostaps -dd /etc/hostapd/hostapd.conf i get this output.

    pi@raspberrypi ~ $ sudo hostapd -dd /etc/hostapd/hostapd.conf

    random: Trying to read entropy from /dev/random

    Configuration file: /etc/hostapd/hostapd.conf



    BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)

    Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=12 freq=2467 MHz max_tx_power=0 dBm

    Allowed channel: mode=1 chan=13 freq=2472 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=0 dBm

    Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=36 freq=5180 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=40 freq=5200 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=44 freq=5220 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=48 freq=5240 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=52 freq=5260 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=56 freq=5280 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=60 freq=5300 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=64 freq=5320 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=100 freq=5500 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=104 freq=5520 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=108 freq=5540 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=112 freq=5560 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=116 freq=5580 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=120 freq=5600 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=124 freq=5620 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=128 freq=5640 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=132 freq=5660 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=136 freq=5680 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=140 freq=5700 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=149 freq=5745 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=153 freq=5765 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=157 freq=5785 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=161 freq=5805 MHz max_tx_power=0 dBm

    Allowed channel: mode=2 chan=165 freq=5825 MHz max_tx_power=0 dBm

    Completing interface initialization

    Mode: IEEE 802.11g Channel: 1 Frequency: 2412 MHz

    RATE[0] rate=10 flags=0x1

    RATE[1] rate=20 flags=0x1

    RATE[2] rate=55 flags=0x1

    RATE[3] rate=110 flags=0x1

    RATE[4] rate=60 flags=0x0

    RATE[5] rate=90 flags=0x0

    RATE[6] rate=120 flags=0x0

    RATE[7] rate=180 flags=0x0

    RATE[8] rate=240 flags=0x0

    RATE[9] rate=360 flags=0x0

    RATE[10] rate=480 flags=0x0

    RATE[11] rate=540 flags=0x0

    Flushing old station entries

    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Could not connect to kernel driver.

    Deauthenticate all stations

    +rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2


    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Failed to set encryption.

    Failed to clear default encryption keys (ifname=wlan0 keyidx=0)


    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Failed to set encryption.

    Failed to clear default encryption keys (ifname=wlan0 keyidx=1)


    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Failed to set encryption.

    Failed to clear default encryption keys (ifname=wlan0 keyidx=2)


    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Failed to set encryption.

    Failed to clear default encryption keys (ifname=wlan0 keyidx=3)

    Using interface wlan0 with hwaddr 64:66:b3:06:2b:0e and ssid ‘Pi’

    Deriving WPA PSK based on passphrase

    SSID – hexdump_ascii(len=2):

    50 69 Pi

    PSK (ASCII passphrase) – hexdump_ascii(len=14): [REMOVED]

    PSK (from passphrase) – hexdump(len=32): [REMOVED]


    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    random: Got 20/20 bytes from /dev/random

    Get randomness: len=32 entropy=0

    GMK – hexdump(len=32): [REMOVED]

    Get randomness: len=32 entropy=0

    Key Counter – hexdump(len=32): [REMOVED]

    WPA: group state machine entering state GTK_INIT (VLAN-ID 0)

    Get randomness: len=16 entropy=0

    GTK – hexdump(len=16): [REMOVED]

    WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)


    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Failed to set encryption.



    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    ioctl[RTL_IOCTL_HOSTAPD]: Operation not supported

    Failed to set beacon head/tail or DTIM period

    wlan0: Setup of interface done.

  • Jeffin

    Awesome, really thanks for this! It really helped me as a linux noob, and it’s even easier with your configuration script!
    One thing though, sometimes I need to connect my raspberry to my iphone personal hotspot. But on AP mode, my raspbmc cannot found any wifi. Is there any way to turn off the AP mode manually so my raspberry could connect normally to wifi connection just like before? I didn’t have LAN internet at home so sometimes I need to connect to wifi hotspot.

    Thanks! :D

  • Francisco Palomino

    I did the same as the tutorial I have the RTL8188CUS chipset
    I can see the access point in my phone

    But when I tried to get connect, I got an immediate answer that my phone is unable to join the network.

    I did a sudo hostapd -dd /etc/hostapd/hostapd.conf and at the very bottom I see.

    ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
    something I missing?
    Thanks, any help is appreciated.

    • Tanvi Jindal

      I am getting the same error. Were you able to figure this out? HElp would be really appreciated!

      • Francisco Palomino

        I did a fresh installation of Raspbmc.
        I ran the last three command lines at the end of this tutorial regarding the script and setup in two minutes.

        chmod +x
        sudo ./
        I been answering the questions one by one and I did the setup.
        At the same time and due to several tries, seems like iphone keep older settings when trying to connect to the same SSID, so I reset Network Settings and everything worked fine!
        I used a TP-LINK as well with a fresh installation, ran the script and no problems at all.
        Post your results!.

        • Jacek

          Thanks Francisco! I hope this helps others as well!

      • sanchox

        I had the exact same issue. After running the script, my AP showed a SSID, but I would be immediately disconnected upon login. Without a reinstall, I followed the tutorial line by line (instead of relying on the script again). I found that the /etc/network/interfaces file was not correct. It had two sets of entries, one for static and one for manual. I edited it to match the tutorial and it worked like a charm :) GL

        • Tanvi Jindal

          Thanks for the reply, I am sorry I had been inactive for long time. I had fixed the issue too, had a wrong network interfaces file too. :/

          • Amir Ali

            I have a question… Can we use another feature in a cascade object trainer?

  • StackLinux

    The one problem I find (not just with this setup) is that if you go more than 20 feet in another room. Even though the signal level is still -50dBm or -60dbm the ping time starts to skyrocket and connection drops. See attached screenshot while testing just using youtube for example (which works perfect in the same room).

    IPs are differn’t because I’ve been trying multiple how-to’s to see if maybe its an issue with config and just gave this setup a try. Works find but move to the bedroom pings are perfect until load “even with signal well within good levels”. So far it only works well within 10 – 20 feet in the same root. My WiFi dongle is… I also tried with this one first: The distance cause me to invest in the long range antenna which as far as signal is -60dBm in most rooms and 40dBm in the same room.

    The distance issue with high latency I thought was signal but I’m using another device with monitors signal while testing. Tested using Cisco router and even with -70dBm from 2 rooms away it works perfectly!

    Not sure if anyone else noticed this. Also I purchase a 2 Pi to make sure. Also I have multiple power supplies two of which are rated AND I tested at 5v 2amps. Most if not all of the first things to eliminate had already been tested.

    And yes I know I have the right drivers got them directly from here:

    As I said all the obvious things have been checked and rechecked. Multimpi Pi’s USB wifi dongles, even tried it with Arch Linux ARM all the same high pings and looses connection if you use from another room even with signal ALWAYS below -60dBm.

    Oh yes, I’ve tried differn’t channels. But mainly 1,6 and 11. ;)

    • Jacek

      I am always close to pi when using it as AP, but I assume that these small wifi adapters simply can’t handle longer distances.

  • TJC

    Jacek, thank you for the convenient script. It makes the installation very easy. The only manual change I made was to remove duplicate wlan0 entries in /etc/network/interfaces. I have a TP-Link TP-WN725Nv2 WiFi adapter which seems to use the Realtek 8188EUS chip. I can not get the TP-Link adapter to work with your instructions.

    I first install the driver for the TP-Link adapter for Raspbian Linux version 3.10.25+ #622 from

    With CHIPSET set to “no” I get a hostapd Segmentation fault during boot. The eth0 port works, I can ping the wlan0 address, but no SSID is broadcast.

    With CHIPSET set to “yes” I get hostapd ioctl[RTLIOCTL_HOSTAPD]: Operation not supported errors during boot. The eth0 port works, I can ping the wlan0 address, but no SSID is broadcast.

    In both cases ifconfig shows an IP address for wlan0, that it is UP, but not RUNNING.

    I have spent many hours searching for a solution, but nothing seems to work. Following your instructions gets me the furthest, but not to a working access point. Any suggestions you have would be appreciated.

  • Fero Nymous

    thx a lot for the script. I have also one problem that my ssid isn’t shown
    how can i fixed it??

    • Jacek

      Is hostapd running?

      • Fero Nymous

        i think that is runninge because i get a ip-adresse for dhcp but the 802.11 management says :: hostapdioctl(RTL_IOCTL_HOSTAPD]:operation not support
        9 times its written

  • 曹博堯

    wpa_supplicant should be wpasupplicant ?

  • Michael

    Hi Jacek
    i have a problem.
    hostapdhioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
    Starting ISC DHCP server failed
    What did i wrong. I used ur script

  • Jonathas Kerber

    Thanks man, I had several troubles in trying to get hostapd working but your hostapd file worked perfectly. Can you tell what you’ve done?


  • Oki Erie Rinaldi

    hey,, what about this second last step?

    i found the following:
    update-rc.d: warning: /etc/init.d/isc-dhcp-server missing LSB information
    update-rc.d: see
    System start/stop links for /etc/init.d/isc-dhcp-server do not exist.

    when i “update-rc.d isc-dhcp-server enable”.

  • Oki Erie Rinaldi

    Oke,, now my wireless turns to ‘unmanaged’. It can’t be active or inactive. What should I do?

  • John Samuel αΩ

    I can see the AP and connect with my phone, but I cannot connect to XBMC from the remote. I don’t think my phone can see any services on the rpi even though it is connected. Any ideas what I did wrong?

    • Jacek

      Do you have httpaccess enabled in xbmc?

      • John Samuel αΩ

        Yes. I can still access XBMC through wired network. It is available at on my wired network. When connecting to AP though, it seems to be totally isolated from the onboard services.

        • Jacek

          So your wireless device does not have problems to connect to AP and it receives ip, right? Can you access other services on this pi, like ftp? What network mask you hdefined in hostapd.conf?

          • Alex

            You need to disable bridge mode in hostapd.

  • Ajay Jain

    I tried this tutorial, and I can view the network. However, I cannot browse the Internet on it. I don’t need an ethernet setup for this, do I?

    • Jacek

      How is your pi connected to the Internet? Do you have second wifi adapter? (I assume you don’t have ethernet cable connected)

      • Ajay Jain

        I do have a second wifi dongle. What would I do? Replace all instances of eth0 with wlan1 or just use that to connect to my Pi’s connection?

        • Jacek

          Yes, you should replace eth0 in iptables configuration

    • sasmito

      if you connected raspberry pi with ethernet and didnt connect the internet to get the resource library raspbian, you must setting wireless configuration like /etc/hostapd/hostapd.conf
      or search on google how to setting wireless configuration

  • Claudio Clacly Spada

    Hi, I used the script and it works, I can see SSID but the mobile and the PC can’t connect to the AP. Can you help me? Thank you!

    EDIT: I have an usb dongle with realtek 8188CUS

    • Wilson Bradley

      Same problem and chipset..

  • Ugo

    I have tried several tutorials and the script solved it! (please put it as the first thing on the post!)
    sir, please post your paypal address, i want to pay you a beer! thank you very much

    • Jacek

      Ha! Thanks a lot! no such need :) you post is enough to make me feel happy :) If you want to spend some money though, you can always visit :)

  • Sammy Singh

    Hi JaceK,

    Ultimate tut. Using the script started the hotspot nicely, thought I had to edit the interfaces file but I got the hotspot …. I am stuck in a very different problem. See before I had installed the hotspot. I was running both LMS and squeezelite player on same pi, connected to my LAN. With a pen dive mounted I was able to play songs of pendrive from squeezelite player that used to get detected under LMS and all was well. After instaling the hotspot, I loose eth0 connectivity (which is understandable and expected) BUT when I connect the laptop with the new ip that rpi hotspot dhcp gives (, though I can open LMS page, I DO NOT SEE SQUEEZELITE player under it. It has vanished. The squeezelite script has the correct server ip. The moment I remove hotspot all is well. There is something hotspot is doing that is making my LMS loose the squeezelite player ……. do you by any chance have any idea what is going on, how can we resolve this…..

  • Serega Patsura

    Help please i looked many tutorials,this the best =), i setting up step by step Raspberry Pi, and running script, AP see but then i tried to conect it, it always write “obtain IP-Adress … forever and not conected” i don’t know where error i conected via eth0 and wlan0 (Edimax EW 7811UN), who know solution please write, i need RPi and AP for my “Batchelor Diploma Work” (Sory for my bad English i from Ukraine). Thanks for advice.

  • Jessica Hart

    Please make sure your WiFi dongle supports AP mode.

  • philipp

    Got a working AP using Raspbmc, TL-WN725Nv2.1. Just make sure that
    1. Press yes, when asked for the alternative hostapd
    2. supply enough power to the pi. (for some reason, the 500 mA power supply I used in the first place didn’t work)

  • Clément

    It is not working for me. I don’t know what to do.

    I have this error when i start isc-dhcp-server

    [FAIL] Starting ISC DHCP server: dhcpd[….] check syslog for diagnostics. … failed!


    I can see the wireless network, but it doesn’t connect to that one. It is just loading all the time…

  • james hobbs

    Very helpful, thanks.

    I can now connect to my rPi as an access point, and if the rPi is connected to my LAN with eth0 the internet connection is shared to my connecting device and I can access my Plex server on the rPi at

    However, if I start the rPi without the eth0 connected, I can still connect to the AP but I no longer am able to connect to my Plex server… I don’t know where to begin.

    eth0 Link encap:Ethernet HWaddr b8:27:eb:52:ea:3e
    inet addr: Bcast: Mask:
    inet6 addr: fe80::ba27:ebff:fe52:ea3e/64 Scope:Link
    RX packets:1353 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1208 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:698456 (682.0 KiB) TX bytes:222789 (217.5 KiB)

    lo Link encap:Local Loopback
    inet addr: Mask:
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:65536 Metric:1
    RX packets:318 errors:0 dropped:0 overruns:0 frame:0
    TX packets:318 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:163118 (159.2 KiB) TX bytes:163118 (159.2 KiB)

    wlan0 Link encap:Ethernet HWaddr 74:da:38:26:9c:28
    inet addr: Bcast: Mask:
    inet6 addr: fe80::76da:38ff:fe26:9c28/64 Scope:Link
    RX packets:1935 errors:0 dropped:32 overruns:0 frame:0
    TX packets:2533 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:273989 (267.5 KiB) TX bytes:3140917 (2.9 MiB)

  • nsayer

    This no longer works. Any attempt to run hostapd – regardless of which version – now results in

    ioctl[SIOCSIWMODE]: Operation not permitted

    Could not set interface to mode(3)!

    Could not set interface to master mode!

    rtl871xdrv driver initialization failed.

    Something about the drivers included with 3.18.7+ have broken hostapd for the RTL8188CUS.

  • Noah Kroon

    I have a problem, I can see my AP but when i try to connect with it it keeps authenticating forever untill it times out. Any ideas?

    • Noah Kroon

      I’m not sure what caused the issue but removing the “wpa-roam” line in /etc/network/interfaces fixed the problem for me. Thanks a lot for this guide!

  • ricardo

    Hi, this is a wonderful tutorial. I went through it as well as through the instructions of compiling the custom hostafp to drive the relatec chips (at and came close, but unfortunately I could not get it to fully work.

    Functionally, I got as far as being able to create a visible access point via another device but unfortunately there seems to be a problem with the authentication. I tried all wpa methods, and even password-less access, but the client (an iPhone) could never connect to the access point on my Raspberry Pi.

    My setup is a Raspberry Pi 2, running a fresh instal of OSMC (OSMC_TGT_rbp2_20150519) with a Edimax Wifi plug (rtl8192cu).

    Note: When running the I saw the following worrisome message:

    The following packages have unmet dependencies:

    hostapd : Depends: libnl-route-3-200 (>= 3.2.7) but it is not installable
    E: Unable to correct problems, you have held broken packages.

    So I ran: sudo apt-get upgrade libnl-route-3-200
    I also had to do: sudo apt-get install usbutils

    Even with all this, and rerunning, authentication still failed from iPhone with message ‘Incorrect password for “wifi”‘

    Also, wlan0 did not come up with a fixed IP on boot, and I had to manually launch: sudo hostapd -d /etc/hostap/hostap.conf.

    I could not find any errors on any log files or dmesg, but I may have not been looking in the right place.

    Please help, a similar setup (with exact same wifi plug) worked perfectly on a RP +B with XMBC, and I urgently need this working for an imminent family road trip.

  • Stefano

    I have a modem router that answer to, the raspberry lan with
    I set the /etc/dhcp/dhcpd.conf in this way:

    subnet netmask { #AP Subnet defintion
    range ; #Range of IP addresses available for clients (I WANT TO RESERVE FROM .30 TO .39 IP FOR THE DEVICE ATTACHED TO THE RASP WIFI)
    option domain-name-servers ; #your DNS IP (in my case, my router is workign as DNS)
    option domain-name “home”; #optional domain name
    option routers ; #your client’s gateway / router IP

    The wifi dongle is RTL8188CUS 802.11n WLAN Adapter.
    In the /etc/hostapd/hostapd.conf i set my ssid value.
    In th e/etc/network/interfaces

    auto wlan0
    allow-hotplug wlan0

    iface wlan0 inet static
    up iptables-restore < /etc/iptables.ipv4.nat

    I cannot see the rpi wifi network, I see a new wireles device conntected to the modem (from the modem admin page) but I cannot connect to the raspberry via lan ssh anymore.

    I removed from /etc/network/interfaces the iface wlan0 part and now I have again ssh connectivity via lan.

  • Rob

    Used the guide on an RPi 2 and RTL8192cu based adapter and it worked perfectly. Thanks for sharing!

  • Josh

    I am trying to do this, but am overwhelmed. I know nothing about programing Pi.

  • Nasim Arianpoo

    I am using tl-wn725n on freebsd11 on my rpi 2, the problem is that the adaptor supports ad-hoc/ap but the driver in freebsd (urtwn) does not. Is there any way around this? really appreciate your help, looked for it for almost two weeks and no results :(

  • Ian Anderson

    Super tutorial!

    Can you tell me what limits the number of devices which can associate with the access point? I guess there could be limits in hostapd, the driver, or the hardware. I have an application where I want to be able to associate as many devices as possible.

    Do you have source code for hostapd to work with the RTL8188CUS chipset please?

    • Jacek

      Hi, Unfortunately I don’t know the answer to your first question. I don’t have source code of hostapd either :(

      • Marco

        Hi Jacek, thank you very much for your tutorial, works like sharm in my case.

        I find annoying that everytime I want to setup a WiFi AP I need to pay attention which chipset my dongle has.
        I would have like to compile the binary of hostapd that supports RTL8188CUS by myself, to try to understand what are the differences among different chipset.

        It is really convenient to download the pre-compiled from your website, but could you share the compile process to build it?

        Thank you!

  • Nicolas

    NOTHING is working for me >.< I tried 3 tutorials and NOTHING. With yours the Pi is giving me Failure while "Starting advanced IEEE 802.11 management:hostapd". I'm gonna reinstall OS and try everything by myself ;_; If you know how to help me: I have TL_WN722N card.

    • Jacek

      Most likely your chip is different (not 8818CUS) thus this custom version of hostapd will not work

      • Nicolas

        Ok… It look like I must try every option .
        Btw. Are you from Poland?

        • Jacek

          Yes, we are :)

          • Nicolas

            No nieźle :D, najmniej się spodziewałem polskiego portalu po angielsku szukając tego szajsu >.< :P

  • DEMG

    Hello great work !

    Finally I managed to turn my RPi in a wifi routeur thanks to you =). Thanks !

    My RPi hosts a server and a web site, I already can acces the website by taping the ip address of the RPi from the brower of my laptop.
    I’d like to know if there is a way to replace the ip adress of the rpi in the local wireless network by a text/name like “MyProject42” or whatever…

    Like that, I could access the RPi site by typing “MyProject42” in a browser (still with the local network).

    • AbuGok

      add it in your hosts file (if using windows) MyProject42

  • Christoph Schranz

    Fantastic Skript & Guide! Thank you!
    One add:
    Some modems get IP’s like 10.X.Y.Z, which are not static. (caused by the provider)
    Therefore use as your router’s address and it works!

  • teter

    Thank Jacek, but my AP is not visible.
    Linux raspbx 4.1.6-v7+ #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015 armv7l GNU/Linux. + TP-LINK TL-WN725N.
    interface up ip, address assigned.
    help, where to look for the problem?

  • Kostas

    It works for Raspberry 2. Thanks.

  • Adam

    I’m trying to get this to work using the script on osmc

    with both an rtl8192cu and an rtl8188cus
    With no success.
    I cant see the ssid.
    Following different guide I can connect to the AP but I cant ping the pi.

    Thank you for the help!!!

  • Sergius

    Hello. Nice guide.

    I am trying to do a AP with a raspberry PI 2 and TL-WN725N. I followed your advice and the network gets up. But the clients try to enter the network and end up not connecting after they report “authenticating”. I tried to check up the /var/log/messages and it reports me the client tries to check in with “R8818EU: error ap recv disassoc reason(7)” .

    The TL-WN725N is connected directly to the pi’s USB.

  • Paul

    Hello, his walk with OSMC?

    Thank you

  • maria

    I literally used the institutions mentioned above. do not I see no error but the access point is not displayed. I used a LP_LINK TL-WN722N. can anyone help me out?

  • Vladimir Takov

    Hello, this is really a great article!
    I fallowed the instructions step by step for my RPi 2 and everything just worked!
    Thank you so much for sharing!

    The only thing I’m not really sure about is how to properly turn on/off the AP functionality. Cause I have only one wifi dongle and I want to use it sometimes for accessing the internet and sometimes as an AP.

    So I wrote two bash scripts to turn it on/off

    sudo rm /etc/network/interfaces
    sudo cp /etc/network/interfaces.apon /etc/network/interfaces
    sudo update-rc.d hostapd enable
    sudo update-rc.d isc-dhcp-server enable


    sudo rm /etc/network/interfaces
    sudo cp /etc/network/interfaces.apoff /etc/network/interfaces
    sudo update-rc.d hostapd disable
    sudo update-rc.d isc-dhcp-server disable

    where the interfaces.apon and interfaces.apoff are backup configurations for AP or accessing my router.

    And it works, but I’m not sure if this is the proper way to switch between the two cases.

  • Manuel Almeida

    Hello. I used to connect to raspberry pi by SSH and network cable. I tried to connect with WiFi dongle and I found that I only connect if I comment out the line “wpa=2” in the file hostapd.conf. But then I connect in open network. I tried with wpa= 1,2 and 3, but none of them works. Can you help?

    • Peter Kenneth Munene

      Hey. Did you ever find a solution to this? I’m facing the same issue

  • sasmito

    maybe you can check your ip address and dns ip or dns server to get their ip address and dns ip, setting the configuration. /etc/hostapd/hostapd.conf

    wpa_pairwise=TKIP CCMP

    btw do not hack my account, LOL

  • Simon J

    I just got my RPI 2 running OPENELEC. My wifi dongle is a D-Link DWA-121. And it isn’t detected..

  • CarlosD

    Hello its works correctly but there is a tutorial to make work the dhcp with a dns in my intranet????

  • LouisMarie Guiganton

    First off, thanks for the tutorial!

    I’m running into an issue : When I run the configuration script. It seems to work alright, I have the new wifi access point that appears, but I can no longer access the raspberry! It disconnects from my network and I can’t manage to take it back, even by using the ethernet connexion…

    Do you have the solution to this?

    Many thanks

  • Vibhor Sharma

    I am trying to create Access point using your script “sudo ./” but when I try to enter the new AP network i.e. it says “Invalid AP network provided… No X was found at the end of you input. Setup will now exit.” Please help. And provide tutorial for what to input in those fields.

  • Nater

    I have been struggling for days on this to get it to work. I have tried several configs on different sites. This one has gotten me the closes but it still wont fully connect.
    I see the AP and I try to log in and it keeps saying password is invalid. Try on my Mac and it gives a different error but wont log in either. I have a pi 2 with the same exact wifi as the article. did a hostpad config dump and this is what it says – Any help would be greatly appreciated. I have lost count of how many times I have reimaged and started over.

    Configuration file: /etc/hostapd/hostapd.conf



    +rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2





    Using interface wlan0 with hwaddr 00:13:ef:d0:24:36 and ssid ‘carPlex’







    ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument

  • Piyush Mangtani

    hey i am following this post for quite a long time now and i wanted to know how to solve the problem of invalid ap network. I am entering my ap network as but it is saying that its invalid. Please help me out here.

  • gabe817

    I used a dual band wifi adapter (Edimax EW-7811UAC) because I want to support 802.11ac. Everything works on the 2.4 GHz band when I have hw_mode=g but when I set hw_mode=ag to enable dual band I can’t get an IP address. Also, I’m not sure how to set up the SSID and channel of the 5 GHz band. Anyone have any suggestions?

  • Alessandro Grasso

    I have a Raspberry Pi 2 running raspbian jessie and this is working very fine for me!

    I have only a question. Is there a way to decrease the time hostapd is spending trying to connect to the ethernet network?
    I am often using the WiFi to connect to the Raspberry in SSH so I don’t need the ethernet connection on the raspberry but the WiFi of the Raspberry is starting very slowly, it looks like it is waiting for the ethernet connection, in fact the startup is faster with the ethernet cable plugged.

    • Jacek

      Maybe it’s enough to disable (remove?) eth0 interface from /etc/network/interfaces?

      • Alessandro Grasso

        No, it isn’t.
        It took almost two minutes more when the ethernet is not plugged in both cases.

  • Ester Dossett3

    Creative post ! Speaking of which , if someone is requiring to merge two images , my company discovered article here

  • Holf

    You made my day, thank you very much!

    With this supercool script the setup on a Raspberry Pi 3 B running Raspbian Jessie worked like a charm within 2 minutes. I wish i had found it earlier.

    I spend ~2 days trying to work out everything by myself based on a bunch of tutorials that all used different dhcp/dns server packages. Finally my system was so broken that it did not even allow to ping Ok… The horror – I’ve seen it. Two days of frustration but also full of learning things about networking. Now I feel humble and bear a lot of compassion for all those poor sysops that spend their lifetime trying to get along with all those horrible network issues.

    To all those out there who want to get an AP up and running:
    By applying the script provided, you save at least 2 days. Please spend them on something useful like playing with your kids or working for the homeless and hopeless!

  • Marco Di Micheli

    I have a problem, I can see my AP but when i try to connect with it it
    keeps authenticating forever until it times out. Any ideas?

  • ronduino

    Hi guys i could use some advice on where any log files might be kept for dhcp etc

  • clementlefranc

    Hi, this configuration was working on my previous distro (Wheezy). After updated to Jessie it’s not working anymore.
    Do you know what changed ?

  • dylanseq

    Great, many thanks ! Worked perfectly :)

  • jose correia

    Great Job!
    I already walked around the world looking for a solution for my edimax usb dongle.
    As the driver of edimax dongle is based on RTL8188CUS, at least i read somewhere in the internet, i’ve tried to setup as your final instructions with the configuration script. Anyway i faced a problem i saw the network, but i can’t reach to the internet, due authentication problem in my device (android 5 phone).
    Can anybody give me any clue? I’ve done the tests with my pi 2 and cabled internet as source. I used a dongle as AP.

  • Arun Kumar

    Is this support access point in Raspberry PI 3 B+ ? I mean the latest raspebian OS in the Compute Module 3

  • Hamish MB

    Hi, I was wondering if you’d had any luck getting this to work with Raspbian Buster (10)? I’ve partially completed a tutorial (still have a kernel panic problem) on this using resources fro various places, including here, and would like there to be an up to date resource on this some. My tutorial is at if you’re interested.

    I’d really appreciate if you could let me know if you figured this out at some point or have some ideas :)