How to Enable Ad-hoc Connection on your Android

Hello,
I was searching for a long time how to enable ad-hoc connections on my HTC chacha and finally I found it!, so I decided to share my experience with you.
btw I found many ways but guess what?! most of them didn’t work :(

lets stop talking and start enjoying the unlimited internet connection on your mobile :)

Ubuntu Users

First of all you had to install hostapd

“In simple words, hostapd allows you to create software wifi access points allowing decent amount of configuration options. In rest of this post, I will show how to create a software access point in Linux using hostapd and share your internet to the devices through it”

To Install hostapd just type this command on the terminal

sudo apt-get install hostapd

Then, open a text editor program, for example gedit. Copy the following into it.

interface=wlan0
driver=nl80211
ssid=MyAP
hw_mode=g
channel=11
wpa=1
wpa_passphrase=MyPasswordHere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600

Please don’t forget to fill in the name of your network after “ssid=”, as well as the password after “wpa_passphrase=”.

After all these, save the file as hostapd.conf in your home folder.

Then create a normal ad-hoc network from the wireless menu from the top bar click on “Create New Wireless Network

after the new network created successfully proceed to the next and the final step

Now, in your terminal:

sudo hostapd hostapd.conf

Turn the wifi connection on in your devices and enjoy the fast network share!

Windows Users

You can install Virtual Router

Project Description

Virtual Router turns any Windows 7 or Windows 2008 R2 Computer into a Wifi Hot Spot using Windows 7’s Wireless Hosted Network (Virtual Wifi) technology.

What is Virtual Router?

Virtual Router is a free, open source software based router for PCs running Windows 7 or Windows Server 2008 R2. Using Virtual Router, users can wirelessly share any internet connection (Wifi, LAN, Cable Modem, Dial-up, Cellular, etc.) with any Wifi device (Laptop, Smart Phone, iPod Touch, iPhone, Android Phone, Zune, Netbook, wireless printer, etc.) These devices connect to Virtual Router just like any other access point, and the connection is completely secured using WPA2 (the most secure wireless encryption.)

Download Virtual Router

http://virtualrouter.codeplex.com/downloads/get/93540

 Preparing your Wireless Connection

After installing Virtual Router and restarting, open the application this window will appear

Type your network name ,, and your password ,, choose network to share ,, and click on Start Virtual Router

Turn the wifi connection on in your devices and enjoy the fast network share!

 

Resources

http://nims11.wordpress.com/2012/04/27/hostapd-the-linux-way-to-create-virtual-wifi-access-point/

http://exain.wordpress.com/tag/hostapd/

http://zhangyou.wordpress.com/2010/08/26/easily-turn-your-ubuntu-into-a-virtual-router/

http://virtualrouter.codeplex.com

Comments

  • Soham Sinha ~ September 15, 2012

    My connecting device is not getting its IP. So it’s not able to connect!! :(

    • Mohamed El Shaer ~ September 15, 2012

      what is ur platform? ubuntu?
      if so create an ad-hoc connection first before running the hostapd command =)
      I am going to edit the post to point to this issue =)

  • tetrakos ~ October 7, 2012

    Great job!
    It worked perfectly for me and is completely secure with WPA encryption. Thanks a lot!

    Just FYI, the first time, I had to try twice to get my HTC wildfire S connected. Now, it works directly.

    • Mohamed El Shaer ~ November 25, 2012

      I am glad that is working for you ,, but no Idea why you have to do it twice =)) ,, maybe something went wrong

  • sajeewa shishan ~ October 15, 2012

    hay guys This works foe HTC one X :D

  • abhilash ~ November 16, 2012

    Hi. My HTC sensation has detected the wifi network,and i got connected to it successfully. However i cannot surf internet on my HTC. its like, its just connected to the wifi, not the internet. :(

    • Mohamed El Shaer ~ November 25, 2012

      are you using windows? ,,
      are you sure that your pc is already connected to the internet?

  • polym ~ December 3, 2012

    I can do it when i use ubuntu 12.04, but it is failed to be done in ubuntu 12.10. So I retry it, but there is only isc-dhcp-server instead of dhcp3-server. Now my kindle can search this wifi, but cant connect. can you give me some advice?

    • Mohamed El Shaer ~ December 3, 2012

      so another hack is to create an adhoc connection from “Create New Wireless Network” , and when the connection established run the commend “sudo hostapd hostapd.conf” and you can now connect to this network =)) ,, hope this work with you

  • sm ~ December 10, 2012

    Thanks very much! It worked for galaxy s (gt-i9003) w kubuntu 12.12. But due to “kernel bugs” I couldn’t set up adhoc wireless + WAP on network_management. I created an unsecured one. Is it unsecured indeed?

    • Mohamed El Shaer ~ December 10, 2012

      unsecured mean that anyone can access the network, you can disable broadcasting the SSID check this file
      http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=hostapd/hostapd.conf

      • sm ~ December 10, 2012

        Thanks a lot for the answer! But maybe I was not clear. My hostap.conf is exactly the one you suggested, with the wap lines.

        Connecting from my android, for example, it asks for the wap password.

        It is just the adhoc on kubuntu (I needed to set up to obtain IP) which is not wap (nor wep).

        My question is whether I am safe or not.

        • Mohamed El Shaer ~ December 12, 2012

          aha,, if you setup an ad-hoc connection,, and then run the hostapd command the new network will replace the ad-hoc one so yea you are safe :)

          • sm ~ December 12, 2012

            :) Thanks a lot!

  • sm ~ December 10, 2012

    sorry. I meant wpa

  • chma ~ January 4, 2013

    Thank you very much but … it doesn’t work for me…
    I have Ubuntu 12.04 and when I run “sudo hostapd hostapd.conf” on my terminal, it says this:

    Configuration file: hostapd.conf
    Could not set interface mon.wlan0 flags: Operation not possible due to RF-kill
    nl80211: Failed to set interface wlan0 into AP mode
    nl80211 driver initialization failed.
    ELOOP: remaining socket: sock=4 eloop_data=0x9a198f8 user_data=0x9a19e98 handler=0x807c5e0
    ELOOP: remaining socket: sock=6 eloop_data=0x9a1bca0 user_data=(nil) handler=0x8086770

    Have you any idea…?
    Thank you!!!!!

  • kevin shah ~ January 7, 2013

    hello, i have just installed virtual hotspot 1.2 application to my windows xp and after that my i phone easily connected to it but galaxy note 1 is not even finding the hotspot name in available network list….
    pl help.

  • stefano ~ January 25, 2013

    I tried this on my ubuntu 12.04 but my galaxy ace watch the connection but it does’t take an ip, must i do something with dhcp?

  • cipher ~ February 10, 2013

    It continuous to show ‘Obtaining IP address’ in my micromax A110. I’m using ubuntu 12.10. Should I add anything to the above steps?

  • abel haile ~ February 18, 2013

    android phone to adhoc connecror

  • suresh ~ March 18, 2013

    Its stuck at
    “Configuration file: hostapd.conf
    Using interface wlan0 with hwaddr 68:5d:43:c5:2c:95 and ssid ‘abcds'”
    Any idea to resolve this..
    OS : Ubuntu

  • julian ~ March 25, 2013

    i connect to the wifi network,but I do not have internet access in my android???a solution please…

  • Flo ~ March 27, 2013

    cant get the Ip on mySamsung s.
    Terminal says:
    sudo hostapd hostapd.conf
    Configuration file: hostapd.conf
    Using interface wlan0 with hwaddr 00:25:d3:9c:fb:db and ssid ‘Floswlan’
    wlan0: STA 20:13:e0:c6:d7:1b IEEE 802.11: authenticated
    wlan0: STA 20:13:e0:c6:d7:1b IEEE 802.11: associated (aid 1)
    wlan0: AP-STA-CONNECTED 20:13:e0:c6:d7:1b
    wlan0: STA 20:13:e0:c6:d7:1b RADIUS: starting accounting session 5152E85F-00000000
    wlan0: STA 20:13:e0:c6:d7:1b WPA: pairwise key handshake completed (WPA)
    wlan0: STA 20:13:e0:c6:d7:1b WPA: group key handshake completed (WPA)
    wlan0: AP-STA-DISCONNECTED 20:13:e0:c6:d7:1b
    wlan0: STA 20:13:e0:c6:d7:1b IEEE 802.11: disassociated
    wlan0: STA 20:13:e0:c6:d7:1b IEEE 802.11: deauthenticated due to inactivity

    Thanks for help

  • otapol ~ March 30, 2013

    Hi,
    for static IP is conection redy.
    Not function FORWARDING and DHCP server

  • arka ~ April 9, 2013

    Problem… :(

    using an ubuntu based distro
    pppoe is cofigured with pppoeconf

    my samsung galaxy connects perfectly with wifi but can’t access internet

  • Eric ~ April 11, 2013

    Perfect! Now I can connect my kindle to sync via my ubuntu shared connection. (using Ubuntu 12.04). Thank you! I connected with no internet sharing though, until I did the hack/tweak mentioned in comment #10.

  • sachin ~ April 16, 2013

    Worked fine for me!
    Thank you so MUCH!
    (ubuntu 12.04)

  • Derek ~ April 18, 2013

    Configuration file: hostapd.conf
    nl80211: ‘nl80211′ generic netlink not found
    Failed to initialize driver ‘nl80211′

  • Erick ~ April 19, 2013

    Works for me in windows 7 and a sony live walkman with android 4.0, thanks for the tutorial.

  • ShawnS ~ May 6, 2013

    What you’re doing is NOT enabling ad-hoc wireless on the Android device. You’re running infrastructure wireless mode from the host computer instead of ad-hoc mode.

    That said, there are some methods for actually enabling ad-hoc on the Android such as http://www.androidsim.net/2011/08/how-to-35-connecting-to-adhoc-networks.html

  • Ahmed Saleh ~ May 6, 2013

    Hello ,

    Really thank you very much for your tutorial , i was very happy to see the (GEEKPEEK) at my android device connected to my ubuntu. but unfortunately , there is no internet in my android device. could you please help me to share the internet.

    when i run the command to start sharing the wirless this line appears:
    Using interface wlan0 with hwaddr 00:c0:a8:ee:f4:48 and ssid ‘geekpeek’

    and after configuring my phone – it has beem connected succefully and these lines appears:
    wlan0: STA 30:85:a9:65:f0:bf IEEE 802.11: authenticated
    wlan0: STA 30:85:a9:65:f0:bf IEEE 802.11: associated (aid 1)
    AP-STA-CONNECTED 30:85:a9:65:f0:bf
    wlan0: STA 30:85:a9:65:f0:bf RADIUS: starting accounting session 51880568-00000000
    wlan0: STA 30:85:a9:65:f0:bf WPA: pairwise key handshake completed (RSN)

    your help is really appreciated.

    All Respect;

  • Mohamed El Shaer ~ May 13, 2013

    Hello friends ,, I updated the post ,, for all those who have any error ,, please try the new way to get the IP ,, without installing DCHP :)

    Best Regards

  • Veronika ~ May 14, 2013

    Hi,

    I’m able to see the network I set up and my phone is trying to connect to it, but it always stops at the “Obtaining IP address” phase. On the terminal I see

    IEEE 802.11: authenticated
    IEEE 802.11: associated
    AP-STA-CONNECTED
    RADIUS: starting accounting session
    WPA: pairwise key handshake completed (WPA)
    WPA: group key handshake completed (WPA)
    —-(Slight pause here, phone is trying to obtain IP address)—-
    AP-STA-DISCONNECTED
    IEEE 802.11: disassociated
    IEEE 802.11: deauthenticated due to inactivity

    Any ideas?

    -

    • Mohamed El Shaer ~ May 15, 2013

      did you create a New regular ad-hoc network before running the command “sudo hostapd hostapd.conf”

  • Rex W ~ May 15, 2013

    oh my! this is working wonderfully. I am successfully sharing my wired connection from Ubuntu 13.04 to my 2 android devices! things are looking good.

    Thanks for the write-up!

  • omar ~ May 16, 2013

    i’ve only LOCAL AREA CONNECTION in SHARED connection
    also when I click (START VIRTUAL ROUTER) it give : couldnot be started >> :(

    help plzz

  • Ajay ~ May 16, 2013

    HI..Thank you for the information.
    As per u i downloaded virtual router on my windows 7 laptop, however when i tried to start it it showing an error as virtual router could not be started.. Can you please help me on this..

  • guide for android ~ May 29, 2013

    I just now couldn’t go away completely your internet-site ahead of suggesting that I definitely cherished the regular details a person offer in your company? Will probably be backside nonstop in an effort to take a look at innovative discussions

  • tsu ~ May 30, 2013

    Thank you, but it doesn’t work for me, when i run sudo hostapd hostapd.conf from terminal it says

    Configuration file: hostapd.conf
    Could not read interface wlan0 flags: No such device
    Could not read interface wlan0 flags: No such device
    nl80211 driver initialization failed.

  • joser116 ~ June 23, 2013

    Virtual Router does not work on Windows XP :(

  • Tony ~ July 1, 2013

    I have the impulse 49 for at&t (u8800-51) and my device fails to connect with my adhoc network. Im sending the signal from a laptop and my phone can see it but wont obtain the IP address. IT’S DRIVING ME MADDD!!! Is there a way I can get this thing to connect??

  • Salvatore ~ July 10, 2013

    does this work without a wireless modem???????
    i want to access internet in my android tablet but i dont have a wireless modem…. will this solve my problem???????

  • Salvatore ~ July 10, 2013

    i downloaded it and installed , but iam not able to fill any of the columns , and its written in the down that “Can not manage virtual router.The service is not running” what should i do , plzz help me????

  • Maninder ~ July 12, 2013

    Sir,
    I want to use my nokia e63 wifi adhoc (joikuspot) connection on micromax canvas hd version 4.2.1.Pls tell me will it work or not.tx in advance

  • Ansh ~ July 16, 2013

    It works great on windows 7.
    Thanks a ton

  • nick ~ August 18, 2013

    WOW! It worked for me. Thanks……..

  • Ivan ~ September 5, 2013

    Thanks Man. Working perfectly.

  • Sanjeevi ~ September 25, 2013

    Thanks.. it worked fine with my HTC Desire S & Ubuntu.

  • Dina ~ September 30, 2013

    Thanks!
    It works with my Ubuntu notebook and Android phone!

  • Marco Marocco ~ January 2, 2014

    Thanks, working perfectly!!!

  • Salam ~ January 25, 2014

    Thanks a lot , but i still have a problem , i have ubuntu 13.10, so when i run hostapd.conf in a terminal i get error :
    ” $ sudo hostapd hostapd.conf
    Configuration file: hostapd.conf
    Line 7: invalid WPA passphrase length 5 (expected 8..63)
    WPA-PSK enabled, but PSK or passphrase is not configured.
    2 errors found in configuration file ‘hostapd.conf’

    where i use hotspot as a username and myhot as a password.
    Sorry iam new for ubuntu , so any help would be great appreciated
    thanks .

  • alok ~ April 7, 2014

    thank you sir, you are a life saver…..

  • sahat ~ April 22, 2014

    this way just change adhoc network to insfrastructure hotspot,
    so that android device can connect to it, and i think i can’t really call this one as adhoc.

    am i wrong??
    and is there another way to connect my android device to adhoc net?

  • Hamed ~ May 17, 2014

    However this solution is not ad-hoc mode wifi. This solution is related to infrastructure mode by creating a virtual wireless access point router. As Stated in many sites, ad-hoc mode needs the android to be rooted

  • Diab ~ October 25, 2014

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *