Creating an adhoc host with Ubuntu

Sponsored Link

Have you ever needed to wirelessly network a Windows PC's directly to a Ubuntu machine?  In other words, you lack a router, switch, or other networking mechanism, each PC has a wireless device and you need to trade a file or play a network game?  Read on.


Ubuntu's NetworkManager 0.7.0 contains the necessary features for creating an Ubuntu adhoc network host.

In Ubuntu:

  • Left click on the NetworkManager icon and select Create New Wireless Network

image1

  • Specify an adhoc network name, i.e. UbuntuAdhoc
  • Select your favorite security method (this example specifies None)
  • Click the Create button

As of Ubuntu 8.10, NetworkManager pretends to connect to the newly created UbuntuAdhoc wireless network but inevitably fails and the NetworkManager defaults back to the last successful network connection.  See below to rectify.

Editing Network Connections:

  • Click on the NetworkManager icon, select Edit Connections.
  • Select the Wireless tab, select the UbuntuAdhoc network and click the edit button.

Editing the UbuntAhoc network:

  • Click the Connect automatically check-box
  • On the Wireless tab, ensure the mode is set to Ad-hoc

image2

  • Select the Ipv4 Settings tab
  • Select the Manual method in the drop down
  • Click the Add button and enter a local IP address, Netmask and Gateway, i.e. 192.255.0.1, 255.255.255.0, and 1.1.1.1 respectively.
  • Leave DNS Servers and Search Domains blank

image3

  • Click OK.

Connecting your Ubuntu session to the new adhoc Network:

  • Left click on the NetworkManager icon and select Connect to Hidden Wireless Network...
  • Select UbuntuAdhoc on the connection dropdown and click Connect.
  • Voila, your Ubuntu session should be connected to itself. Hover over NetworkManager icon, and you should see the yellow message: Wireless network connection to ‘UbuntuAdhoc‘ (0%).

image4

Note: the NetworkManager bars will appear empty since the network adapter technically is not connected to any network. These bars remain empty even when another computer joins the network. Regardless, the connection will work fine.

In Windows XP:

Wireless Connection Properties:

  • Right click the Wireless Connection icon (either from the Windows tray or via the control panel) and select Properties. Ensure to right click on the the windows network icon and not the icon specific to the hardware driver.
  • Select TCP/IP option in The connection uses the following items: window, and click the Properties button. (In this image, I was lazy as I used a Lan connection properties window as my virtual XP session did not have a wireless option to capture, but TCP/IP example is identical).

image5

Internet Protocol (TCP/IP) Properties:

  • Specify an IP address within a few increments of the Ubuntu IP address, i.e. 192.255.0.2. Ensure to match the subnet mask and gateway to the ones specified in UbuntuAdhoc (255.255.255.0 and 1.1.1.1, respectively).

image6

  • Click OK in the both the Internet Protocol (TCP/IP) Properties window and then Wireless Internet Connection Properties window.

Click on your respective window wireless connection icon, select UbuntuAdhoc from list of connections and connect.

Note: Assuming the original IP address was auto selected, ensure to set the Inernet Protocol (TCP/IP) Properties back to Obtain an IP address automatically when reconnecting to another wireless network.

If anyone knows of an easier way please post.

Sponsored Link

Incoming search terms:

Related posts

