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


  • 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


  • 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.,, and respectively.
  • Leave DNS Servers and Search Domains blank


  • 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%).


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).


Internet Protocol (TCP/IP) Properties:

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


  • 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

Related posts

You may also like...

61 Responses

  1. Raj says:

    Nice info, thanks!

  2. Martin says:

    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?

  3. ubuntu4us says:

    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:,, respectively.

  4. Mattes says:

    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.


  5. ubuntu4us says:


    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


  6. Mattes says:


    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 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
    ^- DNS IP

    In pseudo code something like # route add netmask … gw

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


  7. Mattes says:

    Sorry the formating got messed-up!

    Internet DSL-Router UbuntuAdhoc AP AP Client is my DNS

  8. manishmahabir says:

    in fedora the network manager can connect to a newly created wireless network and the wired network simultaneously, by this we can easily share our wired connection wirelessly over the new wireless network.
    why is it not possible in ubuntu?

    the video of fedora is here….

  9. Robert Young says:

    How would one use this to connect to say, an iPod Touch? Or rather, how would you set up the connection from the iPod’s side?

  10. Ryan Peter says:

    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?

  11. jcai says:

    very nice. linux powerful!

  12. Jonathan says:

    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.

  13. guest says:

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

  14. ubuntu4us says:

    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:

    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.

  15. Ishmael says:

    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 : )

  16. Pramod says:

    Good one, one can also do it using DHCP.

  17. max says:

    🙂 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?

  18. Jakes says:

    Nice post..Itx kind of same sort of procedure in Windows too

  19. mohamedmig says:

    how to shared internet by wireless on linux mint

  20. jordanwb says:

    Not sure if I’ll ever use this but good to know nevertheless.

  21. Hari says:

    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

  22. Bernd says:


    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 ?


  23. Cabalbl4 says:

    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, and the ubuntu is set to use It seems that ICS is having some trouble with other (NON 192.168.0.X and mask addresses.

  24. subaru says:

    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 -o eth0 -j MASQUERADE
    #iptables -A FORWARD -s -o eth0 -j ACCEPT
    #iptables -A FORWARD -d -m state –state ESTABLISHED,RELATED -i eth0 -j ACCEPT

  25. Cabalbl4 says:

    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.

  26. prabhat says:

    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, and the Windows machine Shouldn’t they both have the same value for the first field?


  27. ubuntu4us says:


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


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


  28. HopelessStuff says:

    One small thing doesn’t work with this. Can’t ping the machines…

  29. James says:

    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

  30. kisqp says:


    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!

Leave a Reply

Your email address will not be published.