Raspberry Pi: Creating A Wifi Access Point

by Clayton Lambert

Today we’re going to be setting up a WiFi Access Point with out Raspberry Pi with a DNS server to point all domains back to our local HTTP server.

Project Requirements

  1. 1. Raspberry Pi Model B+
  2. 2. Edimax Wi-Fi USB Adapter
  3. 3. (Optional) Poweradd Pilot E2 12000mAh USB External Battery Power Bank
  4. (OR) Get The Full Kit: CanaKit Raspberry Pi B+ Ultimate Starter Kit

Setting Up Hostapd

Ideally, you should start with a fresh Raspbian image to make sure these settings does not conflict with your current settings. However, this tutorial should work just fine with any Raspbian image. If you use a fresh install, make sure to run apt-get update.

sudo apt-get update

Creating an access point with hostapd is fairly straight forward. Begin by installing hostapd with the following command.

sudo apt-get install hostapd

Now that hostapd is installed, we need to create a new configuration file in /etc/hostapd/. We’ll just name it “hostapd.conf”.

sudo nano /etc/hostapd/hostapd.conf

Inside this new file we are going to define a few settings for out access point. You can set the SSID and channel to whatever you like, as long as the channel is between 1 and 14.

ssid=Tutorial Access Point

Since we just created a new configuration file, we need to tell hostapd where to locate this file. We need to edit the configuration file location in /etc/init.d/hostapd with the following command.

sudo nano /etc/init.d/hostapd

Find the line “DAMEON_CONF=”, and add the path to our new configuration file.


Setting Up DNSMasq

It’s now time to install DNSMasq. We will configure DNSMasq to point all domains back to to connect to our local server. Start off by installing the dnsmasq package.

sudo apt-get install dnsmasq

Once again we need to edit a configuration file, open dnsmaq.conf in /etc/.

sudo nano /etc/dnqmasq.conf

Move all the way to the bottom of the file, using CTRL + V to skip pages.
At the bottom of the file we need to add the following lines.


Editing Network Interfaces

Next we need to edit our network interfaces file.

sudo nano /etc/network/interfaces

The pi has more than likely already generated a configuration for wlan0. Begin by deleting everything related to wlan0. Assuming you don’t have any other network dongles attached, your file should look similar to the image below.

Network Interface blog claytonn

We are now going to replace the lines we just deleted with the following lines.

iface wlan0 inet static

Installing A HTTP Server

Now that our access point is pointing all HTTP traffic back to itself, we need to install a HTTP server to server up files when they’re requested. For such a small application with little to no worry about scaling we’ll install an Apache server.

sudo apt-get install apache2

When Apache has finished installing you are basically finished, you can now either edit the file apache serves up (var/www/index.html) or reboot the device to test your honeypot!

sudo reboot


Know someone that would find this post interesting? Share it with them!
Share on FacebookTweet about this on TwitterShare on RedditShare on Google+Pin on PinterestShare on TumblrShare on StumbleUpon


  • Mato says:

    I had problem when I add /etc/hostpad/hostpad.conf to /etc/init.d/hostapd but when I add it to /etc/default/hostapd then it works 🙂

  • johi81 says:

    apd, not pad

  • harayz says:

    sudo nano /etc/dnqmasq.conf

  • Chris says:


    I have a ralink rt3070 usb and I can’t seem to find the driver code needed for the “driver=nl80211”. I know it should be different, but I can’t seem to find the right one.

  • Mike says:

    Hey Clayton – thanks so much for this, easily the best tutorial I have seen on doing this.

    I’m a bit of a noob to the RPi, so forgive my possibly dumb questions..

    I’ve got this all working, which is fantastic. I’ve now extended it a bit by putting WordPress on there, which again all works fine. But this raises a question (and I think I know the answer, but just sense-checking in case you have a magic solution..) – presumably once this is set up, the Pi can’t see the web, and so stuff like updates (particularly WordPress, but Pi ones too) can’t be made to happen without going in and editing out the lines in dnsmaq.conf? Or might there be a cunning way for this to be setup? My brain is too small to figure it out.. Maybe allowing “normal” network access _from_ the Pi? I dunno..

    Second q – is there a way that a URL put in by a user when looking at the Pi is _redirected_ to rather than showing it in the address bar? This is a tiny niggle, but a bit of a usability issue for me – so if you put in say digg.com you get whatever you’ve put at – ideally I’d have it instantly redirect…?

    Thanks in advance


  • Nathan says:

    Does anyone know how I can add a password to the wifi. I tried adding wpa_passphrase = ” but it still doesn’t work, the wifi is open to any one

  • asim says:

    hi im using raspberry pi model b+ with edimax and ethernet connection i configured it properly but not wifi hotspot open??

  • black says:

    My configuration file for DNSMasq exist but is empty. I followed your tutorial but DNS do not redirect. Do you think that this is my issue here?

  • bala says:

    hello clayton i saw your videos its very help full to me… i would like to do one practical project on this just i want to show how it happen http://mobilesociety.typepad.com/mobile_life/2014/08/supl-reveals-my-identity-and-location-to-google.html … please tell the steps that how to do describe in praticals

  • Edward says:

    Hello, I’ve seen the tutorial and it’s very interesting indeed; I was wondering, is there any way of showing all connected devices’ MAC addresses somehow?

    I need this for a school project.. I’m sorry I’m pretty much a noob and I’ll surely look it up on the internet but as for now if you (or someone) knew a way I’d really appreciate it!

    Thanks again for the tutorial, good job !!

    • Kevin says:


      View dnsmasq log for clients

      sudo cat /var/log/dnsmasq.log | grep provides | awk ‘{print $9}’ | sort | uniq

  • Malak says:

    I’ve got a problem to open the hotspot on my raspberry pi 3 with my wifi-stick from Edimax (EW-7612UAn V2).

    I want to create something like this:

    1. IF eth0 available (Ethernet Connection) THEN connect the raspberry pi (with eth0) with the Internet and open a hotspot at my Wifi-Stick (wlan1) ELSE connect the raspberry pi with the Internet with the onboard Wifi-Chip (wlan0) and open a hotspot at my Wifi-Stick (wlan1)

    How can I realise this solution?


  • Aditya Sharma says:

    How to go to the default page on an https request?

  • Zop says:

    Worked great once I fixed *MY* typo’s.
    Now if I can come up with a simple web page and script to display a virtual combination lock that will trigger a latch using the GIO, I’m set! (insecure gadget project)

  • Ravi Dhoble says:

    hey, I have created the Hotspot with my Raspberry Pi and my notebook is connected to it. but am not able to access it over FTP. So I cant figure out what’s the problem exactly? Is there any DNS problem? Help me with it.

  • Sovit Singh says:

    I am not getting IP in the victim device. Please help me.

  • Susan says:

    your tutorial is simpler than others that I’ve read. I’ve installed it on a Raspberry Pi 3.

    If boot the RPi without the Ethernet connected, there is not access point ssid.
    If I boot the RPi with the Ethernet, the access point appears and behaves as in your tutorial.

    Any ideas why the access point doesn’t work when attempt that last part of your video?

    • Sam says:

      @Susan Did you setup your internal wifi card to connect to the access point of your router ?

    • Susan says:

      It tuns out (after booting with a monitor rather than ssh) the issue was a common problem – the default timeout on bringing up the network on xenial is 5 minutes. I waited for it to timeout and everything worked. I dropped it back to 20 seconds to make it more usable. FYI: I am using this tutorial to use wifi to remote control a robot 🙂

  • Fares says:

    You jave mistake in the command for netmask and the path pointing to hostapd.conf

  • Add Comment