Aug 14, 2014

1. Check your Wifi card
Check whether your wifi card support AccessPoint (AP) infrastructure mode
iw list
Your wifi card is good to go if the output shows something like
Supported interface modes:
   * --
   * --
   * AP
   * AP/VLAN
   * --
AP means AccessPoint (AP) infrastructure mode.

2. Install "hostapd"
The latest version was buggy when I'm writing this blog. So install the just before version and hold it's updation. 
64 Bit
wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_2.1-0ubuntu1.2_amd64.deb
sudo dpkg -i hostapd*.deb
sudo apt-mark hold hostapd
32 Bit
wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_2.1-0ubuntu1.2_i386.deb
sudo dpkg -i hostapd*.deb
sudo apt-mark hold hostapd

3. Install dnsmasq

apt-get install dnsmasq

4. Install ap-hotspot
Install  ap-hotspot, it's a set of scripts that helps you to easily configure the hotspot settings.
Download the .deb file from the below links and double click to install.
Ubuntu 12.04 - Click to download
Ubuntu 12.10 - Click to download
Ubuntu 13.04 - Click to download
Ubuntu 13.10 - Click to download
Ubuntu 14.04 - Click to download

5. Configure WiFi hotspot
sudo ap-hotspot configure

6. Start/Stop/Restart WiFi hotspot
sudo ap-hotspot start
sudo ap-hotspot stop
sudo ap-hotspot restart

7. Common Issues/Errors
Another process already running error
When you try to start the ap-hotspot it says 'Another process already running'
sudo ap-hotspot start
Another process is already running
To fix this issue remove hotspot.pid from /tmp
sudo rm /tmp/hotspot.pid
sudo ap-hotspot start

Hope this helps and saved your time...

