Cellular Phone/USB Modem as WAN connection

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:37, 2 December 2021 (edit)
Kernel-panic69 (Talk | contribs)
(Main Guide [Updated 5/2020] - (people can use the history link to see when and what was updated))
← Previous diff
Revision as of 23:42, 2 December 2021 (edit) (undo)
Kernel-panic69 (Talk | contribs)
m ('''Steps:''')
Next diff →
Line 56: Line 56:
##Go to the tab <tt>Administration</tt>, <tt>Commands</tt>. ##Go to the tab <tt>Administration</tt>, <tt>Commands</tt>.
##Paste: [these are the commands you used above] ##Paste: [these are the commands you used above]
-##:<code>:insmod usbnet.ko<br>+##:<code>insmod usbnet.ko<br>
##:insmod cdc_ether.ko<br> ##:insmod cdc_ether.ko<br>
##:insmod rndis_host.ko<br> ##:insmod rndis_host.ko<br>

Revision as of 23:42, 2 December 2021


Contents

Main Guide

USB Tethering with an Android phone, or using a USB Modem, on your DD-WRT-enabled router.

USB Phone Tethering [Attach an android-based phone via USB to a router]

Already tethered your phone to your computer via USB (or wifi) and now you want to move up to having a full router?

Here is a Step-by-Step, with a $19 phone, $25/m* unlimited plan and a $5 router [Your router costs may vary] visible.com Visible Reddit forum *click here for the discount

Testing w/ Phone: 1st tested with a Verizon Visible R2 (5/2mbs) on 5/20, but then upgraded to a Pixel 2 w/PixelExperience 6/21 [with Band 66 and Carrier Aggregation support], and then tested with a Pixel 3a G020G (rootable) 11/21. Service: Visible LTE-only pre-pay [bandwidth on the VR2 and other non-Band 66, Non-CA phones is typically 5/2Mbs, but with the better Pixels, it is typically 15Mbps down, 15+mbps up, on AWS Band 66+CA. There is no data maximum per month after which your data rate becomes unusable (e.g. 50GB 'unlimited' limit on Tmobile Pre-pay)]
Router: 1st: Linksys EA6400 running DD-WRT v3.0-r37012 std (2018/09/21) and also works with r42819 (2020/03/30) [fully tested!].

Requirements:

1. Make sure the necessary modules exist on your build. This is very important. Some router builds are simply missing the modules, and it is beyond the scope of this guide or the ordinary user to build their own versions of the missing modules: We will go through the steps to check for this. This guide assumes that the build you downloaded and flashed of DD-WRT, has the modules cdc_ether.ko and rndis_host.ko, which are not present on some builds (regardless of build size) but required for USB tethering. If they do not exist on your build, you may need either: a larger version of DD-WRT that includes them, or to reflash over to OpenWRT [However OpenWRT has limited Broadcom support!]. These are -very small- modules (8kb) but are not included on some larger builds for some routers.

2. Reset your router: This assumes you have saved your existing Router settings first, before resetting your router to test these USB Tethering settings. If you've done some custom config since flashing your router, and you want to keep it, first: back up your settings, then reset the router, and test this out. If you can get it working from a reset router, then if it does not work with your custom settings, you'll have to figure out what additional steps you need to do that are beyond the scope of this article.

Steps:

  1. Router: Main configuration page: leave WAN on Automatic DHCP. Set the MTU manually between 1200-1428 (max) [1]. Set your timezone. Save & Apply.
  2. Phone: connect it to router's USB port with a USB cable you've already used for successful tethering with your laptop.
  3. Phone: Turn on your phone's Developer Options: [Click 'Build Number' in 'About Phone', 7 times in rapid succession]
  4. Phone: Search for 'Default USB Configuration' in 'Developer Options'. Set it to 'USB Tethering'
  5. Phone: Permanently turn off your screen lock (PIN or pattern etc). The phone must be unlocked for USB Tethering to turn on automatically when the router is booting-up, with the phone plugged in & powered-up from the Router USB port. A locked phone will not tether when the router's USB interface turns on.
    • (Alternative, not tested) Use Android's Smart Lock feature to automatically unlock your phone.
  6. Router: Services, USB: Enable 'Core USB Support'. Apply.
  7. Phone: USB Tethering should now turn on automatically. Check to make sure this is happening.
    You can press Cancel or simply ignore the pop-up that appears asking what USB connection mode the phone should use. It will have USB tethering turned-on either way at this point.
  8. Router: Telnet into the router. Run the following commands:
    Press Enter after each command. insmod commands will insert modules quietly, and not report success.
    1. cd /lib/modules/$(uname -r)
    2. ls -a (check for presence of usbnet.ko, cdc_ether.ko, rndis_host.ko)
    3. cd (you do NOT need to be in the modules directory to execute the following)
    4. insmod usbnet.ko
    5. insmod cdc_ether.ko
    6. insmod rndis_host.ko
      Use the command 'lsmod' to verify the modules usbnet, cdc_ether and rndis_host are running.
    7. ifconfig usb0 up
    8. udhcpc -i usb0
      You should be able to 'ping google.com' now from within the telnet interface, but not yet on any connected client devices. Noobs: CTRL-C to stop pinging.
    9. iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
    10. iptables -A FORWARD -i br0 -j ACCEPT
      You should now be able to ping google.com from any client devices.
    11. Set the following: further corrects potential MTU issues when connecting a phone to a router (not only DD-WRT!):
      iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
    12. (Optional: Not tested)If you are trying to hide tethering:
      iptables -t mangle -I POSTROUTING -o `get_wanface` -j TTL --ttl-set 65
      iptables -t mangle -I PREROUTING -i `get_wanface` -j TTL --ttl-set 65
    13. Fully test your apps, websites and other services on all your connected clients.
      Everything should be working at this point.
      • To make the router configure automatically on bootup, you can automate it by adding the following lines to the Startup script:
    14. Go to the tab Administration, Commands.
    15. Paste: [these are the commands you used above]
      insmod usbnet.ko
      insmod cdc_ether.ko
      insmod rndis_host.ko
      ifconfig usb0 up
      udhcpc -i usb0
      sleep 5
    16. Click 'Save Startup'.
    17. Paste:
      iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
      iptables -A FORWARD -i br0 -j ACCEPT
      iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
    18. Click 'Save Firewall'.
    19. Click on (Administration) Management. Click 'Save'. Then 'Reboot Router'.
    20. You may have to reboot the router if you make configuration changes.


Again, everything should be working at this point. You are finished with this guide. Thank you!

Credits: Users sydlexia and shenoyh on the forums for the source information.

See link: https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1128616#1128616

USB Modem [Use dongle that contains a SIM]

There are newer methods, integrated into the firmware than the previous version of this wiki. The relevant threads: K26 NEWD-2 Mega/Big builds starting with 14414 now have the 3G/UTMS WAN connection option built into the firmware.

See the following thread for more information:

http://www.dd-wrt.com/phpBB2/viewtopic.php?t=69970

See also http://www.dd-wrt.com/wiki/index.php/Mobile_Broadband for a list of directly supported device in K26 and K3.x builds.