How to share a wired Internet connection with an Android phone (reverse-tethering)?
Solution 1
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!
Solution 2
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:
Wait till the driver receives an update for AP mode. (many wifi-card drivers are still in staging stage)
Buy a wifi-dongle and make sure it supports AP mode on ubuntu.
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
Solution 3
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
Solution 4
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
- busybox app installed
- USB cable to your computer
- USB Debugging enabled on your android device (to be able to adb from your pc)
Computer
-
In your /etc/network/interfaces you need to have these two lines otherwise you'll get a
no such device
errorallow-hotplug usb0 auto usb0
adb installed (
apt-get install android-tools-adb
)
Connection
-
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 isenxf6759e7fbebd
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)
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.-
Enable IP forwaring with
sudo -- sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
-
Enable nat on your computer with
sudo iptables -t nat -F sudo iptables -t nat -A POSTROUTING -j MASQUERADE
-
On your computer connect to your android device with
adb shell su
-
then already having your connection you can check with
busybox ifconfig -a
commandrndis0 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)
Solution 5
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.
- Connect your pc with the Internet as usual
- Connect your Android phone via USB to your pc
- Activate 'USB-Tethering' in Androids 'Settings'
- Create a new wired connection in Ubuntus network manager as described here
- Start Reverse Tether and follow it's instructions
- Browse on your phone :)
Erdem
Updated on September 18, 2022Comments
-
Erdem almost 2 years
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
-
geoffrey over 12 yearsI 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 over 12 yearsStill 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 over 12 years@Jo-ErlendSchinstad Thanks, I tried this but it does not help.
-
Eric Carvalho almost 9 yearspossible duplicate of How to Connect & Share your Internet Connection (Wired & Wireless)
-
Erdem over 12 yearsThanks for the reply. After I created a new wireless network, i cannot see this network on my phone. What did I do wrong?
-
Emil over 12 yearsThats very strange. Are you sure your computer has a wifi card?
-
geoffrey over 12 yearsAndroid does not detect the 'adhoc' type of wireless network created by network-manager, so this will not work.
-
Argusvision over 12 yearsAlso, 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.
-
geoffrey over 12 yearsthanks, 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.
-
Argusvision over 12 yearsI'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?
-
geoffrey over 12 yearssorry, but I don't think I have the power to extend the bounty ...
-
geoffrey over 12 years... but there is a 'grace' period of 24 hours after the end of the bounty, so that gives you another day
-
adnan kamili about 12 yearsA working solution, follow this link: superuser.com/questions/407371/…
-
DavidGamba over 10 yearsThis gets me way closer but the phone is stuck trying to get an ip address.