Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Ubuntu 12.04 on a HP 430 notebook and this has a single wired internet connection and I would like to share this with a LG Optimus One with Android 2.3.3. I followed these instructions and created a hotspot as shown below, but UbuntuHost is not visible on the LG Optimus One when I enable the Wifi on it.

To summarize, I want my Laptop with an internet connection to act as a WiFi router and access the internet from other devices (LG Optimus One with Android in this case).

What additional steps have to be done?

enter image description here

share|improve this question
    
See the second answer for this question for a bug and workaround: askubuntu.com/questions/105545/make-my-laptop-a-wifi-router –  user68186 Aug 7 '12 at 15:05
    
That seems to be a different problem. I am not able to see the SSID in the Android Phone. –  Praveen Sripati Aug 8 '12 at 5:27
1  
Andriod 2.3 doesn't support wifi ad-hoc.If your wifi card supports master mode then you can try to set up as hotspot(infrastucture mode) using hostapd.Follow instruction here on svsarana blog. Replace ppp0 with eth0 from the instruction. –  Khurshid Alam Aug 9 '12 at 17:47
    
Actually, depending on the cellphone it does or does not support wifi ad-hoc. I have a Huawei cellphone with 2.3 and it sees ad-hoc devices. –  Luis Alvarado Aug 9 '12 at 23:00

4 Answers 4

up vote 25 down vote accepted
+100

Since this is like the #1 question I get from students and newcomers to Ubuntu I will try to answer it with a couple of things everyone should know about Ubuntu in regards to sharing an internet connection. This is divided in 3 sections:

  1. Sharing your Internet Connection via a Wired Connection
  2. Sharing your Internet connection via a Wireless Connection
  3. Sharing your Wireless Connection with Mobile Devices
  4. Connecting to a Wired or Wireless Device

Know that, in order to share your Internet connection either Wired or Wireless, you NEED to have at least 2 network cards, they can be a mix between a Wired card and a Wireless card, 2 Wired cards or 2 Wireless cards. The point is, you need to have at least 2 network cards, one card that receives your internet connection and another that sends it to other computers or devices on your network.

Sharing your Internet Connection via a Wired Connection

Configuring the PC that will share the connection

  1. Assuming you are receiving Internet through a second Wired connection or a Wireless connection, Open your Network Manager via the Network Icon on the Unity Panel:

    enter image description here

  2. Go all the way down to the Edit Connections option and click on it.

    enter image description here

  3. You will appear on the Wired Tab. Each Wired connection is by default related to each Ethernet Wired NIC card you have. For example if you have 2 Wired NICs you will see 2 options here. In the image below you see one since this is a Laptop and they normally have one. Select the Wired connection you wish to edit which should be the one connected to your LAN and not the one that is receiving the Internet connection. Double click on it or select the EDIT button.

    enter image description here

  4. You will appear on the Wired Tab (Again). This time, go to the IPv4 Settings if you are using IPv4 or IPv6 if you are using that one. On the Method option select Share to Other Computers. Now SAVE. You are done.

enter image description here

This will do all the stuff that was normally done 6 or 7 years ago with all the terminal commands and iptable stuff.

Now just connect the 2 computers and you are done.

NOTE: If both computers have a Wired Gigabit Ethernet NIC then you can actually connect them directly since most 1000BASE-T have automatic MDI/MDI-X. If not just connect them to your switch, router, hub, whatever and that is all.

PC That will receive Shared Internet Connection (Depends on Network Setup)

  1. Open your Network Manager via the Network Icon on the Unity Panel:

    enter image description here

  2. Go all the way down to the Edit Connections option and click on it.

    enter image description here

  3. You will appear on the Wired Tab. Each Wired connection is by default related to each Ethernet Wired NIC card you have. For example if you have 2 Wired NICs you will see 2 options here. In the image below you see one since this is a Laptop and they normally have one. Select the Wired connection you wish to edit and double click on it or select the EDIT button.

    enter image description here

  4. You will appear on the Wired Tab (Again). This time, go to the IPv4 Settings if you are using IPv4 or IPv6 if you are using that one. On the Method option select Manual. The options in Addresses will be editable now. Add the IP you want, the Mask you need and the IP of the PC that is sharing the connection. In this case I said that the IP of the Client PC will be 192.168.0.2, the Mask is 255.255.255.0 to imply that is a Class C (LAN) network and 192.168.0.1 to mention that the computer sharing the connection has the IP 192.168.0.1 with it. Additionally add the same IP of the computer sharing the connection to the DNS Servers (As shown in the image).

    enter image description here

