[GUIDE] Connect Android to Linux PC internet via USB - Networking

I've been playing 4 hours with my brand new Archos Titanium 40
and I was specifically trying to connect it to the internet
via the USB cable.
Here's what I have :
Archos Titanium 40, almost unmodified Android Jelly Bean 4.2.2, not rooted.
A fairly up do date "testing" Debian on my PC.
The Archos USB cable (standard stuff mind you) connecting my phone to the PC.
The first thing to note is that Jelly Bean 4.2.2 does provide
reverse tethering natively.
For that, just plug your USB cable in your PC and in your phone.
The phone then proposes to expose itself as a regular USB storage.
Don't accept that. Go to the settings page instead, look at the
"wireless & network" stuff, then "More...". There you'll find "USB Internet". Activate
that. Android will then take you by the hand. The first thing it'll
ask is the OS you want to connect to. You have a choice between
various Windows versions... But we're on Linux. So choose Windows 8
and just act as if everything was fine (clik "next" and then "finished"). After that
your USB connection is there. The setting string reports you're connected.
On the PC Linux now. There's a new network interface : usb0.
To see it use ifconfig (you must be root to do that).
The problem is that that interface has no IP address. Since we choose to work
as with windows 8, Android phone gave itself the 192.168.137.1 default
address (you can see that by opening a shell on your phone and
typing netcfg; the you look at the rndis0 interface...)
So, you know have to set that address properly, and then activate the IP
NAT stuff. This is done as root with :
ifconfig usb0 192.168.137.1
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT
(on my PC eth0 is the ethernet card wich is connected
to my router which is, in turn, connected to the internet)
And voilà. nothing to install, nothing to root. Everything works :
slashdot, youtube, etc. Super clean. No rooting needed, no additional software.
Somehow I didn't find that anywhere on the web... So I hope it helps...
stF

Related

Any way to share desktop internet with droid by USB?

Hey there.
I´ve searched the forums but i didnt found for a way to share a desktop internet connection with the phone by USB.
There are many ways to tether (share phone connection with the desktop/laptop, wired or wireless), but are there any way to share internet the opposite way?
Thanks!
Dont think so.
As far as I know, there is only one option to connect to internet through PC. You can connect by WiFi, but only with Windows 7, because Desire can't connect to ad-hoc network.
If you are interested in this subject, go to connectify.me
Thanks for your help!
YES if you have windows 7 and wifi.
Sorry to bump this but was a big deal for me also and I found a solution.
I use a peice of software called connectify (google it) which uses some new part of windows 7 networking to allow you to turn your computer into a wifi router.
It even works when connected via wifi which obviously it pointless if you have wifi already. We dont at work so I use it then and have about 6 others connected from thier desires with no effect on me.
HI
I have found the solution to share PC's internet on mobile via USB. I am using ubuntu 10.04 and HTC dream with superfroyo2.2. I just did the following:
First of all, connect the PC to Phone via usb. and enable tethering on phone. (Don't panic. I am going to tell you how to do the reverse of it.)
Your PC will get the IP 192.168.42.37 and mobile will have the IP 192.168.42.129.
Settings on PC
sysctl net.ipv4.ip_forward=1
Above command will enable routing on the PC.
Now go to your phone via adb shell
and give following commands;
#setprop net.dns1 8.8.8.8
also need to set default gw using
# busybox route add default gw 192.168.42.37
by above commands on mobile you have set the dafault gateway to be PC's IP and also set the DNS.
and BINGO..your internet should work on mobile now.
If you still get some problem, then troubleshoot it step by step. First ping your PC from mobile and mobile from PC, both should ping each other and make sure, your PC is connected to internet and there is no firewall or antivirus on the PC that may block incomming traffic from mobile.
As a further test you can give following command to enable NAT on your PC:
// iptables -t nat -A POSTROUTING -s 192.168.42.0/24 -j MASQUERADE
I did not use this command and natting was done without this command on my PC, my be due to some error or other configurations that I don't know but its good for me that its working without it
HD roms had that IIRC
Sent from my HDfied HTC Desire
i dont think its possible right now :/

[Guide] Reverse USB Tethering step by step

hello everyone!
I was trying to find a way to connect my iconia via usb with my laptop and use my internet access for instances that wifi isn't available.
I searched a lot but there wasn't any usefull clear guide. So after some failing attempts, finally i managed to succeed (using win 7). Here are the steps:
*root is required*
1. install http://code.google.com/p/android-wired-tether/ (i used stable version 1.2 but i don't think 1.4 will make any problems) but do not enable it yet.
2. Install USB drivers from Android SDK instructions found here: http://developer.android.com/sdk/win-usb.html , later you will also need RNDIS drivers because when you connect the tablet with your pc and enable wired tether it will install the drivers. I found working drivers from HTC sync located at C:\Program Files (x86)\HTC\HTC Driver\Driver Files\Win7_x64\htcrndis.inf
you have to install them manually from the device manager (pick the: HTC Remote NDIS based device)
3. now that we have completed the installation with Wired Tether (still leave it running), we are ready to proceed to the next step. Open network connections. You will notice that now there is one more. (in my case no1 is local area and no2 local area 5 (the one wired tether created). select the connection you want to share go to properties and enter "sharing tab". tick "Allow other network users to connect through this computer's Internet connection" and pick the connection made by wired tether. Hit apply and you will have bridged the two connections.
4. open any emulator on your tablet and type:
Code:
su
ifconfig usb0 192.168.1.9 netmask 255.255.255.0 up
route add default gw 192.168.1.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.gprs.http-proxy" ""
netcfg usb0 dhcp
at ifconfig command you enter an available ip of your router for example if your pc is connected to 192.168.1.7 you can pick 192.168.1.9 that is free.
at the second line enter the default gateway of your internet connection found under the detailed view of its options.
setprop "net.gprs.http-proxy" "" is in case you are NOT behind a proxy server
5. wait about 15 seconds and...
enjoy!
each time you enable wired tether you have to type in:
su
netcfg usb0 dhcp
to undo the hole "reverse usb" thing, simply unbridge the 2 connections, restart wired tether and you are ready to use it for normal tethering.
browsers work fine, facebook, pulse, tunein. i haven't tested many apps yet...
issues: Market browsing is ok but downloading apps not, some apps do not work.
p.s: it's my first guide so if something seems confusing or unclear, please forgive me!
interesting... question... why do you do " setprop "net.gprs.http-proxy" """?
i'm asking because maybe this is what i'm missing in my usb 3g for my wifi only
thor2002ro said:
interesting... question... why do you do " setprop "net.gprs.http-proxy" """?
i'm asking because maybe this is what i'm missing in my usb 3g for my wifi only
Click to expand...
Click to collapse
forgot to implement the source link...
comments to focus are:
Rugga said...
I'm using Windows 7. I shared my ethernet internet connection to the USB tether device.
In console emulator on the phone I typed:
ifconfig usb1 192.168.2.2 netmask 255.255.255.0 up
route add default gw 192.168.2.1 dev usb1
I can ping the gateway, I can also ping the web by IP address, eg 64.233.181.104 for google.com
What I can't do is use the browser or ping by domain name. I tried:
setprop net.usb1.dns1 192.168.2.1; and
setprop net.dns1 192.168.2.1
Click to expand...
Click to collapse
OK it is working now. After setting up ICS type in console emulator on your phone:
ifconfig usb0 192.168.2.2 netmask 255.255.255.0 up
route add default gw 192.168.2.1 dev usb0
iptables -F
iptables -F -t nat
setprop net.dns1 8.8.8.8
setprop "net.gprs.http-proxy" ""
Click to expand...
Click to collapse
it gave me a headache trying to understand what exactly does this line...
the only thing i managed to figure out is tha it redirects and leaves blank proxy server via gprs connection... is it a fake connection (gprs) that blocks data transfer via usb from apps? the only sure thing is that these 2 lines with setprop command fixed the issue with the apps (browser and others)...
first is google's dns, probably necessary as well...
btw great job with the modules!
A quick question
Is this Iconia-specific or can the same method be used on any Android device provided we have working RNDIS drivers for it?
The way it appears to me, I don't see why it shouldn't work on other devices but please correct me if I am wrong.
HQRaja said:
Is this Iconia-specific or can the same method be used on any Android device provided we have working RNDIS drivers for it?
The way it appears to me, I don't see why it shouldn't work on other devices but please correct me if I am wrong.
Click to expand...
Click to collapse
in devices which already have the tethering ability, the hole wired tether thing doesn't need installation, so it is easier and i think it will work on any android based devices. so give it a try!
probably you won't even need to install RNDIS drivers, but in any case the HTC ones work like a charm (some other that i tried crashed windows upon connection).
you don't have to get specific RNDIS drivers especially for your device cause they are used for connecting usb devices used as network ones.
so... give it a try!
Exactly what i need desperately, i have a wifi signal which is very poor, i use external antenna to boost wifi signal. This external antenna has no drivers for android for sure, therefore i need to do reverse tethering to share internet connection from my computer.
I tried to use your guide but i think it needs a bit more details. I installed android tethering 1.4 but i am stuck at step 2 cause at this step when i turn on debugging mode on iconia then PC searches for drivers but doesn't accept the ones i downloaded from android SDK.
Kindly help me with this, i will be grateful for that.
Thanks.
usman3206 said:
Exactly what i need desperately, i have a wifi signal which is very poor, i use external antenna to boost wifi signal. This external antenna has no drivers for android for sure, therefore i need to do reverse tethering to share internet connection from my computer.
I tried to use your guide but i think it needs a bit more details. I installed android tethering 1.4 but i am stuck at step 2 cause at this step when i turn on debugging mode on iconia then PC searches for drivers but doesn't accept the ones i downloaded from android SDK.
Kindly help me with this, i will be grateful for that.
Thanks.
Click to expand...
Click to collapse
Hi! Sorry for my late answer to that. I've been away for a while...
try the drivers that are located at http://acer.us/ac/en/US/content/drivers
pick tablet, iconia tab, a500 and then download the usb drivers.
Any chance to enable this with an android phone? Wired tethering from the phone I mean.
There's actually a free program @ http://www.connectify.me
Its for Windows and they are developing an android app as well. But the windows software is quite easy and makes your computer or laptop a "hotspot" to connect multiple devices too.
enjoy!
Bec07 said:
Any chance to enable this with an android phone? Wired tethering from the phone I mean.
Click to expand...
Click to collapse
i'll give it a try (i assume you mean via usb connection).
connectify is for wireless networking. the hole reverse usb tethering thing is based on usb connection without any participation of a wireless network at all.
the majority of the latest android phones can become a hotspot natively anyway.
He does not want to install the driver from HTC. There are other options?

PC hosting internet to Android device through USB?

How can I get a desktop with out wifi to share it's network connection with a android device via USB?
This way I can update my phones apps, email etc while I am at work (No WIFI connection).
The "adb shell netcfg usb0 dhcp" dosen't do anything the terminal or command prompt just freezes.
References:
How to get internet on your phone via USB - http://forum.xda-developers.com/showthread.php?t=793102
Reverse USB Tethering with Android 2.2 - http://blog.mycila.com/2010/06/reverse-usb-tethering-with-android-22.html
My best guest so far is that I can't do this.
Sent from my COS-DS using Tapatalk
Try this
http://forum.xda-developers.com/showpost.php?p=11042514&postcount=14
I used it before on CM6 I think so it shouldn't matter what ROM you are using.
I haven't tried it in a while but it should still work.

[GUIDE] USB Reverse Tethering - New method - All PC operating systems

Introduction
This guide is intended to help you share Internet connection from your PC to your Android smartphone/tablet via USB cable. This technique is called USB reverse tethering. It is different from USB tethering in which you share Internet from your Android to your PC. There are many reasons why you need this technique working:
- You don't have mobile/wifi network and your PC doesn't have any wifi adapter
- You can't do tethering over wifi, for example, your company doesn't let you make any hotspot at work
- You don't want to spend money for a mobile plan, and you want a more stable and faster Internet connection than wifi
- You don't want your PC and your Android to become too hot because of wifi
- You want your Android charged while in use
...
You have searched and found some applications/tools/solutions, you followed exactly their instructions but finally you were frustrated because they didn't work, here I come for a new method.
This method works following Internet connection sharing basics. If your Android device is able to do USB tethering, you will be able to do USB reserve tethering with this method!
Advantages:
- No additional software on your PC. Leave no trace on your PC. Imagine when you are at work and you have to install some crappy "toy" application on your PC to estiblish a tunnel connection for this task.
- Works with Windows, Linux and Mac OS X
- You know what you do. Who knows what the "easy-to-use" tools do when they fail to help you?
Disadvantages:
- You have to type some commands on your Android.
If you are ready, let's start!
Requirements:
- Rooted Android device with "USB tethering" capability. Check in Android Settings - Wireless & networks - Tethering & portable hotspot. Many stock ROMs disable this capability. You must enable it somehow (root your Android and use an application to enable or replace the stock ROM). CyanogenMod ROMs always have this capability. The important thing to remember is when you connect your Android and enable "USB tethering", it appears as a USB network adapter, not a mass storage or media device.
- PC with a working Internet connection.
- USB cable to connect your Android to your PC.
- Terminal Emulator on your Android. If you don't want to type commands on your touchscreen with Terminal Emulator, you can use your PC keyboard to enter commands with "adb shell". adb is a part of Android SDK which is available for download from Google. To use adb, you need to enable "USB debugging" on your Android.
- Optional, BusyBox on your Android.
Step 1: Connect your Android to PC by USB cable and enable "USB tethering". You are still allowed to enable this option even when your 3g/wifi on your Android is off.
- If you are using Linux (Ubuntu), you don't need to install anything. NetworkManager applet will try to establish a connection on the new detected wired network device.
- If you are using Windows, Windows will automatically search Windows Update and install driver for you. You can skip Windows Update search and install manually an already included driver from Microsoft. In Install Driver window, click Browse My Computer, then Let me pick..., select Network Adapters, uncheck Show Compatible Hardware, look at "Microsoft Corporation" at the left column, and choose Remote NDIS Compatible Device from the right column. You can install or update a driver from Device Manager in Windows.
- If you are using Mac, install driver HoRNDIS. You will be notified about a new network interface. Click "Network Preferences" in the dialog to add it to known interfaces list. Then "Apply".
- If you are using Linux without GUI or NetworkManager, run these commands as root (or use sudo):
Code:
ifconfig usb0 10.42.0.1 netmask 255.255.255.0
(suppose that you don't have any other USB network adapter, otherwise, your Android may be usb1, usb2...)
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
Command for sudo will be:
Code:
sudo 'echo 1 > /proc/sys/net/ipv4/ip_forward'
Code:
iptables -t nat -F
iptables -t nat -A POSTROUTING -j MASQUERADE
Step 2:
- If you are using Linux, click on NetworkManager applet at the top right of your screen, select "Edit Connections...". In tab "Wired", choose the new established connection (be careful, not Ethernet LAN connection) and click "Edit..." In tab "IPv4 Settings", choose "Shared to other computers" as Method. Click "Save". NetworkManager will reestablish the connection and assign to your PC an IP address on this USB network connection, default: 10.42.0.1. Leave Internet connections (wired or wireless) untouched.
- If you are using Windows, open "Network Connections" in Control Panel. It is somewhat different from setup in Linux. Right click on an Internet connection that you have. I assume that you are using a desktop which doesn't have any wifi adapter, so right click on LAN Ethernet connection with Internet, and select "Properties". In tab "Sharing" (or "Advanced" for Windows XP), click "Allow other network users to connect through...", then select the USB connection in dropdown list below. Click OK. Windows will automatically setup your USB network connection and assign to it an IP address, default for Windows 7: 192.168.137.1, default for Windows XP: 192.168.0.1. You can see your Internet connection is now "Shared" and your USB connection is now "Unidentified network".
- If you are using Mac, open System Preferences - Network. If you installed HoRNDIS, you will see a new network interface corresponding to your USB connection. With "Using DHCP" as Configure Ipv4, it may be already connected. Go back to System Preferences, click "Sharing". Select "Internet Sharing". Choose the Internet connection (Ethernet or Airport...) in "Share your connection from", and choose USB connection interface in "To computers using". Mac will assign to your USB connection interface an IP address, default: 192.168.2.1.
- If you are using Linux without GUI or NetworkManager, you have done all PC setup in step 1.
Your PC setup is now done!
Step 3:
Open Terminal Emulator on your Android. Type:
Code:
su
The command prompt must change from $ to #. If it does not, check to ensure that your device is rooted properly.
[UPDATED]Type the following command in Terminal Emulator, the same for all PC operating systems:
Code:
netcfg rndis0 dhcp
The name for usb interface inside Android may vary. It is usually rndis0 or usb0. Type
Code:
busybox ifconfig
to identify the name.
Use OLD instructions below when automatical dhcp method does not work.
[OLD]Type these following commands in Terminal Emulator:
For Linux PC:
Code:
ifconfig rndis0 10.42.0.2 netmask 255.255.255.0
route add default gw 10.42.0.1 dev rndis0
If route fails, try:
Code:
busybox route add default gw 10.42.0.1 dev rndis0
For Windows PC, use the same above commands, replace 10.42.0.2 by 192.168.137.2 (192.168.0.2 for Windows XP), replace 10.42.0.1 by 192.168.137.1 (192.168.0.1 for Windows XP)
For Mac PC, replace 10.42.0.2 by 192.168.2.2, replace 10.42.0.1 by 192.168.2.1
Now you can close Terminal Emulator and start the browser for Internet.
Some applications (download in Google Play, GMail, Facebook...) don't recognize Internet connection. You can try this way (WARNING: NOT TESTED):
- Enable temporarily 3G connection on your Android
- Type:
Code:
ifconfig rmnet0 0.0.0.0
The name for 3G interface inside Android may vary: ppp0, rmnet0... Type
Code:
busybox ifconfig
to identify the name.
before ifconfig rmnet0 ... above.
This will make applications see your Internet connection via USB as 3G!
USB tethering settings on Android will be reverted automatically when you unplug USB cable. To revert back settings on PC, uncheck "Allow other network users to connect through..." on Windows, "Internet sharing" on Mac, change from "Shared to other computers" back to "Automatically (DHCP)", or simply delete USB connection from NetworkManager on Linux.
Awesome tutorial! I moved to a new office at work and lost my 4G signal, they don't have new WiFi AP's up yet, and Edge sucks. I figured out the first half but couldn't figure out how to take a DHCP address on the USB connection on my phone. That worked perfectly and if you leave WiFi or mobile data on then ifconfig it to 0.0.0.0 Gmail et. al. work fine as well. Combined with my Open VPN bridged tunnel to my home network this is a great system for getting a connection away from wireless signals.
pretty handy. glad I found this thread.
p.s Newsworthy soon.
I tried the instructions provided in the tutorial for LAN n 3G connection.
The internet is not starting on my mobile
Very useful! Many times I've gone to Vegas wondering if I could tether my phone's internet to my computer using USB instead of having to use wifi tether or paying for over expensive slow internet! Definitely a useful tool and money saver
Hi!
Thanks for this awsome tutorial but something isnt working for me.
I gues it is at this step:
Click "Allow other network users to connect through...", then select the USB connection in dropdown list below. Click OK. Windows will automatically setup your USB network.
When i allow other network users i dont get any dropdown list and when i press setings below it myself i get a list but there is no USB in there.
I selected everything in there but it still did not work :/
What might the problem be?
also my device seems to be usb0 not rndis0 because terminal said "no such device" and with usb0 it said nothing
Thanks!
aww thanks to share
This is much easier.
xeph20 said:
Hi!
Thanks for this awsome tutorial but something isnt working for me.
I gues it is at this step:
Click "Allow other network users to connect through...", then select the USB connection in dropdown list below. Click OK. Windows will automatically setup your USB network.
When i allow other network users i dont get any dropdown list and when i press setings below it myself i get a list but there is no USB in there.
I selected everything in there but it still did not work :/
What might the problem be?
also my device seems to be usb0 not rndis0 because terminal said "no such device" and with usb0 it said nothing
Thanks!
Click to expand...
Click to collapse
Your Windows must see your Android as a USB network adapter. Go into Device Manager and check under Network Adapters to see if it is there.
If it isn't there, did you enable "USB tethering"? Go into Android Settings - Wireless & networks - Tethering & portable hotspot. When you activate USB tethering, Windows will popup New Hardware dialog for the first time. If you don't activate USB tethering, there will be neither rndis0 nor usb0.
oddoneout said:
This is much easier.
Click to expand...
Click to collapse
Maybe, but that method requires you to install an additional software on your PC. It works with Windows only. The connection is slower, for sure, because data packages have to be routed through the software. And that method proved 'not fully working' (some applications can't connect to Internet).
Thank you
Thank you for posting this great method.
I tried it on my HTC Desire HD and now I am suffering some issues.
After doing all the steps, the internet doesn't work. And after using the command ifconfig rmnet0 0.0.0.0, the usb connection is not recognized by my phone now. I found that the usb debugging option was disabled after the configuration steps. After I re-enable the usb debugging in the setting, the usb connection is still not recognized.
If anyone know how to re-enable my usb connection, please let me know. Thank you.
wangzhuoyu said:
Thank you for posting this great method.
I tried it on my HTC Desire HD and now I am suffering some issues.
After doing all the steps, the internet doesn't work. And after using the command ifconfig rmnet0 0.0.0.0, the usb connection is not recognized by my phone now. I found that the usb debugging option was disabled after the configuration steps. After I re-enable the usb debugging in the setting, the usb connection is still not recognized.
If anyone know how to re-enable my usb connection, please let me know. Thank you.
Click to expand...
Click to collapse
USB debugging option is quite irrelevant. Here I mentioned "USB tethering" capability, not "USB debugging". You can do all steps in this instruction with USB debugging off. Please tell me more when you mean "the usb connection is not recognized by your phone"
phamthanhnam said:
USB debugging option is quite irrelevant. Here I mentioned "USB tethering" capability, not "USB debugging". You can do all steps in this instruction with USB debugging off. Please tell me more when you mean "the usb connection is not recognized by your phone"
Click to expand...
Click to collapse
Thank you for your reply.
I mean when the usb cable is plugged, and the phone is connected with PC by the usb cable, there is no real connection between them.
When I used the command: busybox ifconfig, the usb0 device is not listed any more.
wangzhuoyu said:
Thank you for your reply.
I mean when the usb cable is plugged, and the phone is connected with PC by the usb cable, there is no real connection between them.
When I used the command: busybox ifconfig, the usb0 device is not listed any more.
Click to expand...
Click to collapse
Try to enable USB tethering again, or better restart your phone, then connect it to PC and enable USB tethering. usb0 will disappear if USB tethering option is off.
You will have working Internet connection before ifconfig rmnet0 0.0.0.0. Try open browser or ping first.
phamthanhnam said:
Try to enable USB tethering again, or better restart your phone, then connect it to PC and enable USB tethering. usb0 will disappear if USB tethering option is off.
You will have working Internet connection before ifconfig rmnet0 0.0.0.0. Try open browser or ping first.
Click to expand...
Click to collapse
Thank you so much. But I can't enable USB tethering even after restart my phone and connect it to PC. The USB tethering option is black. My phone can't be recognized by PC now.
wangzhuoyu said:
Thank you so much. But I can't enable USB tethering even after restart my phone and connect it to PC. The USB tethering option is black. My phone can't be recognized by PC now.
Click to expand...
Click to collapse
Hi, I reflashed the ROM and redo all the steps. It still doesn't work. However, the USB connection is established.
And I pinged my phone from PC. I got reply from My phone.
Then I figured out that the Symantec Firework stopped the internet traffic of the shared internet. By changing to allow IP traffic, now my my phone can access the internet with the USB cable.
Some apps work well, including Google Play and Gmail. But Fongo, Nonoh says no Internet connection.
If someone know how to make Fongo and Nonoh work, I really appreciate it.
Thanks again for the great help from you guys.
---------- Post added at 09:51 PM ---------- Previous post was at 09:26 PM ----------
wangzhuoyu said:
Thank you so much. But I can't enable USB tethering even after restart my phone and connect it to PC. The USB tethering option is black. My phone can't be recognized by PC now.
Click to expand...
Click to collapse
wangzhuoyu said:
Hi, I reflashed the ROM and redo all the steps. It still doesn't work. However, the USB connection is established.
And I pinged my phone from PC. I got reply from My phone.
Then I figured out that the Symantec Firework stopped the internet traffic of the shared internet. By changing to allow IP traffic, now my my phone can access the internet with the USB cable.
Some apps work well, including Google Play and Gmail. But Fongo and Nonoh says no Internet connection.
If someone know how to make Fongo and Nonoh work, I really appreciate it.
Thanks again for the great help from you guys.
Click to expand...
Click to collapse
It is very funny that actually Fongo connects to the internet and shows my account info. However, it still says WiFi & Data not available.
It seems that these apps don't test the internet accessibility by trying to connect to the servers, but by reading some WiFi & Data status information in the phone system. So how can we cheat them?
Thanks again for this wonderful post.
After using the command: ifconfig rmnet0 0.0.0.0, is there any way to reverse the command? Thanks. I want to check how some apps work if I didn't use the command.
Tried to use this method on linux, apparently either adb or terminal emulator stops working (adb says my device is offline, terminal emulator doesn't show any prompt, just blank screen) when I enable USB Tethering, therefore I can't execute the required commands.
Notworking in proxy connections
Hi,
I tried all the steps mentioned by you in my Kubuntu PC. All worked well except i'm not able to use internet on my mobile. My pc is connected to a network (which i want to share to my pc) via proxy settings. I pinged from my adb shell for other PCs in my network, and it worked without any packet loss. So my phone is actually connected to the network but i cant access internet. Is there any solution
wangzhuoyu said:
After using the command: ifconfig rmnet0 0.0.0.0, is there any way to reverse the command? Thanks. I want to check how some apps work if I didn't use the command.
Click to expand...
Click to collapse
Try to turn off mobile broadband, or this command:
ifconfig rmnet0 down
leledumbo said:
Tried to use this method on linux, apparently either adb or terminal emulator stops working (adb says my device is offline, terminal emulator doesn't show any prompt, just blank screen) when I enable USB Tethering, therefore I can't execute the required commands.
Click to expand...
Click to collapse
Try to use latest adb version (download from Google instead of using repository version). Android 4.2.2 requires you to accept connection from adb in a dialog displayed on your phone's touchscreen. Try to clear cache/application data in Android Settings/Applications for Terminal Emulator.
Sagar Uv said:
I tried all the steps mentioned by you in my Kubuntu PC. All worked well except i'm not able to use internet on my mobile. My pc is connected to a network (which i want to share to my pc) via proxy settings. I pinged from my adb shell for other PCs in my network, and it worked without any packet loss. So my phone is actually connected to the network but i cant access internet. Is there any solution
Click to expand...
Click to collapse
Run 'busybox route' in Terminal Emulator and assure the default gateway is correct. It should be Kubuntu PC's IP on USB interface (10.42.0.1), like this:
default 10.42.0.1 0.0.0.0 UG 0 0 0 rndis0
then try 'nslookup www.google.com' to see if it can reach DNS server and get domain name resolving.
Try to turn off firewall on your Kubuntu PC:
'sudo ufw disable'
I have not tested with proxy networks yet. Maybe you have something in your PC/network that blocks traffic from your phone to Internet?

Enabling Ethernet over USB OTG

I found a way to enable Ethernet over USB OTG on a Samsung S6 Edge (SM-G925I, International Edition). The phone needs to be rooted because the method requires enabling the interface and editing routing tables.
The method has a "high" level of difficult, because it requires to enter commands on the phone using a terminal. By sharing this method, I hope experts will be able to automate this process, e.g., via an app.
While the description is for the Samsung S6 Edge, I suspect that this method may also be used on other phones.
Pre-requisites:
Tested on Samsung S6 Edge, SM-G925I, with Android v5.0.2 (Build LRX22G.G925IDVU1AOE3).
Phone must be rooted. This is necessary because you will be editing IP routing information which is only available with superuser access. Instructions for rooting the phone may be found elsewhere in XDA.
Set phone to "Airplane Mode" with Wi-Fi disabled. This simplifies the setup, but it is possible to lift this restriction. Left as an exercise to the reader.
Connect the phone to a micro USB OTG adapter. Then, connect the USB OTG adapter to a USB to RJ45 Ethernet adapter. Then, connect the Ethernet adapter to a router. (I have had good luck with BobjGear connectors and adapters. Sold by major online merchants.)
Setup
Your setup should look like this:
Samsung S6 Edge <-> Micro USB OTG connector <-> USB to RJ45 Ethernet adapter <-> Router <-> Internet
Enabling USB OTG interface
Using an app such as "Terminal Emulator" (by Jack Pavlevich) enter the following commands:
Check whether phone can reach router (that is, the gateway). Note: use the IP address of your router. Output shows that phone does not have access to any network.
Code:
$ ping -c 3 192.168.1.1
connect: Network is unreachable
(Optional) Check existing routing setup, useful for comparing after setup is completed.
Code:
# ip route // Should not show anything
# ip rule // Shows default rules (in my case, there are eight)
Confirm that the interface is visible to the phone.
Code:
$ netcfg
eth0 DOWN 0.0.0.0/0
The "eth0" interface corresponds to Ethernet over USB OTG. "DOWN" means that "eth0" is not active, resulting in the "Network is unreachable" message when pinging the router.
Now, gain superuser access:
Code:
$ su
Enable "eth0" interface. Router must be setup for DHCP.
Code:
# netcfg eth0 dhcp
If above command times out, try again. Otherwise try:
Code:
# netcfg eth0 down
# netcfg eth0 dhcp
Confirm that the interface is up and it has been assigned an IP address by the router. (IP address assigned to "eth0" will vary depending on your router setup.)
Code:
# netcfg
eth0 UP 192.168.1.21/24
Now, ping the router. (Note: Use your router's IP address.)
Code:
# ping -c 3 192.168.1.1
Network is unreachable
While interface is active and it has an IP address, phone still does not have access to any network.
Let's examine existing IP routing settings:
Code:
# ip route
The above command does not show any output, indicating that no IP routing is set up. In devices that support Ethernet over USB OTG off-the-shelf (e.g., Nexus 5, Sony Xperia Z1 phone and Z2 tablet), IP routing is setup "automatically". But in devices such as Samsung S6 Edge, IP routing settings need to be enabled manually using the commands below. (My guess is that Google, OEMs or carriers do not want you to use Ethernet over USB OTG.)
Configure IP routings
Configure IP routing in the "eth0" interface. The settings are similar to the ones used by the phone when the Wi-Fi interface is enabled. If the settings below do not work for you, check the IP routing settings on your phone when Wi-Fi is enabled and "eth0" is disabled, and adjust accordingly.
Code:
# ip rule add from all fwmark 0x101f9/0x1ffff lookup 1024 pref 13000
# ip rule add from all oif eth0 lookup 1024 pref 14000
# ip rule add from all fwmark 0x1f9/0x1ffff lookup 1024 pref 19000
# ip rule add from all fwmark 0x0/0xffff lookup 1024 pref 22000
# ip route add table 1024 192.168.1.0/24 dev eth0
# ip route add table 1024 default via 192.168.1.1 dev eth0
Exit superuser mode and (optionally) confirm IP routing settings.
Code:
# exit
$ ip rule // Command should show new entries 13000, 14000, 19000 and 22000
(Optional) Examine new IP routing settings and and newly created routing table entry.
Code:
$ ip route show table 1024
$ ip route
Both commands should output something like this:
Code:
default via 192.168.1.1 dev eth0 proto static
192.168.1.0/24 dev eth0 proto static scope link
Finally, confirm router is reachable from phone. (Note: use your router's IP address.)
Code:
$ ping -c 3 192.168.1.1
That's it! Your phone should now have Ethernet access over USB OTG. Enjoy!
Ps. Please hit 'Thanks' if this info was useful.
Would we have to perform this everytime we flash a new Rom?
Hello,
Could you give more details about which (BobjGear or others) USB to Ethernet adapters you tested with the S6 Edge?
I'd like to get one, but I'm confused about those which can work or not... The BobjGear page
http://www.bobjgear.com/which-tablets-support-ethernet.html
for their adapters states that they don't support Android phones, obviously if you managed to get it to work that is not entirely true
Thanks in advance for any detail you could provide, this is really a great achievement!
luckylui said:
Would we have to perform this everytime we flash a new Rom?
Click to expand...
Click to collapse
@luckylui Indeed, configuration done using these commands (via terminal or using a script) is not sticky, so you need to re-do it after reboot or after disconnecting/re-connecting the micro USB OTG adapter.
In other devices (such as Android tablets), configuration is done "automatically" (some "init.rc" takes care of this upon detecting than an Ethernet interface has been connect). However, for most Android phones this has to be done manually.
I hope that an XDA expert can help us create such a "init.rc" configuration script.
dew_veil said:
Hello,
Could you give more details about which (BobjGear or others) USB to Ethernet adapters you tested with the S6 Edge?
I'd like to get one, but I'm confused about those which can work or not... The BobjGear page
http://www.bobjgear.com/which-tablets-support-ethernet.html
for their adapters states that they don't support Android phones, obviously if you managed to get it to work that is not entirely true
Thanks in advance for any detail you could provide, this is really a great achievement!
Click to expand...
Click to collapse
Indeed, BobjGear's web page says that their adapters do not work for Android phones. However, they may actually refer to the issue that we discuss in this thread, that is, that Ethernet over USB OTG is not enabled in most Android phones by default. Therefore, BobjGear stays in the safe side by making that statement, so as customers don't blame them when Ethernet over USB OTG doesn't work on a phone.
I also have an Ethernet adapter from "Plugable" which does not work for this application because it is not a USB OTG adapter. The keyword here is "USB OTG", so if you purchase an adapter from another brand, make sure it is "USB OTG".
Yes, I think we are onto something useful here. To add to my OP:
I was able to use the same method (although with slightly different "ip rule" commands) with other phones: HTC One M9 and Samsung Galaxy Note 5. The method was the same: root the phone, enter the commands listed in the OP and "voila", the "eth0" interface works! (The first and third "ip rule" commands were slightly different for each phone because you have to match the rules that get set automatically by the phone when "wlan0" is active.)
I am using a script (run with superuser access) to enter the commands, as they are too many to type by hand. Also, I wrote a simple Android app that runs the script with superuser access, so now I don't even need to use a terminal.
I hope this info helps!
doedoejohn said:
Indeed, BobjGear's web page says that their adapters do not work for Android phones. However, they may actually refer to the issue that we discuss in this thread, that is, that Ethernet over USB OTG is not enabled in most Android phones by default. Therefore, BobjGear stays in the safe side by making that statement, so as customers don't blame them when Ethernet over USB OTG doesn't work on a phone.
I also have an Ethernet adapter from "Plugable" which does not work for this application because it is not a USB OTG adapter. The keyword here is "USB OTG", so if you purchase an adapter from another brand, make sure it is "USB OTG".
Yes, I think we are onto something useful here. To add to my OP:
I was able to use the same method (although with slightly different "ip rule" commands) with other phones: HTC One M9 and Samsung Galaxy Note 5. The method was the same: root the phone, enter the commands listed in the OP and "voila", the "eth0" interface works! (The first and third "ip rule" commands were slightly different for each phone because you have to match the rules that get set automatically by the phone when "wlan0" is active.)
I am using a script (run with superuser access) to enter the commands, as they are too many to type by hand. Also, I wrote a simple Android app that runs the script with superuser access, so now I don't even need to use a terminal.
I hope this info helps!
Click to expand...
Click to collapse
Do you think you could share that app for the note 5?
Do apps access ethernet?
Thank you for this useful op.
Following your concept (S6 edge device rooted and using Alex-V kernel) I have no trouble with pings via terminal however all apps still see internet as disconnected.
Do your apps connect to the internet on all the phones with which you used this method?
Does the kernel have to support USB-Ethernet or is this not kernel related?
doedoejohn said:
Indeed, BobjGear's web page says that their adapters do not work for Android phones. However, they may actually refer to the issue that we discuss in this thread, that is, that Ethernet over USB OTG is not enabled in most Android phones by default. Therefore, BobjGear stays in the safe side by making that statement, so as customers don't blame them when Ethernet over USB OTG doesn't work on a phone.
I also have an Ethernet adapter from "Plugable" which does not work for this application because it is not a USB OTG adapter. The keyword here is "USB OTG", so if you purchase an adapter from another brand, make sure it is "USB OTG".
Yes, I think we are onto something useful here. To add to my OP:
I was able to use the same method (although with slightly different "ip rule" commands) with other phones: HTC One M9 and Samsung Galaxy Note 5. The method was the same: root the phone, enter the commands listed in the OP and "voila", the "eth0" interface works! (The first and third "ip rule" commands were slightly different for each phone because you have to match the rules that get set automatically by the phone when "wlan0" is active.)
I am using a script (run with superuser access) to enter the commands, as they are too many to type by hand. Also, I wrote a simple Android app that runs the script with superuser access, so now I don't even need to use a terminal.
I hope this info helps!
Click to expand...
Click to collapse
Hello, this is fascinating. I want to set this up on my LG G2 D801, only I don't know what "ip rule" commands I should enter. How can I find out the rules the phone sets when "wlan0" is active?
This post needs more recognition and attention than it has. XDA Admins should frontpage it imho. I have a friend who has a Nexus 9 and Ethernet dongles work out of the box. Samsung devices though is an other story. Me and my boss are setting up networks for small businesses. It would have been amazing if we could enable on our Samsung phones (S5 him and S7 me) Ethernet support as it would save us from having to carry on not-easy-to-access places heavy equipment to set up the network or troubleshoot issues that WiFi is not an option. I wish there was an app or a script that would do the work for you. In any way, good job, actually, spectacular job!
Hello,
how can I use ethernet with my S6 with Android 6?
doedoejohn said:
I found a way to enable Ethernet over USB OTG on a Samsung S6 Edge (SM-G925I, International Edition). The phone needs to be rooted because the method requires enabling the interface and editing routing tables.
The method has a "high" level of difficult, because it requires to enter commands on the phone using a terminal. By sharing this method, I hope experts will be able to automate this process, e.g., via an app.
While the description is for the Samsung S6 Edge, I suspect that this method may also be used on other phones.
Pre-requisites:
Tested on Samsung S6 Edge, SM-G925I, with Android v5.0.2 (Build LRX22G.G925IDVU1AOE3).
Phone must be rooted. This is necessary because you will be editing IP routing information which is only available with superuser access. Instructions for rooting the phone may be found elsewhere in XDA.
Set phone to "Airplane Mode" with Wi-Fi disabled. This simplifies the setup, but it is possible to lift this restriction. Left as an exercise to the reader.
Connect the phone to a micro USB OTG adapter. Then, connect the USB OTG adapter to a USB to RJ45 Ethernet adapter. Then, connect the Ethernet adapter to a router. (I have had good luck with BobjGear connectors and adapters. Sold by major online merchants.)
Setup
Your setup should look like this:
Samsung S6 Edge <-> Micro USB OTG connector <-> USB to RJ45 Ethernet adapter <-> Router <-> Internet
Enabling USB OTG interface
Using an app such as "Terminal Emulator" (by Jack Pavlevich) enter the following commands:
Check whether phone can reach router (that is, the gateway). Note: use the IP address of your router. Output shows that phone does not have access to any network.
Code:
$ ping -c 3 192.168.1.1
connect: Network is unreachable
(Optional) Check existing routing setup, useful for comparing after setup is completed.
Code:
# ip route // Should not show anything
# ip rule // Shows default rules (in my case, there are eight)
Confirm that the interface is visible to the phone.
Code:
$ netcfg
eth0 DOWN 0.0.0.0/0
The "eth0" interface corresponds to Ethernet over USB OTG. "DOWN" means that "eth0" is not active, resulting in the "Network is unreachable" message when pinging the router.
Now, gain superuser access:
Code:
$ su
Enable "eth0" interface. Router must be setup for DHCP.
Code:
# netcfg eth0 dhcp
If above command times out, try again. Otherwise try:
Code:
# netcfg eth0 down
# netcfg eth0 dhcp
Confirm that the interface is up and it has been assigned an IP address by the router. (IP address assigned to "eth0" will vary depending on your router setup.)
Code:
# netcfg
eth0 UP 192.168.1.21/24
Now, ping the router. (Note: Use your router's IP address.)
Code:
# ping -c 3 192.168.1.1
Network is unreachable
While interface is active and it has an IP address, phone still does not have access to any network.
Let's examine existing IP routing settings:
Code:
# ip route
The above command does not show any output, indicating that no IP routing is set up. In devices that support Ethernet over USB OTG off-the-shelf (e.g., Nexus 5, Sony Xperia Z1 phone and Z2 tablet), IP routing is setup "automatically". But in devices such as Samsung S6 Edge, IP routing settings need to be enabled manually using the commands below. (My guess is that Google, OEMs or carriers do not want you to use Ethernet over USB OTG.)
Configure IP routings
Configure IP routing in the "eth0" interface. The settings are similar to the ones used by the phone when the Wi-Fi interface is enabled. If the settings below do not work for you, check the IP routing settings on your phone when Wi-Fi is enabled and "eth0" is disabled, and adjust accordingly.
Code:
# ip rule add from all fwmark 0x101f9/0x1ffff lookup 1024 pref 13000
# ip rule add from all oif eth0 lookup 1024 pref 14000
# ip rule add from all fwmark 0x1f9/0x1ffff lookup 1024 pref 19000
# ip rule add from all fwmark 0x0/0xffff lookup 1024 pref 22000
# ip route add table 1024 192.168.1.0/24 dev eth0
# ip route add table 1024 default via 192.168.1.1 dev eth0
Exit superuser mode and (optionally) confirm IP routing settings.
Code:
# exit
$ ip rule // Command should show new entries 13000, 14000, 19000 and 22000
(Optional) Examine new IP routing settings and and newly created routing table entry.
Code:
$ ip route show table 1024
$ ip route
Both commands should output something like this:
Code:
default via 192.168.1.1 dev eth0 proto static
192.168.1.0/24 dev eth0 proto static scope link
Finally, confirm router is reachable from phone. (Note: use your router's IP address.)
Code:
$ ping -c 3 192.168.1.1
That's it! Your phone should now have Ethernet access over USB OTG. Enjoy!
Ps. Please hit 'Thanks' if this info was useful.
Click to expand...
Click to collapse
First of all, thank you for this great work. I need ethernet connection and my tablet (lenovo yoga tab 3) had no ethernet access.
Now, following your instuctions I have managed to ping the router from the terminal, but then I do not load any page the browser and I do not connect the apps. Do I need to do anything else? Or am I doing something wrong?
Could you help me please?
Thanks in advance!
doedoejohn said:
Code:
# ip rule add from all fwmark 0x1f9/0x1ffff lookup 1024 pref 19000
Click to expand...
Click to collapse
Hello, I am trying to do the same for my note 4.
I am currently able to ping google.com without having changed the ip rule tables.
But all my apps are still not able to recognize the ethernet connection.
So I am digging into those ip rule tables.
My question is, how did you find that value 0x1f9 ?
I have analyzed dozen of ip route policy databases and I have roughly understood how they are built.
But it seems this value differs from an interface to another (wlan0, eth0, rmnet, ...). Seems it's a kind of network ID ?
Also, would it be possible to have your ip route policy table with wlan0 and the final one for eth0 with your tweak ?
Thanks
hello
i would like to know if there is a script to enable ethernet...i've a lenovo tablet, the usb dongle is well recognize by android but no ethernet connection is made...
Thank you for sharing this, novebis!
Getting ethernet working on my used tablet was the reason for my purchasing it and the reason I joined the forums.
This worked on my ASUS Memopad 8 ME181C K011 (rooted with locked boot loader) with a "Pluggable USB 2.0 Ethernet Adapter 10/100 Mbps", Model USB2-E100, hanging off of a "Micro USB OTG Charge HUB For Smartphone and Tablet".
I've got the "Pluggable USB 2.0 OTG Ethernet Adapter 10/100 Mbps", model USB2-OTGE100, also which I suspect will work without any changes. I also have a USB 3 gigabit model from a different manufacturer with a similar but newer SoC which I'll try. A Chromecast powered version from UGREEN is also on the way for testing.
I'll be looking for an automated method for this and for a way to make Google Play use the connection.
Thanks so much. I'm stoked
On Note 5, I can ping google.com and Chrome is working via the cable. But all other apps don't, like Google Photos, Youtube, Facebook.
Any idea why?
The script in this thread didn't work correctly so I had to improvise my own as below:
ifconfig eth0 10.1.1.50 netmask 255.255.255.0 broadcast 10.1.1.255
ifconfig eth0 up
ndc network create 9792
ndc network interface add 9792 usb0
ndc network route add 9792 usb0 0.0.0.0/0 192.168.225.1
ndc resolver setnetdns 9792 8.8.8.8 8.8.4.4
ndc network default set 9792
Click to expand...
Click to collapse
dan.leahu said:
On Note 5, I can ping google.com and Chrome is working via the cable. But all other apps don't, like Google Photos, Youtube, Facebook.
Any idea why?
The script in this thread didn't work correctly so I had to improvise my own as below:
Click to expand...
Click to collapse
Although I have a different device, I've given up on this and switched, instead, to a virtual android device.
There are some apps relating to fake WiFi which are supposed to address this issue but I've had no luck in getting some apps (e.g. Google Play) to use ethernet. I've also had limited results using reverse USB tethering.
What you're trying to do is what many would want. However, it's simply too good of an idea for the producers of proprietary systems and operating systems to tolerate. Efforts to give the people what they want seem to fall into a black hole of silence.
"Dive Into Android Networking: Adding Ethernet Connectivity - ELCE 21"
https://www.youtube.com/watch?v=LwI2NBq7BWM
Slides
https://www.elinux.org/images/9/98/Dive_Into_Android_Networking-_Adding_Ethernet_Connectivity.pdf
HD version of the video here...
https://bootlin.com/pub/video/2012/elce/elce-2012-zores-android-networking-ethernet-support.webm
Products resulting from the above work:
Premium DeskPhones
https://www.al-enterprise.com/en/products/devices/premium-deskphones
AngrySockPuppet said:
Although I have a different device, I've given up on this and switched, instead, to a virtual android device.
There are some apps relating to fake WiFi which are supposed to address this issue but I've had no luck in getting some apps (e.g. Google Play) to use ethernet. I've also had limited results using reverse USB tethering.
What you're trying to do is what many would want. However, it's simply too good of an idea for the producers of proprietary systems and operating systems to tolerate. Efforts to give the people what they want seem to fall into a black hole of silence.
"Dive Into Android Networking: Adding Ethernet Connectivity - ELCE 21"
https://www.youtube.com/watch?v=LwI2NBq7BWM
Slides
https://www.elinux.org/images/9/98/Dive_Into_Android_Networking-_Adding_Ethernet_Connectivity.pdf
HD version of the video here...
https://bootlin.com/pub/video/2012/elce/elce-2012-zores-android-networking-ethernet-support.webm
Products resulting from the above work:
Premium DeskPhones
https://www.al-enterprise.com/en/products/devices/premium-deskphones
Click to expand...
Click to collapse
Thank you so much, never knew such research exists on this.
So does it mean there's no way to do it?
I thought I was close, as after the script above I've further did some changes and now Google Play works via Ethernet Cable. I can download apps, which wasn't working before.
Added command:
Code:
ip rule add from all lookup main pref 1
But still, WhatsApp and Google Photos still miss the connection. I really can't understand why?!
Oh now I see from the slides:
• Java framework services and apps rely on Connectivity Manager
and have no clue what Ethernet route/connection actually means.
- Except for some apps (e.g. Browser, which relies on native implementation).
Click to expand...
Click to collapse
Actually found this which does a reverse tethering via USB cable + Linux computer. Hope it'll work better than trying to get Ethernet connection work.
https://github.com/vvviperrr/SimpleRT
found at:
https://news.ycombinator.com/item?id=12198085
dan.leahu said:
Thank you so much, never knew such research exists on this.
So does it mean there's no way to do it?
I thought I was close, as after the script above I've further did some changes and now Google Play works via Ethernet Cable. I can download apps, which wasn't working before.
Added command:
Code:
ip rule add from all lookup main pref 1
But still, WhatsApp and Google Photos still miss the connection. I really can't understand why?!
Oh now I see from the slides:
Click to expand...
Click to collapse
Congratulations on getting Google Play to work. That's a big accomplishment.
You're way ahead of me though.
Perhaps you will have better luck with the fake WiFi apps as well.
My main interest in this is to use social media apps without wireless.

Categories

Resources