Configuring hostapd on Raspberry Pi

Configuring hostapd on Raspberry Pi

The daemon hostapd is a Linux service which enables  a “host” computer to become a WiFi Access Point (AP).     Thus  “host” + “AP” + “d”  (for daemon) gives the name hostapd.

I originally learned to set up hostapd from  instructions on Pastebin written by user Dryfire117,1 andlater found useful instructions on the Raspberry Pi website.2 The process originally involved building the daemon from source code to get support for the nl80211 driver, but that is now included with the prepackaged version you can install using apt-get. Here are the main steps:

  1.  Install:  Install hostapd with the following command
    $ sudo apt-get install hostapd
  2. Configure: Create and edit the configuration file, at /etc/hostapd/hostapd.conf.
    For starters, include the following:

    #If this fails, try rt1871xdrv a 
    # Name of the new network: best use the hostname
    # Pick a channel not already in use
    # Change to b for older devices?
    # Disable this to insure the AP is visible:

    This creates an open, unsecured access point. Anybody can connect to it without having to give a password. In some cases that is what you want, but in other cases you will want
    to turn on WPA for security and add a password.  In that case, add the following to the hostapd.conf file:


    You should, of course, pick a better password. It has to be at least 8 characters long.

    There are many, many other options which can be set in this configuration file, but these are the ones needed in most cases to get up and running. Full documentation of the options can be found in a sample configuration file at

    A few things I’ve learned from testing options on the Raspberry pi are that trying to enable the Automated Channel Selection (ACS) algorithm  via “channel=0” does not work, and setting “hw_mode=any” does not work.

  3. Test:  Test it manually to make sure the configuration file is okay:
    $ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
    If there are errors it will complain and abort.  Unfortunately some older wifi devices don’t support all the features necessary to run an access point.   This is where you find out if yours will work.If there are no problems it will run and you can see the network SSID on a nearby device. Simply press ^C to stop it.
  4. Enable: Have hostapd start at boot time, by doing the following:
    1. Set the default location for the configuration file, by editing the file /etc/default/hostapd to add the following line:
    2. Enable the service at boot time with the command:
      $ sudo update-rc.d hostapd enable
    3. You can test it now with the command
      $ sudo service hostapd start
      and/or you can reboot.

Once hostapd is enabled and running, the next step is to enable the DHCP service, so that clients joining the network are automatically assigned IP addresses.


  1. How to: Make a Raspberry Pi Powered Wifi Repeater” by Dryfire117,
  2. Setting up a Raspberry Pi as a routed wireless access point,”
Print Friendly, PDF & Email