61 thoughts on “Creating an adhoc host with Ubuntu

  1. OK, so how is 192.255.0.1 “a few increments” from 168.255.0.2? Shouldn’t they both have very similar numbers? i.e. 192.255.0.1 and 192.255.0.2 or am I totally not getting it?

    [Reply]

  2. Boo,

    You are correct. The text and image should read 192.255.0.2. The text has been updated and I will update the XP TCP-IP image once I figure out how.

    Thanks,

    Darin

    [Reply]

  3. excellent. i was able to create an adhoc in mint 8 and connect to iphone 3gs and use its internet. thanks a lot. made it so simple.

    [Reply]

  4. I am able to connect to ad hoc network of ubuntu, but I cannot browse internet in the other computer…
    I did all the steps mentioned above….
    I cannot figure out the problem…

    Please help…
    Thank you in advance

    [Reply]

  5. 2 khaja
    Try to add an external DNS to your configuration on connected computer (OpenDNS for example). Your computer does not forward dns configuration (maybe).

    [Reply]

  6. Ehm… the Class C Private Address range is 192.168.0.0/16 (From 192.168.0.0 to 192.168.255.255).
    192.255.0.1 is NO private address!

    [Reply]

  7. I did all of the above in Mint 10, still happens that does not connect to my adhoc network, simply returns to the last succesful network which is my home wireless network.

    Any suggestions ?

    [Reply]

  8. 2 Mathias
    Try to set up your network via iwconfig, especially mode and essid. You may read my first comment in this topic for some details. I was dropped to another network too until I have set mode to Ad-Hoc via iwconfig.

    [Reply]

  9. I used following simplest technique to access internet from my mobile (e63) from my laptop.

    ubuntu 9.10:
    click network icon in the upper taskbar
    –> create new network
    (same as picture above)
    networkname ‘adhoc’
    security ‘none’
    then goto preferences–>network connections–>wireless–>Adhoc–>edit—>1pv4 settings
    change it to dhcp

    the wifi for mobile works!!

    [Reply]

  10. I have tried this so often I am close to tears (because everybody else seems to be ok without it).
    It does not work…….

    I have a Tenda USB wireless N Adapter
    I have 1 desktop that gets wired connection [shared, gateway to Internet] and 1 wireless USB adapter that is supposed to listen for ad-hoc connections.

    I have Win-7 and Ubuntu 10.10 dual boot.

    When Win-7 boots, ad-hoc connection comes up (scheduled task netsh.exe wlan connect name=my_ad_hoc). But Ubuntu 10.10 laptop cannot connect to this ad-hoc network.

    When Ubuntu boots, I follow the directions given here, (and Ubuntu’s wiki) but connection never gets created.

    If someone knows a reason why please, I’d publicly kiss you on the middle of Golden Gate bridge!

    [Reply]

  11. 2 Guru Pitka

    There may be many reasons for the connection not to work.
    What does ‘sudo iwconfig wlan0′ say?
    Modeset can be wrong (Check for ‘mode:Ad-Hoc’ and not ‘mode:Managed’).
    Check key (if it is encrypted).
    If connection still fails, try to start the ad-hoc via iwconfig
    ‘sudo iwconfig wlan0 essid “YourNetwork” mode Ad-Hoc’.
    BTW is the adapter working normally with non ad-hoc networks?

    [Reply]

  12. 2 Revan

    Try to create an unencrypted connection first. I have not used mandriva distro yet, but it can have the same encryption problem I have described in comments before (what network manager do you use?).
    Second, try to set up autoconnection for each Ad-Hoc.

    [Reply]

  13. “Try to create an unencrypted connection first. I have not used mandriva distro yet, but it can have the same encryption problem I have described in comments before (what network manager do you use?).
    Second, try to set up autoconnection for each Ad-Hoc.”

    By unencrypted you mean no wep, no other password, just open to anyone to connect to?

    Network manager?!? Beats me, it’s the standard one, Mandriva 2010 One comes with… tried to look for any special name it has, no use…

    And by autoconnection, do you mean non-static IP adresses, meaning getting ip-s automatically? That’s what I already did…

    I’m just tired, for almost 2 days searching for a solution to this….

    [Reply]

  14. 2 Revan
    Yes, no password at first. You should try it to understand if there is a problem with encryption.

    I do not know which network manager comes with mandriva, but by autoconnect I mean the option to automatically connect to network even if it is not present.

    And one more thing. Connecting to network, encrypting it and getting IP’s and other related stuff are different issues, which should be solved separately.
    1) Get unencrypted connection working even with no DHCP
    2) Configure the network addresses so the network works as you see fit
    3) Encrypt connection

    [Reply]

  15. After finding that Mandriva 2010 One’s Internet Connection Sharing was bugged…

    Ok, I said to myself, let’s try another linux distro and see if maybe I’ll have a decent ICS with that.
    So, I tried another few: Ubuntu, opensuse, Mint… tried the live CD version of each because I ran out of dvds, and besides, live CD-s should also work, right?
    What do you know, all I tried was broken, although passed md5 test, burned no prob with lowest speed, when tried to boot from live CD… what did I get? A nice broken lines image desktop where you could understand nothing, like an old tv full of bugs… always I had to press the restart button… a totally f… up and hanging desktop where you can see no button or icon, nothing, just broken lines…

    Why don’t they f… test them properly?

    It’s not a problem with my configuration, I tried on another computer, same thing. Considering Mandriva runs, I conclude it’s not my problem but theirs’s…

    And in Mandriva, a new set of surprises: USB sticks are recognized but treated with “zero used space, zero free space”, you cannot copy anything on them, boot login interface likes to just hang sometimes, maybe it’s reading a newspaper in another dimension…

    Tired of all these “minor inconveniences” some pretensed “modern” operating systems do. I’m just the average user. A normal PC, not the worst, not the best. I have my real world life and I don’t want to sit all day in front of my PC trying to fix basic things that should work from the very start in a “modern” operating system…

    I want things to be simple, as they should be, nothing more, nothing less.

    What a really modern operating system should provide to the user:

    (STEPS)

    1. First of all, to be able to boot from the disc
    2. To install easily and properly
    3. To connect to the internet on a direct connection, then be able to share that connection properly with other PC-s
    4. To make a LAN, either cabled or wireless, no problem and access shared files
    5. To update correctly.
    6. To install proprietary drivers when the user wants, considering they own the piece of hardware called “video card”, they have all the right in the world to have access to their proprietary drivers…
    7. To have the basic stuff pre-installed: Open Office.org, a nice media player that actually works with subtitles also, and doesn’t beg for codecs all the time, (people, just install VLC or SMPlayer by default and be done with it), to have GIMP for image editing…
    8. To have a decent community where people can ask for help and they get a good, detailed response, not a superficial one. Sometimes when people answered my posts, I wandered if they actually read what I asked. Really, carefully read. It’s so easy to spit “generalities” out or to mechanically direct them to a wikipedia link or similar…

    Why on earth do such things still happen in 2011? If they did happen 10 years ago, maybe I’d understand, just maybe. But not today…

    From my point of view, it is like this: If somebody actually decides to spend time creating and maintaining an operating system, be it commercial or open source, the creator should care about stability issues first of all. They should be that empathic as to test their operating system and the necessary software not on the best machines only, but on the contrary! On the lowest possible PC-s still in use. Try to test it on more machines, with different configurations… Just to try to imagine themselves in the place of a common user, like I said, not the worst, not the best PC…

    Also, if you are a software creator and if you accept to waste time and energy and resources on creating and maintaing software, then please try to do a good job. Just release a “stable” release when that release is really, really stable, tested on more different configured machines. Download your own created iso-s and burn them on poor (although still acceptable for everyday use) hardware configurations and try to boot from those!!! If all is fine, if all necessary steps I counted a modern operating system should meet are ok, ONLY THEN release the version! And after that, don’t just release version after version, each few months only for fashion’s sake! Why the need for such versions when there are updates! For god’s sake many of my friends still use Windows XP (a truly modern operating system that keeps things simple even for a child’s use), which was released in 2001 (!!!), and if properly updated, they do all those steps I mentioned with this operating system, Windows XP that is.
    From 2001, for humanity’s sake!!! And other “enlightened minds”, come now, after 10 years, (10 years after, hohohooo…) with their “modern” operating systems, which, no matter if they are Vista or Windows 7 or Ubuntu or other crap cannot do the same, cannot provide the basics???… They cannot respect the average PC user that just wants to press a button and get things done, he or she doesn’t need to access all kinds of geeky interfaces and “replace scripts and sh**…

    Some people succeeded back there in 2001. They proved it is possible. The average PC user was respected and need not look for “fixes” for the basics of the basics tasks an everyday average user has to do.

    Look at our divided world today! Each creates his/hers own version of Linux! Not a bad idea at first, the world is beautiful by diversity but that diversity must be sustained by solid usage facts!

    Otherwise, it’s just “art for art’s sake”, just another fashion and propaganda, where in the end the ones that suffer are still the “little people”…
    It’s inadmissible.

    *sigh* Maybe oneday, somebody will really make something nice, with the average user in mind and not their own publicity…

    I really hope for heavens’s sake that this post will be read and interpreted right. Maybe it will make some people think again about some aspects…

    Sorry if english isn’t my native language. I hope what I meant it’s clear.

    I wish all the best to all good intended. I wish to the rest just what they deserve. Nothing more, nothing less…

    [Reply]

  16. To Cabalbl4,
    Saw your reply…yes eveything is working

    The ad-hoc network is created on Win-7 64x

    I can connect to this from another Win-7 64x laptop/computer. But no other OS can connect.

    I have tried Win XP (x32), Win Vista(x32), Ubuntu (x64), Android Gingerbread, Android Honeycomb.

    I was wondering if anyone knew of any connection issues with Win-7 x64

    [Reply]

  17. 2 Guru Pitka

    Ah yes, I remember an issue. Once a friend of mine has brought a win7 notebook to my home, where 3 pc (2 ubuntu and 1 win xp) were connected via ad-hoc. We were not able to connect him to the network. He was always disconnected after 3-5 seconds of connection.

    It seems to be a win7 issue. We didn’t solve it.

    [Reply]

  18. I’ve read all entries to get an idea of issues involved creating an ad hoc for my office. I have some computers with different OS’s and their versions (XP, Vista, 7, etc.). What I’m hearing is that Microsoft (win7) has created a closed system confining connections within their OS only. I. Don’t. Like. This. It forces you into their market and theirs alone. And it also forces me to buy unnecessary equipment for network sharing. I. Don’t. Like. This. I know they won’t listen because it’s all about making money. But someone with talent writing programs should make it their vendetta to smooth out this process and do a in-your-face to Microsoft. Just say’n.

    [Reply]

  19. Hi,

    i am trying to create a mobile website using ruby on rails in ubuntu 10.10 , i run mongrel server locally, can i use the above mentioned method to connect my mobile to the local server running in my laptop….

    if there are any other methods to do so…. plz do specify the link…

    [Reply]

  20. In order to get internet connection, I had to change the “method” under IPv4 settings to Automatic(DHCP) addresses only. Did that then disconnected and reconnected client PC and go a proper ip address in the form:

    IP Address: 10.42.43.80
    Subnet Mask: 255.255.255.0
    Default Gateway: 10.42.43.1

    Prior to this, Windows XP was assigning an automatic IP and we all know that wont work!

    I hope this helps for those of you having no internet access problems.

    All the best!

    [Reply]

  21. Last night I got it to work. Today it will not work. I deleted the ad-hoc network connection and started again. The ubuntu computer wont even connect to it so although the windows computer says it’s connected, I can’t access the machine with the ad-hoc network on it via the network and I can’t access the internet either. It seems that sometimes it works and sometimes it don’t but without rhyme nor reason. Very odd. Maybe it depends on the weather.

    [Reply]

  22. Under the IPv4 setting, you can set it to “Share to other computers” instead of “Manual” and it will let your laptop function as a DHCP server so that computers joining your ad-hoc network won’t need to manually set their IP configurations (although that can make it less secure, especially if you’re running it without wireless security).

    I have a question, though: Is there any way to allow the ad-hoc network to *not* be hidden to guest computers, without using the CLI?

    [Reply]

  23. But CAN’T set it to “Share to other computers.”
    I can set it (of course) but after “apply” I open IPv4 settings and it is DHCP – again.

    [Reply]

  24. I am able to connect the Wi-Fi and able to ping the PCs each other. But the client PC is not able to access internet.I have configured separate DNS address in the configuration but still not able to browse.. still troubleshooting.

    I have iptables configured to DROP every thing except for input chain.
    Chain INPUT (policy DROP)
    target prot opt source destination
    ACCEPT all — anywhere anywhere
    ACCEPT tcp — anywhere anywhere state RELATED,ESTABLISHED
    ACCEPT udp — anywhere anywhere state RELATED,ESTABLISHED

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination

    Chain FORWARD (policy DROP)
    target prot opt source destination
    ACCEPT all — 192.168.0.0/24 anywhere

    Thanks in Advance.
    My linux is ubuntu Lucid
    RAJ

    [Reply]

  25. Great help! I was unsuccessfully trying to view my site in progress from an iPhone over a 3G hotspot device for a long time… When I realised it wasn’t working this helped me view it in no time! Thanks again!

    [Reply]

Leave a comment

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