31

I have been trying to share my wired Internet connection with my Android phone. However I could not succeed in doing this. Has anyone of you ever succeeded? Operating systems that I use are as follows:

  • Ubuntu 10.10
  • Android 2.3
5
  • 1
    I have been trying to find a solution for some time to this, and have tried a number of things, without success. I think the best option would be to create a wireless network on Ubuntu that is NOT an Adhoc wifi network (because Android does not detect such connections). There are instructions on how to do this out there, but I find them either too complicated, or they just don't work. So a step-by-step walk-through on how to do this would be welcome.
    – geoffrey
    Oct 23, 2011 at 2:14
  • It is likely that you'll have to specify the network name on your Android device. Oct 25, 2011 at 16:59
  • Still no satisfactory answer after the bounty period, so I suppose the answer to this question is: it's really difficult! I have awarded the bounty to the most 'voted up' answer, a helpful answer even if not the solution I was looking for.
    – geoffrey
    Oct 30, 2011 at 1:22
  • @Jo-ErlendSchinstad Thanks, I tried this but it does not help.
    – geoffrey
    Oct 30, 2011 at 1:23

8 Answers 8

13
+200

Yes, it is possible. I have Ubuntu 11.04, NetworkManager 0.8.4, Android Nexus One phone running Cyanogenmod 7.

As described by Roman, right-click on the NetworkManager icon and choose "Create new wireless network". I chose to leave the connection wide open (no WPA, no WEP). My phone was able to see the network right away and I connected without trouble. The bridging was automatically done so I could browse the internet without configuring anything extra.

The reason why you having trouble with the above method is because stock Android 2.3 doesn't support ad-hoc networks. To be precise, Android's wpa_supplicant does not show ad-hoc networks. There are a number of ways to fix this. Google around and go hunting in the xda-developers forums. You will probably need to do some hacking on your phone that is beyond the scope of this answer.

My personal recommendation: if your phone supports Cyanogenmod, you can install it to get ad-hoc support and other hackish delights. You will need to root your phone, which may or may not be to your taste.

Another alternative is to try "Infrastructure mode". After setting up the ad-hoc wireless network as per above, click on the NetworkManager icon, choose "Edit connections". Hit the wireless tab and Edit the ad-hoc network you just created. Under Mode, choose "Infrastructure". I am unsure if this will work for you since I don't have a stock Android phone to test with. My thought is if ad-hoc mode is the problem, then the another mode might be the solution.

Good luck!

1
  • Thanks! Well, I understand that rooting a Wildfire S is not that simple, so that won't work for me. The 'infrastructure mode' sounds interesting, but so far I was not able to get it to work - it just won't connect. I'll try googling around for solutions to that problem ...
    – geoffrey
    Oct 26, 2011 at 1:27
3

First of all as we all know stock ROM of Android i.e. the one which comes with the phone does not support ad-hoc mode (surprisingly), and even Ice-Cream Sandwich (Android 4.0) won't support ad-hoc mode.

So, we need to create an access point using Ubuntu to which any android phone can easily connect. In Windows you can use Connectify to do that and it works perfectly well but with Ubuntu you may have certain problems, depending on whether your wifi-card supports access point mode (master mode) or not.

Now, even if your wifi-card supports access point mode, the next problem is whether the driver of your wifi-card supports AP mode or not, if it does then the problem is solved and if does not then you have three options:

  1. Wait till the driver receives an update for AP mode. (many wifi-card drivers are still in staging stage)

  2. Buy a wifi-dongle and make sure it supports AP mode on ubuntu.

  3. Use Windows, where Connectify will do the job for you.

If you are interested you can post the name of your wifi-card driver so that I can help you further. Use this command:

lshw -c network
1
3

A working solution for me with USB Cable on Kubuntu 15.10 & Android 4.2.2 on a Samsung S3 mini was following

Requirements

Android

  1. busybox app installed
  2. USB cable to your computer
  3. USB Debugging enabled on your android device (to be able to adb from your pc)

Computer

  1. In your /etc/network/interfaces you need to have these two lines otherwise you'll get a no such device error

    allow-hotplug usb0
    auto usb0
    
  2. adb installed (apt-get install android-tools-adb)

