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
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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.
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
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.
Please check out this link and tell me if it's roughly what you're looking for.
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
A working solution for me with USB Cable on Kubuntu 15.10 & Android 4.2.2 on a Samsung S3 mini was following
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
adb installed (
apt-get install android-tools-adb)
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)
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 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)
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.
This works for me
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
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