Android USB Tethering 2015 update?

Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
MountainX
DD-WRT Novice


Joined: 28 Dec 2013
Posts: 41

PostPosted: Sat Aug 29, 2015 18:10    Post subject: Android USB Tethering 2015 update? Reply with quote
I've got a Buffalo router with DD-WRT firmware v24SP2-(08/12/14) std. My phone provider is T-Mobile and my plan includes tethering. My phone easily tethers to my PC via usb (without any 3rd party apps needed).

I want to get usb tethering working with my dd-wrt router. However, I am not finding any recent threads and I hesitate to follow information from 2011/2012.

How do I proceed? Thanks in advance.

Mod note 04.11.24: Topic split from 4G USB Modem because USB modems and Cell Phones are not entirely the same functionality. -kp69

As of 55776/8 and later alpha and beta releases, Android USB Tethering is now included in DD-WRT for those routers which support it:

2024 - Android usb tethering to dd-wrt router?

kernel-panic69 wrote:
Yeah, well, because of your inquiry, I again prodded about adding support for Android Tethering and:

Android Tethering Added

Add ncm support

Android Tethering fixes

Should be in the next public release to test. 8):wink:


Sponsor
shenoyh
DD-WRT Novice


Joined: 14 Feb 2011
Posts: 11

PostPosted: Fri Oct 20, 2017 16:39    Post subject: 2017 Update: Got it working Reply with quote
Its 2017: Several Years have passed since the original question of how to tether Android phones to DDWRT.

A couple years have also passed since MountainX went around asking about the same to several forums and threads and he was only successful in getting pointers to OLD DDWRT Wikis and threads. The DDWRT Wiki on this is outdated and does not apply to newer K3 builds that include several of the required drivers as well as built in support for things like ACM, 3G/4G modems, RNDIS.

It appears that MountainX did get this setup working based on what he has posted on an other website though we are not sure how he did it.

While it may be that DDWRT supports it, there is no Wiki article or even a forum post that details how to do this in clear steps (Android USB tethering in general which is different from using a 3G USB dongle).

After several hours searching, I finally got it working. If I had Wiki access, I could have put this in the Wiki, but unfortunately I do not have Wiki access.

Note that during the process I also found that this won't work on TPLink or other Atheros WiSOC routers - works only on ARM and maybe MIPS.

This is my router model and firmware (TMo router on Latest KONG):
Router ModelAsus RT-AC68U
Firmware Version DD-WRT v3.0-r33435M kongac (10/08/17)

Samsung Android phone connected by USB to USB2.0 port or router (though that should not matter and the 3.0 port should work well).

On the phone, I go into settings->Tethering and Hotspot-> Check the "USB Tethering" box. In order to see this box, your phone must be connected by USB to the router and may initially need to be in Data (LTE/3G mode) though you can later switch to Wifi if required.
My phone is rooted, but that should not matter so long as you see the USB tethering option.

The following will work both to share the Wifi from the phone as well as the LTE/3G:
cd /lib/modules/4.4.89
insmod usbnet.ko
insmod cdc_ether.ko
insmod rndis_host.ko
ifconfig usb0 up
udhcpc -i usb0

