yashsingh1/xdaforums huggingface dataset:
[Networking] class101:
The scripts I place them at the base directory of the shared folder in Windows, it points directly to /sdcard/

Originally on 4.4.4 I did not really used a script file, I was sertting the ip and gateway on both cards manually but with the need to launch our own dnsmasq for 5.0 changes I found it was easier to put every commands in single files I can run with a short alias and in the case of a need to go back to a stock android I don't have any more to remember a lot of syntaxes heheh

But yeah you shouldn't need a single edit in the file if you just want to copy paste it I made it for that, else in the terminal to create a file you can do "vi /sdcard/rndis.sh" (vi is a very good text editor present in all linux but better to watch the syntax to type with it, not simple to use if you need to edit inside but for copy pasting you will just long press the screen and paste, then you type ":wq" in vi to write & quit

From here the file is ready to be executed, there is no extra permission to set on it, just need to su -c 'sh /sdcard/rndis.sh' to execute, then you can set it to an alias to speed up everything, let me know if you have troubles to set it I will help you

some commands you will probably need:

netcfg (see network cards running state, the ip and netmask of each one)

busybox route -n (see network card routes/gateways)

vi (file edition)

su (alone in the terminal editor to get root privilege directly in the terminal)

su -c 'sh /path/toscript.sh' (run a script as root)

mount -o remount, RW /system (allows writing in system files for example /etc/mkshrc, it reverts to read only after a reboot)

I think you have all linux commands you will need with that
[Networking] Ricfil:
I got lost when you say you put the script on a folder on windows? Wasn´t the script supposed to be in a phone partition so that terminal Emulator can find its path?...

I´m finding it pretty confusing to get the script part to work. Everything else I think I´ve managed to understand.

Thanks for the help man.
[Networking] class101:
I mean I'm backing up the scripts files on my Windows and in case of a first install or reinstallation of the Android os, to set reverse tether again, I 'm transferring these script files from Windows => Nexus like that, when you plug the usb in Windows don't you see a new shared folder appearing under "This PC" where all other drives are showing ? Here I have a Google Nexus 5 and when I plug the phone to the usb of my computer, I see under This PC, a shared folder named Nexus 5 where I can paste all the scripts once and I never touch them again because I know that the base of this shared folder is pointing directly in /sdcard/ of the phone

My english is very basic so you probably have a hard time translating me hehe, it is just in case you wonder how to edit a script file easily in Windows and want it on the phone, there is more way probably like file edition with vi + save directly from the phone, or probably adb push can also transfer files from Windows to the phone but not very familiar with this way of file transferring from Windows to the Phone.

btw in case you wonder how to edit the mkshrc to add aliases, I have just added these to mines

alias rn='sh /sdcard/rn.sh'
alias rnoff='sh /sdcard/rnoff.sh'
alias wl='sh /sdcard/wl.sh'
alias wloff='sh /sdcard/wloff.sh'
alias rm='sh /sdcard/rm.sh'
alias rmoff='sh /sdcard/rmoff.sh'
alias ro='busybox route -n'
alias pi='ping google.com'
alias piip='ping 8.8.8.8'
alias pirn='ping -I rndis0 google.com'
alias wr='mount -o remount, RW /system'
alias n='netcfg'

so each time I type "rn" it starts reverse tether, "rnoff" to stop, "pi" a test ping, "ro" to see routes and "n" to see network cards

//edit: reverting to 4.4.4 this weekend because the battery usage of 5.0 compared to 4.4.4/ART is a nightmare, 5.0 is far to be ready for use imo.

//edit2: Just tested the script under 4.4.4 it works perfectly without a change
[Networking] Ricfil:
You´re english is pretty good. No problems there. I´m Portuguese, my english is not that awesome either. :)