You can also (Depending on the network setup) select instead of Manual, select Automatic and just put the IP of the computer sharing the Internet in the DNS Servers section.

enter image description here

Note that this depends on the network setup. For example if you have both PCs connected to a switch or router, the switch/router will take care of the Client, so you only need to setup the PC Sharing Internet and just connect both to the switch/router. If by chance you are connecting the PCs directly together then it is better to do the additional setup of the Client.

In most cases, you will not need to setup the client, just connect to the network and done. Ubuntu will take care of everything. I just added the Client part for specific cases where problems might arise.

This should cover all the possible scenarios in a home LAN when one wants to share the internet connection over Wired cable.

Sharing your Internet connection via a Wireless Connection

NOTE: Read below for Android user information.

Since a couple of Ubuntu versions ago, there is no need for using masquerading techniques through terminal commands to share the internet connection. There isn't even the need to use iwconfig and echo commands to forward stuff. For the many computers and laptops I have tested (Almost 1000 with Ubuntu) I can frankly say for sure that with the following steps you can share your internet connection with no trouble at all.

This is the same for open sourced and proprietary drivers. I can confirm for example Broadcom, Ralink and Atheros chipsets wireless cards will work out of the box, they will work since NetworkManager will take care of the low level details. The latest versions of Network Manager, specially since 0.9.x are excellent in this aspect.

Step 1 - Go to Network Manager and select Create New Wireless Network..
Note that there are other ways, terminal and GUI like, that can also do the job, but this is the easiest and fastest way possible (Even faster and easier than doing it in Windows XP or Windows 7). Also know that I am assuming you are receiving Internet through another network card (Wired or Wireless) and you want to share this Internet connection wirelessly.

enter image description here

Step 2 - Type name of SSID (The name that other devices will see when looking for the hotspot)

enter image description here

Step 3 - As you can see here I put as the SSID name "Ubuntu Ad Hoc Power" and it has an encryption of WEP. The encryption type depends on the network card. Some cards do no support Ad-hoc with WEP, others with WPA, and others with any security whatsoever. After setting the SSID name and security just click create.

enter image description here

Step 4 - For cases where you will share internet with somebody close to you on the same room, I normally just share the device with no security. Easier for them to connect. Of course do not do this in a party or in an office full of wireless vampires.

enter image description here

Step 5 - When a shared connection is created, the next time you try to share it, it will appear in a connection list, saving you the trouble of naming the connection and setting security.

enter image description here

After doing the above steps, you should have a computer sharing the internet connection with no problems at all. Now for the part that so many of us forget (specially me)

Sharing your Wireless Connection with Mobile Devices

Many users always ask why doesn't my phone (Android, IPhone, Blackberry) see the internet connection shared from my laptop?

In many of this cases, Android, IPhone or Blackberry will have disabled the option to "find" Ad-Hoc hotspots. This is for security measures. So they will only see actual Wireless routers and not Ad-hoc enabled devices like a Wireless PCI card, Wireless USB card or even another Ad-Hoc enabled phone. To be able to do this, at least in Android you need to root the device. For IPhone you need to jailbreak them. For Blackberries is more complicated. I have only done this on Androids and Iphones. After doing this you should see the Ad-Hoc device with no problem at all.

Of course this does not affect all models. Only some of them. Some you will only just buy and they will see Ad-hoc spots from day one. Others you will have to root/jail to fix this annoying problem.

I don't know if I can recommend some sites or ways to accomplish this here but google is your friend. Anyway a quick way to see this is to try to connect another computer to the one sharing the internet. It should work. Another way is to look for another cellphone that can see ad-hoc.