27 comments:

  1. sudo ap-hotspot debug
    Starting Wireless Hotspot...
    * Stopping advanced IEEE 802.11 management hostapd
    ...done.
    * Stopping DNS forwarder and DHCP server dnsmasq
    * (not running)
    insserv: warning: current start runlevel(s) (empty) of script `hostapd' overrides LSB defaults (2 3 4 5).
    insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `hostapd' overrides LSB defaults (0 1 6).
    insserv: warning: current start runlevel(s) (empty) of script `dnsmasq' overrides LSB defaults (2 3 4 5).
    insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `dnsmasq' overrides LSB defaults (0 1 6).
    * Restarting DNS forwarder and DHCP server configuration syntax check
    ...fail!
    net.ipv4.ip_forward = 1

    ReplyDelete
    Replies
    1. Try to reinstall the dnsmasq, and make sure you installed the correct version of ap-hotspot. Please let me know if the issues persist...

      Delete
  2. its stuck near 'obtaining ip address...'. What to do ?

    ReplyDelete
    Replies
    1. I guess it's problem with the dnsmasq...try reinstalling it....

      Delete
  3. Uhhhh ! Finally find something that really works !! :)

    ReplyDelete
  4. Hi, I got this working, but how do I now transfer files from my android phone running jelly bean to my laptop running ubuntu 14.04? I tried pinging from phone to laptop and from laptop to phone but the pings failed. They do seem to be connected to each other though...

    ReplyDelete
    Replies
    1. Turn the USB sharing On, which will be promoted on the mobile device when plugged in. Then your mobile's internal storage will be mounted like a usb pendrive and you can transfer files.

      Delete
  5. Thanks for this post. I always knew that it was possible to do this I just never needed to up until this trip I'm taking in a couple weeks.

    ReplyDelete
  6. I get this message :-
    sudo ap-hotspot configure
    Your wireless card or driver does not support Access Point mode

    my driver should support because output of
    iw list |grep AP
    * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
    * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
    * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
    * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
    and
    lspci -k|grep -A 3 -i "network"
    01:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)
    Subsystem: Intel Corporation PRO/Wireless 3945ABG Network Connection
    Kernel driver in use: iwl3945
    02:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet Controller
    Subsystem: Elitegroup Computer Systems Device 0090

    ReplyDelete
    Replies
    1. Seems like your wifi card is not compatible for creating access points.

      Delete
  7. Thanks Nikhil, this worked fine and saved the day.
    My 2 cents, I used the repo version of hostapd and ap-hotspot , and this worked for me.

    ReplyDelete
  8. ok i conected with my android now how to share files between my ubuntu and adroid device

    ReplyDelete
    Replies
    1. Well this tutorials describes how to setup a hotspot on your ubuntu machine, so that you can share the internet on laptop with your android device. This won't help to transfer files between laptop and mobile. For transferring files just connect your android device via usb cable to your laptop.

      Delete
  9. Thank you very much...... iam very happy on this post

    ReplyDelete
  10. sudo ap-hotspot start
    Please disconnect WiFi before proceeding

    ReplyDelete
    Replies
    1. i'm also getting same error wht to do?????

      Delete
  11. Check if your wifi adapter is already connected to a network, If so disconnect it and follow the the steps

    ReplyDelete
  12. thnx...its working

    ReplyDelete
  13. thanks for the help

    ReplyDelete
  14. hello!! in my lapy it is showing that ap-hotspot is running but i cant get it in my android mobile what can i do for this prlblm??

    ReplyDelete
  15. wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_1.0-3ubuntu2.1_amd64.deb
    NOT WORKING SERVER ERROR
    PLS HELP

    ReplyDelete
    Replies
    1. Hi Akhil,
      Thanks for pointing out.
      I have updated the links, please check now.

      Delete
  16. anand@Anand-Lap:/tmp$ sudo ap-hotspot debug
    Starting Wireless Hotspot...
    * Stopping DNS forwarder and DHCP server dnsmasq
    ...done.
    update-rc.d: warning: start runlevel arguments (none) do not match hostapd Default-Start values (2 3 4 5)
    update-rc.d: warning: stop runlevel arguments (none) do not match hostapd Default-Stop values (0 1 6)
    Disabling system startup links for /etc/init.d/hostapd ...
    Removing any system startup links for /etc/init.d/hostapd ...
    /etc/rc0.d/K20hostapd
    /etc/rc1.d/K20hostapd
    /etc/rc2.d/K80hostapd
    /etc/rc3.d/K80hostapd
    /etc/rc4.d/K80hostapd
    /etc/rc5.d/K80hostapd
    /etc/rc6.d/K20hostapd
    Adding system startup for /etc/init.d/hostapd ...
    /etc/rc0.d/K20hostapd -> ../init.d/hostapd
    /etc/rc1.d/K20hostapd -> ../init.d/hostapd
    /etc/rc6.d/K20hostapd -> ../init.d/hostapd
    /etc/rc2.d/K80hostapd -> ../init.d/hostapd
    /etc/rc3.d/K80hostapd -> ../init.d/hostapd
    /etc/rc4.d/K80hostapd -> ../init.d/hostapd
    /etc/rc5.d/K80hostapd -> ../init.d/hostapd
    update-rc.d: warning: start runlevel arguments (none) do not match dnsmasq Default-Start values (2 3 4 5)
    update-rc.d: warning: stop runlevel arguments (none) do not match dnsmasq Default-Stop values (0 1 6)
    Disabling system startup links for /etc/init.d/dnsmasq ...
    Removing any system startup links for /etc/init.d/dnsmasq ...
    /etc/rc0.d/K85dnsmasq
    /etc/rc1.d/K85dnsmasq
    /etc/rc2.d/K85dnsmasq
    /etc/rc3.d/K85dnsmasq
    /etc/rc4.d/K85dnsmasq
    /etc/rc5.d/K85dnsmasq
    /etc/rc6.d/K85dnsmasq
    Adding system startup for /etc/init.d/dnsmasq ...
    /etc/rc0.d/K85dnsmasq -> ../init.d/dnsmasq
    /etc/rc1.d/K85dnsmasq -> ../init.d/dnsmasq
    /etc/rc6.d/K85dnsmasq -> ../init.d/dnsmasq
    /etc/rc2.d/K85dnsmasq -> ../init.d/dnsmasq
    /etc/rc3.d/K85dnsmasq -> ../init.d/dnsmasq
    /etc/rc4.d/K85dnsmasq -> ../init.d/dnsmasq
    /etc/rc5.d/K85dnsmasq -> ../init.d/dnsmasq
    * Restarting DNS forwarder and DHCP server dnsmasq
    ...done.
    net.ipv4.ip_forward = 1

    ReplyDelete
    Replies
    1. Try the two commands before ap-hotspot

      sudo nmcli nm wifi off
      sudo rfkill unblock wlan

      Delete