Easy USB Smartphone Tether Install Shell Script

Hey all. I hope it's okay to post this here. I made a simple shell script that installs all the necessary packages to enable USB smartphone tethering.

Copy/paste the following into a text editor when ssh'd into your router i.e. nano or vi/vim (and of course make it executable after with chmod +x nameofyourfile.sh), then run it, and it'll install all that you need to tether your iPhone or Android phone to your OpenWRT router!


# /bin/bash
# Hey all! Shiggitay here! I've been messing around with OpenWRT so much that I've visited the wiki/docs pages a bit too much when it comes to setting up a WAN Failover solution. 
# Sooo, I decided to make this little script to help y'all out. This script will install the necessary packages and services to enable iPhone and most Android USB smartphone 
# tethering on OpenWRT. Feel free to email me at shiggymiyamoto [at] gmail [dot] com with any questions if something isn't working.
# After this script finishes downloading and installing the packages please visit https://www.openwrt.org/docs/guide-user/network/wan/smartphone.usb.tethering#b_routerweb_interface
# to finish setup. Thanks, Shiggitay

# Install the following to enable tethering support to your router:

opkg update
opkg install kmod-usb-net-rndis

opkg install kmod-usb-net-cdc-ncm

# Huawei may need its own implementation!
opkg install kmod-usb-net-huawei-cdc-ncm

# More protocols:

opkg install kmod-usb-net-cdc-eem
opkg install kmod-usb-net-cdc-ether
opkg install kmod-usb-net-cdc-subset

# Extra steps depending on USB type and drivers for your router:

opkg update
opkg install kmod-nls-base kmod-usb-core kmod-usb-net kmod-usb-net-cdc-ether kmod-usb2

# Additional steps for iOS devices:

opkg update 
opkg install kmod-usb-net-ipheth usbmuxd libimobiledevice usbutils

# Call usbmuxd
usbmuxd -v

# Add usbmuxd to autostart
sed -i -e "\$i usbmuxd" /etc/rc.local

=== END SCRIPT ===

I hope someone finds this useful. I've only tested the above script on x86_64, but it should theoretically work on ARM64 as well, so long as the required packages are available. Feel free to comment out any packages you don't need, like for example the Huwawei one if you don't have any Huwawei devices, etc.


User guide for info / installation on openwrt.org

1 Like

I'm aware of the docs/wiki, but instead of copy/pasting all that stuff I've put together a script you can execute and it'll do it all for you. And that link I actually include in the script at the top, but yeah you need to continue with those steps. I just thought it'd be beneficial. It wouldn't hurt to look into the script after you make it executable.

1 Like

I knew, but for someone who is interested in the background I provided the link...

1 Like

Nice Subject and steps are clear

1 Like

Thanks! Yeah I've had to reinstall that stuff a lot lately when tinkering with OpenWRT builds and it got annoying constantly c/p-ing all that stuff... Now? ./install_openwrt_smartphone_tether.sh and BOOM the software part is done, leaving only the interface assignments, of which I don't know how to automate, but yeah.