PCsuggest

  • Quick tip
  • SECURITY
  • NETWORKING
  • OpenWrt
  • HARDWARE

Setup USB tethering to OpenWrt router

Updated - November 8, 2019 by Arnab Satapathi

Most of the time a smartphone's wifi hotspot isn't powerful enough. So you might want to use the internet via usb tethering to router for better wifi coverage.

I'm pretty sure most of the routers can't do that by default, even if they have a USB port.

That's when OpenWrt is extremely useful, openwrt usb tethering is quite simple if you've a little knowledge about it.

Contents

  • What you need to setup OpenWrt usb tethering ?
    • 1. Login to the router via SSH and install drivers
    • 2. Edit network interfaces
  • Conclusion

What you need to setup OpenWrt usb tethering ?

Of course you need a router running OpenWrt with a USB port and a smartphone or a 3G/4G router capable of USB tethering.

Beside that, you've to make sure that,

  1. There's atleast 20 KB free space left on the router's NOR flash memory.
  2. The router can connect to internet somehow, need to install drivers.
  3. You're not using the USB port for any other purpose, like extroot.
  4. Basic understanding of linux commands and OpenWrt.

Alternatively you can build a OpenWrt custom firmware including the kmod-usb-net-rndis driver.

1. Login to the router via SSH and install drivers

At this step, you need to login to your router via SSH, use Putty if you're on Windows.

ssh root@192.168.1.1

Make sure the router is connected to the internet, either through the WAN interface via an ethernet cable or via WiFi client mode. I used my laptop's ethernet port to share existing wifi connection through NetworkManager.

Now update the opkg repository with opkg update, and install the OpenWrt RNDIS driver.

opkg install kmod-usb-net-rndis

That's enough, the package kmod-usb-net-rndis will automatically pull all other dependencies.

amazon prime logo
Try AmazonPrime for free
Enjoy free shipping and One-Day delivery, cancel any time.

All kernel drivers should be loaded automatically, check it with lsmod | grep 'rndis' command.

2. Edit network interfaces

In this step, first plugin your tethering device and check what interface is created by the rndis_host driver.

root@openwrt:~# dmesg
[ 59.980000] usb 1-1: new high-speed USB device number 3 using ehci-platform
[ 60.160000] rndis_host 1-1:1.0 eth2: register 'rndis_host' at usb-ehci-platform-1, RNDIS device, fc:de:56:ff:01:06

Now create a new network interface, usb_wan and configure it.

Edit the /etc/config/network file with vi, and add the lines below, anywhere you want.

config interface 'usb_wan'
    option ifname 'eth2'
    option proto 'dhcp'

Now save the changes and exit vi editor. If you're not familier with the vi text editor, have a quick look here.

IPv6 support configuration

This is optional, but if you're thinking about IPv6 connectivity, create another interface usb_wan6 on the /etc/config/network file and add these extra lines there.

config interface 'usb_wan6'
     option ifname 'eth2'
     option proto 'dhcpv6'

Now reload the whole OpenWrt networking stuff.

/etc/init.d/network reload

You can see the a the new network interface is now up, and got an ip address.

openwrt usb tethering to router

In the above screenshot, eth0 is the ethernet LAN interface, eth1 is the ethernet WAN interface and eth2 is the USB tethered interface.

Note: If the tethering device is assinging the router any IP between 192.168.1.1 to 255, then you may need to change the ip address of the LAN interface from 192.168.1.1 to something like 192.168.2.1.

I've to change that, as my LTE router is assigning the 192.168.1.100 address to the router, so it was not working.

Conclusion

Basically the smartphone acts as a USB to ethernet adapter which we need to setup. This tutorial is also applicable for those external ethernet adapters too.

So that's how to setup USB tethering on a OpenWrt router. It's simple enough if you're familier with Linux and OpenWrt, but quite dubious for beginners. I can't make it even more simplier.

What's your thought about this method of setting up USB tethering to router ? Let me know through the comments.

Filed Under: hardware, networking, openwrt Tagged With: openwrt, openwrt usb tethering, router, router usb tethering, usb, usb tethering, usb tethering to router

Your comments
  1. Alaa says

    December 5, 2020

    Many thanks Arnab,

    Is there a way to fix the usb mapping to a certain id for example make it always eth2 ?connecting and disconnecting the devices keeps changing the id and this requires reconfiguration of wan every time.

    Reply
  2. Mukesh says

    August 30, 2020

    Hello Aranab
    Is this method possible to implement in tplink w8968 v4 ? I am trying to use my old 4g phone to connect with usb port of above router and use jio 4g net in entire house.

    Reply
    • Arnab Satapathi says

      September 6, 2020

      Yes, I've tested it with a android phone and JioFi 2.

      Reply
  3. shori says

    May 28, 2020

    Great article !!!
    Can be tether my smartphone as modem with the Router TP-Link TL-MR3420 nMax 3G / 4G Router 300Mbps ?

    Tnx
    shori

    Reply
    • Arnab Satapathi says

      May 28, 2020

      Yes, you can, I can confirm it.

      Reply
      • shori says

        June 2, 2020

        Thanks so much for the response.
        We're talking about this router right?
        https://ksp.co.il/index.php?select=&kg=&list=1&sort=2&glist=1&uin=13462&txt_search=%D7%A8%D7%90%D7%95%D7%98%D7%A8+%D7 % A1% D7% 9C% D7% 95% D7% 9C% D7% A8% D7% 99 & buy = & minprice = 0 & maxprice = 0 & intersect = .. & rintersect = & store_real =

        Reply
        • Arnab Satapathi says

          June 2, 2020

          Yes, that wold work too.
          I have the MR3220 model.

          Reply
          • shori says

            June 2, 2020

            Thank allot.
            I will try it

          • shori says

            June 2, 2020

            TNX, I will try and update.
            You have very nice site.
            Good day

  4. Joob says

    April 18, 2019

    When I tether from my phone via USB it also acts as a DHCP server. If I would use this method, would that mean that the router will also do DHCP and so I'll have double NAT? Is is possible to use the router to only act as a bridge between the wireless and wired LAN interfaces to the USB interface of the phone?

    Reply
    • Arnab Satapathi says

      April 18, 2019

      Yeah, it's actually double NAT, as the router's LAN and WLAN interface are binded togather and running their own DHCP service.

      I'm not sure whether it's possible to bridge all 3 interfaces USB, LAN and WLAN.

      Reply
  5. Yuvraj says

    July 24, 2017

    Informative Blog. Thanks For sharing

    Reply
  6. JoeGalind says

    July 13, 2017

    Excellent tutorial. I had been banging my head trying to get this to work with a Verizon 4G dongle.

    I had to add the following for it to work, since it was detected as a mass storage device:

    okpg install usb-modeswitch

    Edit /etc/usb-mode.json

    Add the following:
    "1410:9020": {
    "*": {
    "msg": [ ],
    "config": 4
    }
    },

    The 1410:9020 corresponds to the vendorid & deviceid for my dongle.

    Hope this helps.

    Reply
    • Arnab Satapathi says

      July 14, 2017

      That's great to know Joe.

      And thanks for the USBmodeswitch part.
      I've a plan to write a seperate tutorial about USB modeswitch and USB modem on OpenWrt in near future.

      Reply
  7. Yaser says

    July 8, 2017

    The tutorial is quite clear

    Reply
    • Arnab Satapathi says

      July 8, 2017

      Thanks 🙂

      Reply
      • Yaser says

        July 13, 2017

        Is there any possibility to send call from openwrt / linux to android phone?

        Reply
        • Arnab Satapathi says

          July 13, 2017

          It may be possible, via adb commnds, unfortunately old school AT commands doesn't work well on modern android phones.

          A better alternative could be using a cheap GSM module, like SIM800C, if you really need to make calls or send SMS from a router.

          Reply
          • Yaser says

            July 18, 2017

            Any opportunity to get android phone get automatic tethering and without rooting the phone?

          • Arnab Satapathi says

            July 18, 2017

            Unfortunately I don't have a Andoid device now, so I can't test it.
            However my LTE modem automatically tethers to the router, the LTE modem is not much different from a phone, just without the display.

        • YASER says

          June 10, 2018

          Can you do paid development on openwrt ?

          Reply
          • Arnab Satapathi says

            June 11, 2018

            Unfortunately not, too much caught up with other activities.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © PCsuggest.com · All rights reserved.

  • Home
  • About
  • Contact
  • Privacy Policy
  • Sitemap