I get the aliase edit. You need to edit a file named "mkshrc" on the system partition. And I think I get the shared folder thing. Still have to notice the shared folder you mencion about. Still, I don´t have any problems copying the files from Windows to the Nexus when I need to use them. My problem is how to make the script work on Android. I used terminal emulator and typed (su -c 'sh /sdcard/rndis.sh') and then checked the internet access on Chrome (on the Nexus 5) and... nope... no conection... :( I can´t seem to understand what comand do I need to run on terminal emulator so the script can do its magic... frustating stuff really... I just need to copy the text script on your post to a text file named rndis.sh (extension.sh), copy the script to the Nexus 5 "SDCard" partition and use the comand above in terminal emulator to run it. Right?

Regarding batery life on 5.0. A Portuguese forum I´m a member of as lots of posts relating that stuff. For me, I´ve managed to get awesome batery times and sometimes also ****ty ones on Lollipop. I do believe there are some bugs on 5.0 code that interfere with batery drainage on some devices.

Thanks for the time and knowledge. :good:
[Networking] class101:
Exactly.

Really hope you will get it, I took some screenshots of what it looks like when it works

1)

su (to get root)

su -c 'sh /sdcard/rn.sh' (running the script file as shown in the code block above, you shouldn't get any errors between the echo commands)

netcfg (confirm rndis0 is set to an ip in the 192.168.137.0 network 255.255.255.0 netmask, grep is to only catch the relevant line mentionning rndis0 for the screenshot)

busybox route -n (confirms the network is known and the default route is set to 0.0.0.0 netmask 0.0.0.0)

ping google.com to test the connection and dns resolve

ping 8.8.8.8 to check if it is only a dns issue or no connection at all

screenshot

2)

If you dont get any internet connection after the ping command with the setting exactly showing up as in the screenshot, then this is the buggy connection sharing in Windows, disable it once by unchecking the connection sharing and reenable it, and double check 192.168.137.1 255.255.255.0 has been automatically attributed to the RNDIS interface, here I have to disable/enable it always after restarting Windows about once a day, something I think is going wrong in Windows when the rndis interface disappear when you unplug the usb cable

Below is a screenshot of the internet connection sharing checkbox in Windows, this is the first one to uncheck, hit OK, OK again to apply settings and reopen and check it back to enable connection sharing again.

And below the tcp ip setting automatically attributed by Windows to the nexus card, you shouldn't have to edit this but showing it for investigating possible issues in your case
[Networking] Ricfil:
:confused:Now, this is a perfect post right here. Plenty of material to work on. Not only for myself but also for others who are trying the same configurations as me on 5.0. Sticky worthy in my book. :D

You know your stuff. You should teach IT stuff or something similar. :) You've got the knowledge, the will to help, and the "touch" to do so.

Big thumbs up! :good: :good:

As soon as I get my hands on my Windows machine I'll get to that.

Thank YOU.

Edit:

Still no go. I´ve checked and the rndis interface on Windows does not automaticaly assign the ip 192.168.137.1 (only if I manually input it in the interface). Also, here is what I get when I run the rndis.sh script on Terminal Emulator (one shows all comands like your example above despite the erros I got and the other is just another quick test to run the script):

One more question, do you enable the usb tether on the phone before or after running the script? I did it both ways and the result is similar to image 2 :confused:
[Networking] class101:
You did not built your files correctly, they probably have invalid chars, you need to remove them with vi or you probably created the file with line ending of WIndows while you should create them with UNIX line ending, Notepad++ can do that but anyway I attached the script in Unix line ending to this post if you can't build them

Also Windows should set the ip automatically after prompting a message box, if you have an ip manually set or nothing then this is probably because you don't even enable the rndis interface correctly.

Also you don't have to enable the RNDIS manually ... Never mentionned you had to check the USB checkbox in the phone ... The script will enable the usb rndis automatically, the checkbox will just remain unchecked in Android, you shouldn't check it anymore, if you enable the checkbox this will run a wrong instance of dnsmasq and rndis will be started with ip 42.129 that's not good. The script does it better for working with Windows connection sharing.

Uploaded the script file already built, you shouldn't get any error with them but if you add step I never mentionned before then this will probably not work

Better to reboot the phone to revert all change you did then use the files I posted, you shouldn't have to touch anything else than ping or disable/enable connection sharing after that in Windows, if you get no errors after the script file in the phone and still not working then this is internet connection sharing on Windows side not setting the ip and mask as shown in the picture, in this case you can probably set 137.1 and 255.255.255.0 manually or if it says 137.1 is already assigned you can probably set another ip but you need to update 137.1 in the script files but this is not really the recommanded way to set an other ip than 137.1 because this is the range Windows is supposed to choose automatically when you enable connection sharing, normally it is set to use the 137.0 network and 137.1 for the extra card.

I had once this issue with connection sharing I think 137.1 was attributed to the wrong card and I had to delete the ip setting on that card to release 137.1, but the simplest way actually to test would be to set it manually to 137.1 after enabling connection sharing, and if Windows claims 137.1 is already attributed, update the gateway 137.1 to 137.2 in the script and in Windows to test on a newer ip
[Networking] Ricfil:
Got it working after using your rn.sh script. I thought I only needed to copy the script code and add the ".sh" extension on Windows and I was good to go. I look at "my" built script and then yours and see no diference. :confused: That line ending stuff really got me now...

I will eventually use the rn.sh script more often, but from what I understand, if the scripts are well built (if I knew how to do that) , like using yours, wifi is just a matter of setting manually the ip and gateway as you say on the wifi android interface, then use the wl.sh off/on scripts (on 5.0) and I should be good to go.

Regarding the mkshrc file edit. I just need to copy the lines you added on your post to the end of the file, and then save it? Is it a script file? If so, don´t I need to be aware of the line ending trick on Windows/Unix scripts? It would be great to fully automate the process with a simple comand on Terminal Emulator indeed.

Thanks for the help and pacience. Awesome info you have got going right here. It will help many people I´m shure. :good:

Edit: Does it take a long time for the Windows rndis interface to get configured on your pc (hangs if you force enter properties and such) after the rn.sh comand is entered and the input sent from the Nexus 5 to the pc? On mine it takes a long time to do so (using Windows 8.1 here). It shurely as something to do with the comunication between the N5 and the interface on Windows when everything is being set up properly.

Also, when I was browsing the Nexus using my coaxial cable conection (fast as hell, indeed :cool:), the N5 crashed suddenly (the first time)... Does it happen often at your side? Also, when I disable/enable the ethernet share for the RNDIS interface on Windows a pop up error appeard stating "the service cannot accept control messages at the moment"... It seems that only after a PC restart it worked again. Not even a rn.sh off/rn.sh on fixed it that time. After a pc reboot I saw no errors in the small browsing time I did. Lightning fast when working ok! :cool:

For a quick browse it seems fine. But for a long time experience it seems that some bugs are still present (script or Windows wise, not shure though). You say you use it often it seems. That´s why I ask.

Thanks for the files, the great "how to", the time and pacience and the great insight man.
[Networking] Ricfil:
Do we only need to copy the script lines to Notepad++ and save the file as an Unix .sh file to get the line ending method working with that program? Or are there any hidden options or manual editing still involved?