Connection

  1. In your android, enable the Settings->Connections->Network connections->Tethering and portable hotspot->USB tethering option, this will create an USB connection to your computer which you can see with ifconfig command on your computer. Look @ the interface name which for me is enxf6759e7fbebd this time.

    enxf6759e7fbebd Link encap:Ethernet  HWaddr a2:61:3c:83:1c:38  
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:6 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:464 (464.0 B)  TX bytes:0 (0.0 B)
    
    eth0      Link encap:Ethernet  HWaddr 50:e5:49:47:f4:fd  
        inet addr:192.168.178.20  Bcast:192.168.178.255  Mask:255.255.255.0
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:40894966 errors:0 dropped:0 overruns:0 frame:0
        TX packets:86312833 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:20969506400 (20.9 GB)  TX bytes:120329513606 (120.3 GB)
    
    lo        Link encap:Local Loopback  
        inet addr:127.0.0.1  Mask:255.0.0.0
        UP LOOPBACK RUNNING  MTU:65536  Metric:1
        RX packets:30521 errors:0 dropped:0 overruns:0 frame:0
        TX packets:30521 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0 
        RX bytes:10868749 (10.8 MB)  TX bytes:10868749 (10.8 MB)
    
  2. Assign an IP address to your computer on this network interface with following command sudo ifconfig enxf6759e7fbebd 192.168.42.135 netmask 255.255.255.0 where enxf6759e7fbebd is the interface you got on previous step.

  3. Enable IP forwaring with

    sudo -- sh -c  'echo 1 > /proc/sys/net/ipv4/ip_forward'
    
  4. Enable nat on your computer with

    sudo iptables -t nat -F
    sudo iptables -t nat -A POSTROUTING -j MASQUERADE
    
  5. On your computer connect to your android device with

    adb shell
    su
    
  6. then already having your connection you can check with busybox ifconfig -a command

    rndis0    Link encap:Ethernet  HWaddr FA:08:D6:1A:35:90  
        inet addr:192.168.42.129  Bcast:192.168.42.255  Mask:255.255.255.0
        inet6 addr: fe80::f808:d6ff:fe1a:3590/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:0 (0.0 B)  TX bytes:564 (564.0 B)
    

you can add default route to your computers network address you fixed in point 2 with busybox route add default gw 192.168.42.135 dev rndis0 and that's it (you can check your routes with busybox route command)

2

Please check out this link and tell me if it's roughly what you're looking for.
https://help.ubuntu.com/community/WifiDocs/WirelessAccessPoint

If it looks like it is (or is close to) what you're looking for let me know.
I'm interested in doing this myself, only with the slight modification of directing traffic through ppp0. Which is a tethered connection.
Perhaps we can tweak these instructions to do what we need.

Edit: This looks as if it would work best on a dedicated machine (essentially making it a router). I'm still looking through the configurations, but this might cause some problems for a laptop that you would use the wireless to connect to various locations.
Also, there appear to be a couple of steps involving a Windows machine we maybe able to forgo.

You'll also want to see this. https://help.ubuntu.com/community/WifiDocs/MasterMode

5
  • Also, I tried setting up the wireless through Network Manager (as suggested by RocketScientist) without any real success. That doesn't mean it can't work just that it didn't for me. There maybe another variable I didn't have that he does. bridge-utils for example. Oct 27, 2011 at 19:27
  • thanks, that sounds interesting (though rather complicated). Unfortunately I don't have time to look into it before Sunday, but please report any success with this.
    – geoffrey
    Oct 27, 2011 at 23:20
  • I'm hoping I'll get a chance to play with it. Any chance you can extend the bounty to Monday morning so I can work it this weekend? Oct 28, 2011 at 1:14
  • sorry, but I don't think I have the power to extend the bounty ...
    – geoffrey
    Oct 28, 2011 at 23:28
  • ... but there is a 'grace' period of 24 hours after the end of the bounty, so that gives you another day
    – geoffrey
    Oct 28, 2011 at 23:47
2

I found a working solution to share my Internet connection with my phone via USB reverse tethering, but my laptop uses a wireless connection for it:

Internet -> Wireless -> Laptop -> USB cable -> Android phone

So if that would be possible for you, or if you have a second ethernet card for your pc, you should check out the 'Reverse Tether Trial' app from the play store.

  1. Connect your pc with the Internet as usual
  2. Connect your Android phone via USB to your pc
  3. Activate 'USB-Tethering' in Androids 'Settings'
  4. Create a new wired connection in Ubuntus network manager as described here
  5. Start Reverse Tether and follow it's instructions
  6. Browse on your phone :)
1

Assuming you also have a wireless card in your computer: In Network Manager, click the menu and 'Create New Wireless Network...'. Later, you would be to see the network in your Android.

1

You can create a wireless network from your computers wifi menu. Right click on the wifi icon in the taskbar and click create new network. Fill out the options then connect to it from your phone. Make sure your computer is also connected to the wired network cable. The cable should be automatically bridged to the wireless from my understanding, and it should all work fine.

3
  • Thanks for the reply. After I created a new wireless network, i cannot see this network on my phone. What did I do wrong?
    – Erdem
    Oct 16, 2011 at 20:25
  • Thats very strange. Are you sure your computer has a wifi card?
    – Roman
    Oct 17, 2011 at 22:02
  • 2
    Android does not detect the 'adhoc' type of wireless network created by network-manager, so this will not work.
    – geoffrey
    Oct 19, 2011 at 7:16
0

This works for me

  • Ubuntu 12.04
  • Android 4.0.4

Install hostapd

sudo apt-get 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

After installing hostapd install dhcp server

sudo apt-get install dhcp3-server hostapd

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

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

Please change to fill in the name of your network after ssid=, as well as the password after wpa_passphrase=.

save the file as hostapd.conf in your home folder

Create a new ad-hoc wireless and connect it.

Now, Open terminal and type:

sudo hostapd hostapd.conf

Turn on your phone wifi and find your ssid.

Source from HERE

1
  • This gets me way closer but the phone is stuck trying to get an ip address.
    – DavidGamba
    Nov 28, 2013 at 17:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .