Hostapd Python Client

Earlier i had written a guide about setting up and running hostapd. To hone my python skills and make using and configuring hostapd simpler, i wrote a python client for hostapd. I also intend this project to serve as a base for a connectify-like GUI hostapd client, which i will start working on in a few days. This project is nearly complete, with proper logging system yet to implement and fix any unknown bugs.

Getting and Installing hostapd-python-script

Just paste this on your command line.

git clone

cd hostapd-python-script

Read the README.textile file, it will get you well covered.


Help me improve it by reporting bugs, suggestions and pull requests. I have only tested it well enough under my Arch Linux installation with ath9k wifi driver, so reporting working/non-working environments will help a lot. I believe the sourcecode is simple enough to understand and i have documented most part of it. Will document the rest in few days as well.

Thank you 🙂


23 thoughts on “Hostapd Python Client

  1. Pingback: Hostapd : The Linux Way to create Virtual Wifi Access Point « Foo, Bar and Foobar

  2. Maikol Solís

    I used your script to share my laptop’s connection with my tablet (which doesn’t have internet). I can run the script, but in my tablet the wi-fi connection still saying “Obtaining IP address” and doesn’t work at all.

    Any suggestion?

    Best regards.

      1. Maikol Solís

        These are the properties of this file

        ls -la py_dhcpd.conf
        -rwxr-xr-x 1 root root 422 28.12.2012 16:29 py_dhcpd.conf*

        This is the script’s output

        sudo ./ start
        Writing /etc/py_hostapd.conf …
        Writing /etc/py_dhcpd.conf …
        configuring wlan0 …
        Starting dhcpd…
        Configuring iptables…
        net.ipv4.ip_forward = 1
        Starting Hostapd…
        Done… (Hopefully!)

      2. Hmida Amine (@aminehmida)

        I think it is apparmor fault in ubuntu : I think it is some kind of sandbox that prevents dhcpd from reading or writing to system files/dirs only /etc/dhcp/dhcpd.conf is authorized. I will try dnsmasq instead

  3. vieq

    Man, I can not thank you enough; this made me happy; although I just had to copy the dhcpd config from another post of yours and the script did the rest of the magic 🙂

    Thank you

  4. jlxsolutionsjlx

    -whaddamanots ~/hostapd-python-script $ sudo ./ start
    Writing /etc/py_hostapd.conf …
    Writing /etc/py_dhcpd.conf …
    Executing scripts/init for [GENERAL]…
    Traceback (most recent call last):
    File “./”, line 29, in
    File “./”, line 22, in main
    File “/home/jlx/hostapd-python-script/”, line 17, in start_hostapd
    ret =[section][‘SCRIPT’], env=env_dict)
    File “/usr/lib/python2.7/”, line 524, in call
    return Popen(*popenargs, **kwargs).wait()
    File “/usr/lib/python2.7/”, line 711, in __init__
    errread, errwrite)
    File “/usr/lib/python2.7/”, line 1308, in _execute_child
    raise child_exception
    OSError: [Errno 13] Permission denied

    1. nims11 Post author

      Sorry I didn’t mention this in readme. Since the recent changes, I have left a lot of jobs to scripts, so you need to give them execute permissions as well. So do a

      chmod +x scripts/*

      This should prevent the error.

  5. jlxsolutionsjlx

    hmm i cant get it to work now after a reinstall (X destroyed my night)
    gives no errors but the laptops cant connect just keeps trying and failing tried manual IP didnt work either. any suggestions on how to diagnose this ?

  6. Carlos

    Writing /etc/py_hostapd.conf …
    Writing /etc/py_dhcpd.conf …
    Executing scripts/init for [GENERAL]… Done!
    Executing scripts/dhcpd for [DHCP]… Failed!
    [ERROR] Failed to initiate [DHCP], check log file logs/dhcpd

  7. milindpatel63

    Writing /etc/py_hostapd.conf …
    Writing /etc/py_dhcpd.conf …
    Executing scripts/init for [GENERAL]… Done!
    Executing scripts/dhcpd for [DHCP]… Failed!
    [ERROR] Failed to initiate [DHCP], check log file logs/dhcpd

    Please help


How did you feel about this post? Push in your reply!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s