On Windows I´ve used the admin account we get from the install. If I have any more troubles I`ll check that and also the flushdns option. Never though of that really and it might indeed help.

As for android, I´ve gone from 4.4.4 to 5.0. using fastboot with a full wipe, and never had any issue. Google apps I don´t want on the system are also long gone on my phone, but using Titanium Backup (great app for backups and system app edits).

Once again thanks again for the usefull insights and help. Whenever I see an android 5.0 user with dificulties trying to reverse tether on his system (as myself) I´will shurely recommend your awesome work and explanation :good:
[Networking] class101:
Yes should be enough as soon as you save it as Unix the mode will persist, I think the only way to have it return in a Windows mode is to change the option back in Notepad++ or any editor allowing to do it

//edit: Tried on another computer and there is still a delay when the computer starts, I think that's ICS just slow to load when the computer first boot up, what I'm trying actually is to bridge both network cards instead of using ICS, this should be faster on paper and maybe this will get ride of that behaviour, basically you disable ICS, select both cards, create bridge, you reapply your normal ethernet card ip settings to the bridge, and you change ip in the tether scripts to point in the same network of you internet card, same gateway and dns. Here for example my internet card is on 192.168.1.101 and the mobile on 192.168.1.102, no need of a new network that way, Seems to be slighty faster than ICS here, not tested yet if this Windows service enables faster than ICS yet will let you know tommorow
[Networking] Ricfil:
Got the notepad++ option I think.

Hum... Regarding the bridge option. I don´t get what you are refering to as ICS but understand the fundation you talk about relating "brigdging" the two cards on the same network (on Windows) and apply the script so that the rndis on the N5 points to that same network (as oposed to having diferente networks - bigger load on the system maybe=slower processing). Clever thinking. I still need to try the mkshrc edit option, so that the script is easily triggered. Plenty of stuff to dwelve on!

Gold info you´ve got going here. Gold info I tell you. :D
[Networking] ZioAlfredo:
[win 7 connectivity issue]

Hello, I have a "Samsung Galaxy S Advance" with "CyanogenMod 10.2" and my PC has Windows 7. When I connect the phone to the PC, via USB, it does not appear as Network Adapter, it is not recognized at all. I've unchecked "Media Device", "PTP" and "Mass Storage" options in my phone "USB tethering" menu. My phone is detected by Win 7 as "Unkown Device".

I followed the instructions I've found at: http://developer.toradex.com/knowledge-base/how-to-install-microsoft-rndis-driver-for-windows-7

and I could go through the process of driver update, but at the end Win 7 prompted: "This device cannot start (Code 10)".

What should I do?

Thank you very much,

ZioAlfredo
[Networking] class101:
You don't need to install any driver as far I checked on WIndows server 2008, 2003, Win 8.1 they all have already that driver in place, but maybe now you screwed up the WIndows configuration even more, if you are fine running a shell script .sh on a rooted device then I suggest you to look at the guide I'm linking to in my sig, thats probably the fastest way to setup reverse tether and been tested working on KitKat 4.4.4 and Lollipop 5.0

Yes indeed if you bridge you are just attaching your mobile phone to your current network instead of using a new network and using the computer as a router with ics,

Also I can confirm Bridging cards instead of using ICS does not produce an extra long delay when the computer first boot up, internet works ~10sec after running the script, it is just a big more boring to setup if you are moving from computers to computers since each network as its own ip setting and gateway, anyway I'm fine doing multiple scripts here so I will go definitely on bridge anyway, that's a bit more faster than ICS.

The Unix End Of Line Option in Notepad++ is in Edit > EOL Conversion and in the status bar you see what file use what mode when opening it
[Networking] Ricfil:
Glad to know bridging allows another option regarding reverse tethering the N5. It's another valid option. I will have that option in mind. I've already setup both my desktop and laptop to the first option, but having other (faster) options is always nice. :)

Regarding Notepad++ , I'll be shure to check that option out.

Thank YOU very much :good:
[Networking] class101:
no prob you are welcome, one last thing I would like to be able to get ride is the Wifi requirement so you can fully reverse tether all the Apps without a wifi access point, not sure if someone ever did this without using an app to fake a Wifi interface, like fooling the OS and make it think rndis0 is the wlan interface
[Networking] Kazryu:
Its not working on galaxy tab 4 sm t231

I already tried all the steps, from the first one until last, used all of the method the new ones & old ones but still not working

It's still showing unidentified network in my network adapter, im using windows 8 .1

Please help, thanks
[Networking] class101:
The unindentified network state is not really something relevant to worry about, here I have it showing too but it works as expected,

If you do eveyrthing as shown in the screenshot I've posted in the little guide linked in my sig, the picture at the very bottom of the post, if you get the exact same output on your Android then android is all set and your problem should be located in Windows, if not, the problem starts in Android, difficult to say without you giving much informations
[Networking] SpEcHiDe:
Shell script to do reverse tethering
[Networking] bjorn96:
Hello [MENTION=5273317]phamthanhnam[/MENTION]

I first want to say that it worked all just fine. :good:

Then I have some questions for you. :D

1. Will this leave a trace on the WiFi-router or any other network device, or will it just seem like the computer used a lot more data than usually? :)

2. Can the commands be done in a .bat file and run on the computer as admin? I mean if you have adb installed system wide, use command

@echo off
adb devices
pause
adb shell su
adb shell netcfg rndis0 dhcp
adb shell ...

and so on?? :)

3. I suggest you put a link to Hack-connectivety (as he mention in this post), or Fake Wifi Connection from this post, will fix the Store issue and other apps. :D

4. Is there a way to turn on tether by adb?

All the best, [MENTION=6099013]bjorn96[/MENTION]

Edit: Seems like a lot similar questions been flying around... Annyways I hope tp get the answer from someone. :)

Any chance it can be made so it works without having to connect to internet before?? :)
[Networking] 44twenty:
Terminal says "action 'dhcp' failed (Timer expired)

1st time it worked fine but when i connect again it says "action 'dhcp' failed (Timer expired)"
[Networking] class101:
3. It is a 4.4.4 solution because Fake Wifi Connection requires Xposed, and Xposed does not support Android 5 and will probably never support it, and honestly, an app requiring Xposed to be installed just to fake the wifi connection is too much intermediary app when you can do it manually, just set your wlan network to have the rndis interface as gateway is enough if you are using Connection Sharing, even more easier with a Bridge instead of ICS because you don't even have to set the gateway to a valid address, just setting your wlan adapter to be in the home network is enough, the wifi will just be there as HelloWorld Wifi OK, but in reality all the internet transaction are made on USB.

4. Yes see the what does the rn.sh script in the guide I'm linking to in my signature, when it does --- setting usb mode to rndis --- it enables rndis, I don't check the checkbox anymore here in the options, I run rn.sh to get the internet over rndis, and I enable the wifi in the settings and all is set.
[Networking] bjorn96:
Thanks for that.

I got it working, but I have some "issues" (me being n00b :crying: )

How do i do the part 5??
[Networking] class101:
No problem man we are all noob, I'm working to make a very noob friendly thread guide about this method with updated scripts and step at step instructions on how to use them with both internet access you can get Internet Connection Sharing or a Network bridge, because technically a bridge is even more faster than ICS, I will let you know tommorow or so the link you will better understand I'm describing all steps with screenshots and clean instructions

But if you got already there you got it mostly 100%, actually what you are looking for in 5. you know are the Wifi settings when you go in Settings > Wifi > Long press the wifi you connect on and select to modify the network, in the dropdown menu changes from DHCP to Static and automatically Android will display new boxes where you enter IP, gateway , netmask and dns1 & 2
[Networking] bjorn96:
Looking forward to it. :)

So in other words, connect to a WiFi?? Why then reverse tether? :)
[Networking] class101:
Connected to WIFI just for the Wifi to be present requirement, but it uses USB for internet. Why ? Because wifi is slow and sucks, on wifi here at home I get 25% of the global speed of 20 MB, this give a small 5MB with very slow browsing and connexion is lost from time to time when using an App requiring a stable connexion this is a nightmare, under USB with just WIFI faked, I get 100% of the speed of my internet box, 20Mb, fast browsing and stable connexion without connexion loss, night and day =)

If it was up to us I would like to get ride of that Wifi access point requirement, but unfortunately I don't think it is possible without changing Android sources and recompiling it
[Networking] itsmepawan:
Not working for me : (

Noob here..

I tried and followed steps, and succeeded, but there was no internet in my tablet after completing all the steps from page1. I tried to open play store, chrome browser, but NO internet.

my specs:

Windows 8.1

Android 5.0.2 Slim Rom

Samasung Galaxy tab 2

Used the scripts given by [MENTION=6190600]class101[/MENTION]

Update: Working on Chrome but not on all the apps (I haven't followed after 4th step because I don't have wifi connection).
[Networking] toppits:
You might want to try this: http://xdaforums.com/showpost.php?p=57490025&postcount=205

OP should be updated with some new information, especially regarding LP.

Now i have a little question myself [MENTION=6190600]class101[/MENTION]

I copied all your scripts to my sdcard and I put the alias in the mkshrc file. I use the Terminal Emulator by Jack Paleviche.

When i use n (netcfg) or pi (ping google.com) it works fine. But as soon as I use an alias with a path in it like rn, it gives me an error.

su -c rn -> sh: rn: not found

rn -> : No such file or directory

When i type su -c 'sh /sdcard/rn.sh' everything works fine. I'm kind of at a loss here where my problem is.

If i need to provide anything else so you can help me, please tell me.

And thx for this great guide =)