Search


To get FREE & exclusive emails insert your email-id here

email id:



Tuesday, April 24, 2012

[LINK TO SOLUTION] Create WiFi wireless hotspot in ubuntu for connecting android phones

[Save a lot of time update:  Here's a solution that works given by vineethakartha: Sharing Internet over Wifi Between Ubuntu and Android]

[Update: For people who reached here to get airdroid working, there is an easier way! Scroll down all the way to the updated section to read that]
[Second and more important update: This technique isn't working. My hunch is that it's got something to do with DHCP server. But despite spending hours on it, I haven't got to make it work. And I'm sorry]

Android phones cannot find ubuntu's hotspot or wireless connection
(At least my HTC explorer with android 2.3.5 with my Ubuntu 11.10 and ath9k AR9285 wireless adaptor)

But as you know, I got it working (after a veryyyyyyyyyyyyyyyy long google research with no time to do it, actually)

I had to do this for setting up airdroid on my ubuntu. airdroid is an awesome application to manage android phones from ubuntu linux, by the way.
And configuring airdroid means that you've got a pain in the ass because, airdroid needs that the laptop and the phone be connected to the same wifi network, and when I create a wifi hotspot from ubuntu, using the default options, android doesn't detect it because it's ad-hoc and when i change it to infrastructure, android still doesn't detect it.



All the story aside, let's get into the code.

sudo apt-get install hostapd
#this is the killer! hostapd is designed for this job alone

sudo apt-get install dhcp3-server
#I'm not sure whether this is required, but I installed it reading some guide. Try skipping this step and let me know if it's redundant

(A small digression,
I had tried
sudo iwconfig wlan0 mode master
and got
Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; Invalid argument.
But, as you guessed, persistence wins!)

That's when I headed to the hostapd documentation I linked to already, and found the simple configuration instructions.

Create a configuration file hostapd.conf anywhere

sudo gedit hostapd.conf
 Fill it with the following

interface=wlan0
driver=nl80211
ssid=Any_SSID_name
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Any_password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
The driver, if you noticed, is not athk9, though that's the driver for my wireless adapter. This is just a reference for hostapd to know which mode to use.
Then, run hostapd with that configuration file.

sudo hostapd ./hostapd.conf

That's it! Go to your wifi settings in your android phone, and you'll instantly see the ssid coming up!




Updated Section I know this is stupid, but, for airdroid users, all this hassle is not required. You can just do the reverse - make your android phone the hotspot and let the ubuntu system connect to the phone. ONLY that you should be lucky enough to remember to press the menu button on the airdroid home screen from the android app. And you see the tethering and hotspot option, you press that button and lo! You get the url to visit, instantly!!!

UPDATES, UPDATES, MORE UPDATES : check out this post which probably explains more things to do in this solution.

 Sharing Internet over Wifi Between Ubuntu and Android tells you the further steps that need to be followed, including the dhcp configuration

9 comments:

  1. creted the connection.. but error while connecting....

    ReplyDelete
  2. Updated Section is not working. Also for the main post, it's not connecting after creating the hostpad.conf
    Please reply.

    ReplyDelete
  3. It connected to the SSID, but did not authenticate - here is the error message on the terminal window


    wlan0: STA 50:cc:f8:4d:6d:bd IEEE 802.11: authenticated
    wlan0: STA 50:cc:f8:4d:6d:bd IEEE 802.11: associated (aid 1)
    wlan0: STA 50:cc:f8:4d:6d:bd IEEE 802.11: deauthenticated due to local deauth request

    ReplyDelete
  4. AUTHOR, please reply.. i can see the hotspot on my android tablet, but unable to connect!?

    ReplyDelete
  5. same error
    wlan0: STA 50:cc:f8:4d:6d:bd IEEE 802.11: authenticated
    wlan0: STA 50:cc:f8:4d:6d:bd IEEE 802.11: associated (aid 1)
    wlan0: STA 50:cc:f8:4d:6d:bd IEEE 802.11: deauthenticated due to local deauth request

    ReplyDelete
  6. Everyone getting error, see the updates.

    ReplyDelete
  7. To make it easier, first create a ad-hoc at wlan0. Then turn it to be a wifi hotspot using hostapd. It will work and you don't need to deal with any other configurations.

    ReplyDelete
  8. If only creating "ad-hoc at wlan0" was so easy.

    ReplyDelete

Drop me a comment if anything is missing


Don't forget to visit and follow


BLISSFUL LIFE