ANDROID USERS

For Android users our sister site Android has a nice article on How to ROOT an android device

I also recommend this article which talks about several terms we should know when working with stuff like this: Phone Hacking Terminology

Lastly, sites like cyanogenmod and tools like clockworkmod are very good. But always remember that with great root cow power comes great responsibility.

For example I have a Huawei cellphone that had Android 2.2 originally. After I rooted the device and upgraded to 2.3 using Cyanogenmod I could see ad-hoc devices which saved me from several problems and added a bonus to my cellphone for stuff like using it as a remote control for XBMC.

I should also mention that I have read several of the answers in the Android SE site about Ad-Hoc support. Most are wrong in the sense that they confirm Ad-hoc not working on several older versions of Android (Version 4 and below). This is false since I have done probably more than 50 Android phones ranging from Samsung to Huawei and they all have worked. There might be some that do not get Ad-Hoc even after enabling Root and installing the needed apps but I have not yet come across one that had this issue.

So do not be discourage about looking to get your Ad-Hoc working on your phone. Trust me, it is easy. I hope I have shed some light with this to help you share quicker and easier and to understand when in some cases they do not find ad-hoc devices.

Connecting to a Wired or Wireless Device

Take a look at the image below:

enter image description here

If you click on the Network icon (The green circle at the top) it will drop a menu where you can see all the devices (Wired Connections and Wireless Connections) that you can use to connect. By clicking on them, they will automatically connect to the desire network. In the case of having a Wireless card and have not yet installed the drivers (In the case you need drivers for them), you can visit one of the following links that provide the steps needed to correctly install any Wireless card:

How do I get a Ralink RT3290 wireless card working?

How to install Broadcom wireless drivers? (BCM43xx)

Drivers for Realtek wireless module for Toshiba C850-A965?

Wireless card Realtek RTL8723AE-BT is not recognized

http://askubuntu.com/questions/tagged/wireless+drivers

As a bonus I recommend reading the How to connect and disconnect to a network manually in terminal? (In cases where the need arises).

share|improve this answer
    
The Ubuntu connection is not visible in Android. I was confused between Wireless Access Points with Wireless Ad Hoc networks. I think I need to root the Android for Wireless Ad Hoc networks. Thanks for the response. –  Praveen Sripati Aug 11 '12 at 2:16
    
No problem friend. Normally it would work but since there is a phone involved, in some types of phones, the Ad-hoc feature is disabled. I think is a dumb decision but that is why the root option is there. Try it out and let me know if it solves your problem. –  Luis Alvarado Aug 11 '12 at 3:33
2  
Awesome answer Luis, especially on the creating an ad-hoc network part! –  izx Aug 11 '12 at 16:14
    
Thanks friend. If you have any more info to add with your knowledge it would be awesome, that way it helps users know more on how to create ad-hoc points. –  Luis Alvarado Aug 11 '12 at 19:35
    
I knew I would see your name at the end of this awesome answer! Great work :D –  Seth Oct 1 '13 at 17:07

Assuming you followed the instructions fully, you need to "connect" to the wifi network just set up.

  1. Click on the network icon
  2. Select "Connect to hidden wireless network"
  3. Select "UbuntuHost"
  4. Connect
share|improve this answer

How to connect to Ad-hoc network Android 2.2 and 2.3 and more?

For this to work you need to have a rooted device and you need write access to the file:

/system/etc/wifi/wpa_supplicant.conf

This is how it should look

ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=wifi
update_config=1
ap_scan=2

network={ # An open network
ssid="Ad-hoc ssid here"
scan_ssid=1
key_mgmt=NONE
mode=1
priority=1
}

network={ # An encrypted network
ssid="Your Accesspoint ssid here"
psk="your wpa key here"
key_mgmt=WPA-PSK
priority=2
}

Author Zoppatorslk

share|improve this answer

I have this same problem with my computer. The cause for me is that my wifi card doesn't support adhoc mode. You can find out more about your problem by setting up the adhoc network using the commandline. Here are instructions:

https://help.ubuntu.com/community/WifiDocs/Adhoc

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.