What it does is bring up the usb0 interface and get it an IP address which now becomes the WAN address of the router. Note that I have selected Connection Type as "Automatic Configuration - DHCP". It appears that DDWRT automatically assigns the usb0 to the WAN VLAN and so there is no need to update nvram parameters.
Credit to calamari who first did something like this on a tomato in 2012.(https://dd-wrt.com/phpBB2/viewtopic.php?t=79336&start=15)
To makes things complete you do need to open the firewall as well to forward packets between the USB0 and the br0 which is the gateway (192.168.1.1) for your network with these firewall rules:
iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE
iptables --append FORWARD --in-interface br0 -j ACCEPT

When you switch between Wifi and LTE/3G data on the phone, you may have to run (ifconfig usb0 up;
udhcpc -i usb0) each time since it loses the DHCP IP and does not automatically ask for it again.

So whats the use of this several may ask. Why not use Wifi tethering and put DDWRT in bridge mode? The answer is that not everyone does everything the same way and there are many different applications.

My goal now is to do a failover to the phone's LTE/3G only when required though its WiFi will still be active all the time. I will use an old cheap phone and I am getting a cheap data plan either an iOT data plan from AT&T or an PAYG Sprint plan that does not require monthly payment.
My security system consisting of several Wireless IP devices connect to one DDWRT router which is the security hub. This router sits on a location that does not have cable based internet access. So I have to use the phone's Wifi radio for the purpose of obtaining internet access from the distant router that has only 2.4GHz radio and I have no control of this main router. Several of my devices are not 5GHz capable and so I cannot use the 5GHZ radio at all.

So in my situation, I would use the phone's Wifi to connect to the distant router over Wifi most of the time. If that router/Wifi fails for some reason, then my phone would switch to LTE data.
While failover routing would have been best to do on the DDWRT router than on the phone, there is not sufficient information about failovers on DDWRT either...(failover from client mode to the USB tether or cabled WAN port ethernet is what I hope to get DDWRT to do in the future). So I am just using Androids build in failover mechanism at this time.
jagster936
DD-WRT Novice


Joined: 17 Apr 2018
Posts: 36

PostPosted: Wed Apr 18, 2018 2:48    Post subject: Reply with quote
Has anyone gotten this to work? There is a "mobile broadband" option for USB tethering, but I haven't been able to get it to work
sydlexia
DD-WRT Novice


Joined: 18 Feb 2014
Posts: 9
Location: San Francisco CA.

PostPosted: Wed May 16, 2018 19:21    Post subject: Reply with quote
jagster936 wrote:
Has anyone gotten this to work? There is a "mobile broadband" option for USB tethering, but I haven't been able to get it to work


Yes indeed. Tethering DD-WRT v3.0-r35030M kongac on a Netgear R7000 via a Galaxy S9+ using the method mentioned by shenoyh works well.

Phone connected to usb3 port; usb tethering enabled
WAN port on the router set to DHCP
ssh or telnet to router

run the following or put in rc.startup
Code:

cd /lib/modules/4.4.116-rc1  # this dir may be different
insmod usbnet.ko # this module should already be loaded
insmod cdc_ether.ko
insmod rndis_host.ko
ifconfig usb0 up
udhcpc -i usb0
iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE
iptables --append FORWARD --in-interface br0 -j ACCEPT


That should do it. My phone will drop the port if no activity for a time, so a ping script running from cron that hits your gateway every minute or so will help to keep your connection stable. Just be sure to have your script chuck it's PID in a lock file of sorts and check for it's existence at each runtime to be sure you don't end up with 100 copies of the same script running.

As mentioned by shenoyh, you will likely have to re-run:

Code:

ifconfig usb0 up
udhcpc -i usb0


if your link drops to renew your dhcp lease. Assigning a static IP to usb0 my be an alternative solution to deal with that. Thanks to shenoyh for posting the details.
e.r0k
DD-WRT Novice


Joined: 03 Jun 2018
Posts: 1

PostPosted: Sun Jun 03, 2018 7:36    Post subject: Re: 2017 Update: Got it working Reply with quote
shenoyh wrote:
Its 2017: Several Years have passed since the original question of how to tether Android phones to DDWRT.

A couple years have also passed since MountainX went around asking about the same to several forums and threads and he was only successful in getting pointers to OLD DDWRT Wikis and threads. The DDWRT Wiki on this is outdated and does not apply to newer K3 builds that include several of the required drivers as well as built in support for things like ACM, 3G/4G modems, RNDIS.

It appears that MountainX did get this setup working based on what he has posted on an other website though we are not sure how he did it.

While it may be that DDWRT supports it, there is no Wiki article or even a forum post that details how to do this in clear steps (Android USB tethering in general which is different from using a 3G USB dongle).

After several hours searching, I finally got it working. If I had Wiki access, I could have put this in the Wiki, but unfortunately I do not have Wiki access.

Note that during the process I also found that this won't work on TPLink or other Atheros WiSOC routers - works only on ARM and maybe MIPS.

This is my router model and firmware (TMo router on Latest KONG):
Router ModelAsus RT-AC68U
Firmware Version DD-WRT v3.0-r33435M kongac (10/08/17)

Samsung Android phone connected by USB to USB2.0 port or router (though that should not matter and the 3.0 port should work well).

On the phone, I go into settings->Tethering and Hotspot-> Check the "USB Tethering" box. In order to see this box, your phone must be connected by USB to the router and may initially need to be in Data (LTE/3G mode) though you can later switch to Wifi if required.
My phone is rooted, but that should not matter so long as you see the USB tethering option.

The following will work both to share the Wifi from the phone as well as the LTE/3G:
cd /lib/modules/4.4.89
insmod usbnet.ko
insmod cdc_ether.ko
insmod rndis_host.ko
ifconfig usb0 up
udhcpc -i usb0

What it does is bring up the usb0 interface and get it an IP address which now becomes the WAN address of the router. Note that I have selected Connection Type as "Automatic Configuration - DHCP". It appears that DDWRT automatically assigns the usb0 to the WAN VLAN and so there is no need to update nvram parameters.
Credit to calamari who first did something like this on a tomato in 2012.(https://dd-wrt.com/phpBB2/viewtopic.php?t=79336&start=15)
To makes things complete you do need to open the firewall as well to forward packets between the USB0 and the br0 which is the gateway (192.168.1.1) for your network with these firewall rules:
iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE
iptables --append FORWARD --in-interface br0 -j ACCEPT

When you switch between Wifi and LTE/3G data on the phone, you may have to run (ifconfig usb0 up;
udhcpc -i usb0) each time since it loses the DHCP IP and does not automatically ask for it again.

So whats the use of this several may ask. Why not use Wifi tethering and put DDWRT in bridge mode? The answer is that not everyone does everything the same way and there are many different applications.

My goal now is to do a failover to the phone's LTE/3G only when required though its WiFi will still be active all the time. I will use an old cheap phone and I am getting a cheap data plan either an iOT data plan from AT&T or an PAYG Sprint plan that does not require monthly payment.
My security system consisting of several Wireless IP devices connect to one DDWRT router which is the security hub. This router sits on a location that does not have cable based internet access. So I have to use the phone's Wifi radio for the purpose of obtaining internet access from the distant router that has only 2.4GHz radio and I have no control of this main router. Several of my devices are not 5GHz capable and so I cannot use the 5GHZ radio at all.

So in my situation, I would use the phone's Wifi to connect to the distant router over Wifi most of the time. If that router/Wifi fails for some reason, then my phone would switch to LTE data.
While failover routing would have been best to do on the DDWRT router than on the phone, there is not sufficient information about failovers on DDWRT either...(failover from client mode to the USB tether or cabled WAN port ethernet is what I hope to get DDWRT to do in the future). So I am just using Androids build in failover mechanism at this time.


You're my hero. Thank you and others greatly for posting this information. I've crawled the net for a long time looking for a solution like this. I can confirm this method worked for me on:

Router: Linksys WRT1900ACSV2
Firmware: DD-WRT v3.0-r34080 std (12/14/17)
Kernel: Linux 4.9.69-rc1 #83 SMP Wed Dec 13 01:23:39 CET 2017 armv7l
Phone: Samsung over USB Tethering

I will note that I tried several times over the course of a couple of hours before it worked. I think it's important to reset the router prior to setting this up, and immediately start the process before configuring any other settings.

Thanks again!
Aback
DD-WRT Novice


Joined: 06 Nov 2018
Posts: 11

PostPosted: Wed Nov 07, 2018 12:24    Post subject: Re: 2017 Update: Got it working Reply with quote
I have successfully enabled USB tethering using your guide, but it doesn't work good at all. Network slows down significantly as soon as I start loading web pages, and Ping goes through the roof. I tried switching from USB 2 to USB 3 which helped a lot but still not enough. Even tried switching cable, for a thicker one... Previously I used 5G Hotspot to tether to my router, and set a Repeater Bridge on it, which worked much much better and faster. There were no slowdowns of any kind. My hope was that USB tethering would/should work faster, but it seems I was wrong. My Router is Netgear R6400v2 running DD-WRT v3.0-r37015M kongac (09/23/18 ) , and The connection type was set to Automatic Configuration - DHCP. I didn't touch anything else except enabling USB support and shortcut forwarding engine. All other settings are stock DD-WRT.
Is there something else I could try?

Thanks.

EDIT: I've solved the problem. Disabled Shortcut Forwarding Engine (needed for full wifi speeds on R6400v2). The network behaves as expected now, much better compared to Repeater Bridge.
Saiber77
DD-WRT Novice


Joined: 10 Nov 2019
Posts: 8

PostPosted: Sun Nov 10, 2019 6:38    Post subject: Reply with quote
I followed this guide with my RT-AC68U and couldn't get it to work, "ifconfig usb0 up" returns: "ifconfig: ioctl 0x8913 failed: No such device".

Any ideas?

Mod note: USB Tethering has to be turned on in the phone's settings first.
hoot_spoot
DD-WRT User


Joined: 07 Dec 2009
Posts: 110
Location: Earth.

PostPosted: Tue Mar 31, 2020 4:45    Post subject: Added to Wiki Reply with quote
See link: https://forum.dd-wrt.com/wiki/index.php/Cellular_Phone/USB_Modem_as_WAN_connection
_________________
various hw
suprnova74
DD-WRT Novice


Joined: 09 Feb 2012
Posts: 13

PostPosted: Wed Jul 01, 2020 15:01    Post subject: Reply with quote
Saiber77 wrote:
I followed this guide with my RT-AC68U and couldn't get it to work, "ifconfig usb0 up" returns: "ifconfig: ioctl 0x8913 failed: No such device".

Any ideas?


I know this is a necro, but searches tend to bring this post up as one of the first hits aside from the Wiki.

For anyone else running into this issue, see https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1209728#1209728 as he explains how to find the device ID in the event it doesn't use "usb0" as well as a bunch of troubleshooting tips on performance etc.
smithbill17
DD-WRT Novice


Joined: 18 Aug 2020
Posts: 1

PostPosted: Tue Aug 18, 2020 16:14    Post subject: Reply with quote
I've struggled to get this working using a Xiaomi Redmi Note 7 phone tethered to a TP-Link Archer C9 v4 router running the latest beta DD-WRT firmware.

I can telnet to the router and execute the documented insmod commands successfully but when I get to the ifconfig usb0 up command, it fails with "No such device"

I've Googled and read assorted posts about using nvram to create the usb0 interface, but nothing works.

If i just enter 'ifconfig' it lists out br0, eth0, eth1, eth2, lo, vlan1, vlan2. There is no usb0 interface.

If i tether my phone direct to my laptop (with the same USB Type-C cable), it works fine through the tethered 4G data link.

If i use an old mobile phone (HTC One M7) with an old style micro-USB (TypeB) cable and connect that to my Archer C9 router, then interface usb0 is available and tethering works.

So why, when I connect my Archer C9 to the Redmi Note 7 using the manufacturer supplied USB Type-C cable, does interface usb0 not appear??

I've tried everything to make usb0 appear but just cant figure out why it wont. Any help/suggestions?

Mod note: Your Xiaomi Redmi Note 7 may not support RNDIS, but rather NCM. OR, the interface given is not 'usb0'.
hoot_spoot
DD-WRT User


Joined: 07 Dec 2009
Posts: 110
Location: Earth.

PostPosted: Fri Nov 26, 2021 22:28    Post subject: IPV6 Reply with quote
Anyone know how to get ipv6 working?

https://forum.dd-wrt.com/wiki/index.php/Cellular_Phone/USB_Modem_as_WAN_connection

_________________
various hw
baboeska
DD-WRT User


Joined: 22 Jun 2011
Posts: 59

PostPosted: Wed Apr 12, 2023 11:40    Post subject: Re: IPV6 Reply with quote
hoot_spoot wrote:
Anyone know how to get ipv6 working?

https://forum.dd-wrt.com/wiki/index.php/Cellular_Phone/USB_Modem_as_WAN_connection

This guide has since stopped working for me, post build r51140, udhcpc seems less powerful in terms of wan network options?

No idea for native ipv6, however... If you need IPv6...

On r51140 (12-31-2022) IPv6to4 tunneling via HE works if selected in the ipv6 menu.
Use all the settings from Hurricane Electric tunnel settings, set it up like this, add a line to startup; "ifconfig ip6tun up" ping6 google.com

IPv6 (make sure clients are ipv6 enabled if desired)
6in4 HE get values from their website
DHCP Client daemon disabled
DHCP Server daemon disabled
RADVD enabled, custom config

interface br0 {
AdvSendAdvert on;
prefix yourcustomprefixfromHE/64
{
AdvOnLink on;
AdvAutonomous on;
};
};
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Fri Jun 02, 2023 10:28    Post subject: Reply with quote
Evrything works until:

ifconfig usb0 up
udhcpc -i usb0

Seems something has changed somewhere and current builds DD-WRT v3.0-r52720 std (05/27/23) somehow while all indicated modules are present and loaded no new adapter is created that goes by usbX or any other adapters are created, all though ifconfig can add adapters manually, this would require new steps if at all possible that way.

Anyway, after spending some time on this guide/wiki page (like 10 minutes or so) I wasn't able to get there yet due to lack of anything usbX, shame I could really use this right now as my source of Internet is an unlimited data sim Ive rented for while, so my temporary network where Im stuck at can connect to WAN via router.

I do have a workaround, but requires a 2nd ethernet port on a PC/OTher where Android phone is thered to, and then share the NDIS WAN with that 2nd ethernet which in turn connects to routers WAN, in a pinch a sloppy solution with caveats.

OFFTOPIC.
YES Im alive, news of my demise or alien abduction stories are greatly exaggerated.

Be well folks.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Fri Jun 02, 2023 15:46    Post subject: Reply with quote
This guide https://forum.dd-wrt.com/wiki/index.php/Cellular_Phone/USB_Modem_as_WAN_connection and this thread are pertinent.

Issues lie in the current kernel modules in modern dd-wrt like cdc_ether.ko and rndis_host.ko fail to provide usb0, however on this thread and post provides these compiled modules, so for a test I removed the official and shunted those in and walla usb0 came to live in ifconfig.
NOTE: Your phone's USB Tethering function MUST be active first before usb0 will come up from personal experience on 55678/55723. The only issue I had was getting a WAN IP to register, but it could've been a timing thing. So, the above "statement" is suspect. /shocker -kp69

In addition other changes happen also from gleamed from https://www.reddit.com/r/DDWRT/comments/fco6um/guide_android_usb_tether_as_wan/ namely the nvram wan_ifxxxx= entries must point to usb0

after a apply setting on admin tab to restart network stack since I was loading the modules from /tmp for a test, it worked after udhcpc -i usb0 I was able to tether to android phone via usb direct to router, however clearly these modules need to be recompiled for the target kernel hence maybe the flakiness.

I had also read https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1281232#1280315 however it only gave clues that a great deal has changed to get this working with minimal fuss.

thanks for the links, just no time to waste on this for the time being to get such a basic function going.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14217
Location: Texas, USA

PostPosted: Thu Jun 15, 2023 4:44    Post subject: Reply with quote
Yes, kernel modules have to be compiled for specific kernel version, and this could also be included out-of-the box, but that is another story altogether. Moving right along...

Android phone support

The most simple solution would be this (and it works):

hebeda wrote:
i think the more easy approach is a android phone with android 12 or higher and a USB to Ethernet Adapter , it should have native Ethernet tethering support.

i am using a EDUP EP-9802 USB C to Ethernet Adapter with Realtek RTL8153 Chipset for such purpose with my Xiaomi Poco X3 Pro Phone ..

Otherwise, for emergencies I have a couple of other options using FreshTomato (that supports Android tethering out of the box).

UPDATE: As noted in the OP, Android Tethering support is now natively supported thanks to diligence. As I noted in an edit above, it has nothing to do with kernel modules not providing the interface, it's having your phone "ready". Also, I noted thanks to the most recent 2024 thread, that you possibly must finesse the routing table for it to work as it didn't seem to work using these older workarounds - but at this point, it is now moot unless you are wanting it to work on Linux 2.x or 3.x devices with USB ports (at present time of this edit, not supported that I've seen yet.).

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Display posts from previous:    Page 1 of 1
Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum