USB tethering is used to connect your OpenWrt Router to the Internet by using the contract and 3G/4G modem of your smartphone. It's more convenient and has better performance (lower latency) than turning your smartphone in an access point and using that.
WARNING: connecting your whole network to the Internet using the Smartphone might consume your monthly GB quota very fast, as other devices in the network will download updates (ahem… Windows 10) or use the network whenever they feel like without asking your permission. This is also the case for other human users.
Tested and working with a Wileyfox Swift (Android smartphone) with a router running OpenWrt “master” (built from source) as of 25/04/2018. Building from source isn't necessary for this, I did it for other reasons.
Sharing the router's internet connection with a device over USB (which is the reverse of this) is described in smartphone.usb.reverse.tethering
install some Kernel packages to get USB tethering support.
opkg update opkg install kmod-usb-net kmod-usb-net-rndis kmod-usb-net-cdc-ether
There is also kmod-usb-net-ipheth package whose description is “Kernel support for Apple iPhone USB Ethernet driver”, which might be necessary if you want to tether from an iPhone. Can users with iPhones confirm if this is needed or not?
Connect the smartphone to the USB port of the router with the USB cable and then enable USB Tethering from the Android settings.
If all went well you should be able to see something like the following in the kernel log
[ 168.599245] usb 1-1: new high-speed USB device number 2 using orion-ehci [ 175.997290] usb 1-1: USB disconnect, device number 2 [ 176.449246] usb 1-1: new high-speed USB device number 3 using orion-ehci [ 176.654650] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-f1050000.ehci-1, RNDIS device, ee:da:c0:50:ff:44
Note how the last line tells us that this new “RNDIS device” was bound to interface usb0.
Create a new interface called TetheringWAN (or however you like), and bind to it the new *usb0* network device (or for some cases '*eth1*, check what the log is saying in your case), set the protocol to DHCP client mode, and place it into the WAN firewall zone.
Write this in your console if you are using SSH or serial connection:
uci set network.TetheringWAN=interface uci set network.TetheringWAN.proto='dhcp' uci set network.TetheringWAN.ifname='usb0' uci set firewall.@zone.network='wan wan6 TetheringWAN' uci commit
If you are using LuCi web interface, Click on Network, then on Interfaces, and then on the “Create new interface” button. then see the following screenshots.
First page of the Create Interface wizard.
Firewall tab of the Create Interface Wizard. Very important to set it as WAN.
And the end result in the Interfaces page.
After committing the changes the new TetheringWAN should be activated.
If it does not, write
or restart it with the buttons you find in the Interface page of LuCi Web interface.
If your Android phone does not seem to detect that there is something attached to the USB port and refuses to switch to USB tethering, you might want to install DriveDroid and try to enable various methods of using USB guest for its own functionality. This does solve that issue in my phone (which is running LineageOS nightly and sometimes after I update does show this issue). You will probably need root (administrator) access on your device though.
If you don't see something like the sample kernel log output in your device's log then your device might be lacking proper USB drivers (drivers to operate the USB controllers at all). Check Installing USB drivers and report the issue in a bug report or in the mailing list, as devices should have base USB drivers integrated and working already.
For other issues it might be worth it to check the article about using RNDIS dongles as Android tethering is using the same protocol.
The original forum thread: https://forum.openwrt.org/viewtopic.php?pid=173399#p173399
The old wiki archived page https://wiki.openwrt.org/doc/howto/usb.tethering
A script that might enhance the experience (especially for iPhone users) https://github.com/LeJeko/OpenWRT-USB-Tethering