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 https://github.com/nims11/hostapd-python-script.git

cd hostapd-python-script

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

Contribute

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 🙂

Advertisements

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

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

    Reply
      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 ./hostapd.py 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

    Reply
  4. jlxsolutionsjlx

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

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

      Reply
  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 ?

    Reply
  6. Carlos

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

    Reply
  7. milindpatel63

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

    Please help

    Reply

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

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s