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. First of all, thanks for this walk-through. I followed the steps above in Ubuntu, but I could not connect my Ubuntu session to my new adhoc network. Any ideas?

    [Reply]

  2. I have yet to figure out how to make an UbuntuAdhoc issue an IP address to the connecting machine. Thus, I have to do the following until then:

    If connecting from a Ubuntu to Ubuntu machine, the 2nd Ubuntu machine requires nearly identical configuration as the hosting UbuntuAdhoc.

    On the 2nd machine, attempt to connect to UbuntuAdhoc. When the connection fails, edit the UbuntuAdhoc connection:
    – Right click on the NetworkManager icon and select Edit Connections
    – Select the Wireless tab
    – Select UbuntuAdhoc and click the Edit button

    Editing Auto UnbuntuAdhoc window:
    On the Wireless tab, ensure Mode is set to Ad-hoc
    On the IPv4 tab, set Method to Manual
    In the IPv4 Addresses table, add ip, netmask & gateway: 192.255.0.2, 255.255.255.0, 1.1.1.1 respectively.

    [Reply]

  3. Absolute cool stuff! Works perfectly.
    With a little bit of

    # echo 1 > /proc/sys/net/ipv4/conf/eth1/proxy_arp

    # echo 1 > /proc/sys/net/ipv4/ip_forward

    plus a correct routing entry on your Internet gateway plus correct DNS entries on the client you can use this to give Internet access to clients.

    One question: If I want to remove my adhoc AP how can I do this? I can’t find the configuration for it and it remains there even if I click delete on Network Node Manager ? Right Click ? Wireless … ? delete. After the next reboot it is there again.

    Matthias

    [Reply]

  4. Mattes,

    You must only know how to do the hard stuff! :) Could you please expand on the Internet gateway portion of the IP forwarding? I assume I enter my ISP’s DNS and gateway on the IPV4 tab of the client UbuntuAdhoc setup to enable Internet sharing? (I will give it a shot.)

    To Delete the UbuntuAdhoc:
    Right click on the NetworkManager icon and select Edit Connections
    – Select the Wireless tab
    – Select UbuntuAdhoc and click the Delete button

    dsm

    [Reply]

  5. Ubuntu4us,

    it is as you said.

    The UbuntuAdhoc client (Windows) need to have the default gateway pointing to the UbuntuAdhoc AP. The DNS need to point to the real DNS. Probably the same as set on the UbuntuAdhoc AP.

    The internet gateway (in my case the DSL router) need to know where to send packets for the client network. I had to add a route to 10.0.0.0 on the DSL router. This has to point to the UbuntuAdhoc AP but to the IP on the side of DSL Router. Confused? I am! ;-)


    Internet DSL-Router UbuntuAdhoc AP Client
    149.1.2.3 172.16.2.1 172.16.2.23 10.0.0.1 10.0.0.2
    ^- DNS IP

    In pseudo code something like # route add 10.0.0.0 netmask … gw 172.16.2.23

    BTW.: I can’t test this right now. I writing this from my memory. I check it end of the week.

    Matthias

    [Reply]

  6. Sorry the formating got messed-up!

    Internet 149.1.2.3 DSL-Router 172.16.2.1 172.16.2.23 UbuntuAdhoc AP 10.0.0.1 10.0.0.2 AP Client

    172.16.2.1 is my DNS

    [Reply]

  7. My network manager windows look nothing like the examples shown. I left click on the icon, and click on ‘create new wireless network’ and then do the above – but instead of a ‘create’ button it only has a ‘connect’ button, and I don’t know if it is actually creating the network. It doesn’t seem to connect to itself on the host machine, and if I right-click and go to ‘edit wireless networks’ it aint there. Plus, the entire interface looks different to above.

    I’ve got network manager installed, synaptic indicates I do, and I’m running off Ubuntu 8.10. Anyone know why the interface looks remarkably different?

    [Reply]

  8. I got the network manager to set up the network but when I connect to the network with other devices like another laptop or an ipod touch, I can’t get it to share the internet. The other laptop just sees it as an ordinary device. Does any one know what I can do to make it share the internet connection? I would really appreciate it a lot.

    [Reply]

  9. i can’t detect my ad-hoc wireless network but i’m done with this guide?!
    my device is sony ericsson p1i

    [Reply]

  10. I have not tried the Ad-hoc on anything but a Dell laptop with an Intel wireless card, thus I cannot advise on other systems. Ensure the following packages are installed via Synaptic:
    avahi-autoipd
    lib32nss-mdns
    libnss-mdns
    libopenobex1

    If I could convince more people around here to run Linux, I could expand my experience base. But sadly, few people are willing and/or knowledgeable enough to try more advanced aspects of Linux.

    [Reply]

  11. Do you happen to know how to do it from the CLI?

    Using GUIs isn’t geek at all and doesn’t work for all.

    And as for me, I can’t create an ad-hoc network while I’m conected to a WPA wireless with other card using NetworkManager : ( yes, I have 2 wireless cards : )

    [Reply]

  12. :) Hallo! I install Ubuntu 9,04 on my Laptop HP Pavillion dv 6000. One problem with wireless card (Intel PRO/ wireless) 3945ABG – when my friend connect to my ADHOC, after 20 sec. system disconnect%) If anybody has the same problem?

    [Reply]

  13. Even though i created a wireless network I got status “Never” in the time of Creation column. I switched on the wireless device. but still no progress

    [Reply]

  14. Hello,

    it works-but only without encryption. When i use Wep or Wpa my client says “wrong length of wep key” it doesn t matter if i use wep or wpa- My client cannot connect. Any suggestions ?

    regards

    [Reply]

  15. I have a working ad-hoc connection between ubuntu 9.10 on toshiba satellite A210 (atheros wireless with ath5k driver) and my home PC (Win XP + D-link DWA-110 wireless). I even got it encrypted using WEP :) But there are some things not described in this article:

    1) Ensure that Ad-Hoc mode is set (for me it was an essential step):
    sudo iwconfig wlan0
    And if mode is not Ad-Hoc (e.g. “Managed”) use
    sudo iwconfig wlan0 mode Ad-Hoc
    2) Wireless meter is not working correctly in my ubuntu PC, showing 0% on connection. As far as I remember the RTFM, this is not a bug, it is a feature on Ad-Hoc in ubuntu:) But the connection is working, for sure :)
    3) When setting encryption in network-manager, be sure to do the following:
    – establish a working non encrypted connection first
    – in network manager, there is a strange bug – when you enter a key, it may be changed by the manager in a random way. But there is a workaround: make the changed key visible in network-manager, and use it in windows )
    4) My internet is set via ICS on windows. It is working fine on ubuntu, but only after I set an external dns server (freeDNS) in my ubuntu network options. (I have tried a proxy on windows before, but I’ve got tired of it’s gleeches.)

    Still, after setting everything, sometimes I am getting disconnects on windows side (but quite rare). Resetting network on ubuntu does the trick. Sometimes setting fragmentation threshold 512 bytes helps with them, but not for sure
    (sudo iwconfig wlan0 frag 512). I think this appears because of network interference of unknown origin.

    BTW, my XP PC is set to use ip 192.168.0.1, and the ubuntu is set to use 192.168.0.10. It seems that ICS is having some trouble with other (NON 192.168.0.X and mask 255.255.255.0) addresses.

    [Reply]

  16. hello there.
    that is brialliant info.

    followed the whole thing through and got the two machines to connect. they can ping eathother successfully.
    but the windows client cannot ping anything but the ubuntu host.
    installed dnsmasq as i read somewhere.
    or do i need to do this with iptables?

    i have been trying this so far with no luck:

    #iptables -t nat -A POSTROUTING -s 192.255.0.0/24 -o eth0 -j MASQUERADE
    #iptables -A FORWARD -s 192.255.0.0/24 -o eth0 -j ACCEPT
    #iptables -A FORWARD -d 192.255.0.0/24 -m state –state ESTABLISHED,RELATED -i eth0 -j ACCEPT

    [Reply]

  17. 2 subaru

    I do not know exactly, but it seems that this can be an issue of damaged winsock on windows (misconfigurated by a program or a trojan). Once I’ve got an issue in windows network when machines were unable to ping each other. Try to rebuild winsock by running command window on XP, then input “netsh winsock reset”, enter, reboot.

    Maybe this will help.

    [Reply]

  18. I tried running these steps on a Xubuntu 9.04 system and a Windows Vista client. I also installed dnsmasq. However, this doesn’t work yet. Even with just the Linux machine set up for Adhoc mode, (without the Windows machine in the picture yet), the AdHoc network doesn’t seem to be activated. The Network Manager daemon says that it is trying to connect, but fails to do so, after trying for 1 minute or so. Any suggestions would be appreciated.

    Also: Your instructions specify that the Linux machine should use a IP address of 192.255.0.1, and the Windows machine 168.255.0.2. Shouldn’t they both have the same value for the first field?

    Thanks

    [Reply]

  19. Prabhat,

    Good catch. My example should specify 168.255.0.1. I have not tried an adhoc connection with Vista nor have needed to use adhoc for quite some time.

    Subaru,

    I apologize as I have no idea how to connect through to other networks with this connection. If you discover how, please post.

    dsm

    [Reply]

  20. Doesn’t work.. well up-to when the setting is done and about to connect to the hidden connection. I select the connection name… but the connect button goes grey.. and when i check on network manager by right clicking.. i see random latin greek words under avaliable networks. So when i click on it to connect.. wait like 2 mins, then a message pops up saying disconnected.. if you know how to solve this prob, plz ad me to your email mail. yahoo id – [email protected] or [email protected] –>PREFER YAHOO ID

    [Reply]

  21. Hi!

    I would like to create an ad hoc connection/network, between Windows Vista and Ubuntu 9.04. My Vista PC has the wired dsl connection.

    Thx for any help!

    [Reply]

Leave a comment

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