Cellular Phone/USB Modem as WAN connection

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 09:56, 4 April 2020 (edit)
S2s2 (Talk | contribs)
m (added note on private range from wan/firewall)
← Previous diff
Revision as of 18:00, 4 April 2020 (edit) (undo)
S2s2 (Talk | contribs)
(reduce complexity, optimize)
Next diff →
Line 3: Line 3:
=Main Guide [Updated 3/2020]= =Main Guide [Updated 3/2020]=
-USB Tethering with an Android phone, or using a USB Modem dongle, on your DD-WRT enabled router.+USB Tethering with an Android phone, or USB Modem dongle, on your DD-WRT enabled router.
==USB Phone Tethering== ==USB Phone Tethering==
Line 11: Line 11:
Phone: Verizon Visible R2 (ZTE) $19 phone with a $40/m completely unlimited LTE-only pre-pay<br> Phone: Verizon Visible R2 (ZTE) $19 phone with a $40/m completely unlimited LTE-only pre-pay<br>
-Router: Linksys EA6400 running DD-WRT v3.0-r37012 std (09/21/18)<br>+Router: Linksys EA6400 running DD-WRT v3.0-r37012 std (2018/09/21) and also worked with r42819 (2020/03/30)
-Note: I had not used the router in awhile, and had no reason to upgrade the firmware. This was written when this wiki was updated (2020/04).<br>+Note: I had not used the router in awhile, and had no reason to immediately upgrade the firmware. <br>
'''This assumes you have reset your router FIRST'''. If you have an existing custom config, back it up, then reset the router, and test this out. If you can get it working from a reset router, then you'll have to figure out what you need to do after reloading your custom config if it does not work. '''This assumes you have reset your router FIRST'''. If you have an existing custom config, back it up, then reset the router, and test this out. If you can get it working from a reset router, then you'll have to figure out what you need to do after reloading your custom config if it does not work.
-#Services, USB: Enable 'Core USB Support' and 'USB over IP' (not sure if the 2nd is necessary, but it works when On). Apply.+#Phone: Turn on your Android Developer Options
 +#Search for 'Default USB Configuration'. Set it to 'USB Tethering'
 +#Turn off your screen lock (PIN or pattern etc). [testing this]. The phone must be unlocked for USB Tethering to turn on automatically.
 +#Router: Services, USB: Enable 'Core USB Support'. Apply.
#Android phone connected to router's USB port #Android phone connected to router's USB port
-#Turn on USB Tethering in the phone. (Settings, Network & Internet, Hotspot & Tethering)+#Phone: USB Tethering will turn on automatically.
-#*Phone will not allow USB Tethering to be turned-on, <u>until it has power from the USB Port on the router. There will be no power until the 'Core USB Support' is turned on and applied</u>.+
#Telnet into the router. Run the following commands: #Telnet into the router. Run the following commands:
-##<tt>cd /lib/modules/4.4.157</tt>+##<tt>cd /lib/modules/build</tt>
-##*The last folder, <tt>.../4.4.157</tt>, will vary in name, depending on the kernel build (your version of DD-WRT).+##*The last folder, e,g, <tt>.../4.4.157</tt>, will vary in name, depending on the build/version of DD-WRT.
##*''For noobs: do a <tt>cd /lib/modules</tt>, then an <tt>ls</tt> to see what the name of the folder is. Or look in Status tab.'' ##*''For noobs: do a <tt>cd /lib/modules</tt>, then an <tt>ls</tt> to see what the name of the folder is. Or look in Status tab.''
##<tt>insmod usbnet.ko</tt> ##<tt>insmod usbnet.ko</tt>
Line 31: Line 33:
##*You should be able to '<tt>ping google.com</tt>' now from within the telnet interface, but not yet on any connected client devices. ''Noobs: CTRL-C to stop pinging.'' ##*You should be able to '<tt>ping google.com</tt>' now from within the telnet interface, but not yet on any connected client devices. ''Noobs: CTRL-C to stop pinging.''
##<tt>iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE</tt> ##<tt>iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE</tt>
-##*If you notice that your WAN IP (IP from the Cellular Phone) is in a private range (e.g. 192.168.x.x), then instead of doing line/step 8, you may instead want to simply turn-off the router's firewall (Security, SPI Firewall: Disable), as that reduces complexity. 
##<tt>iptables --append FORWARD --in-interface br0 -j ACCEPT</tt> ##<tt>iptables --append FORWARD --in-interface br0 -j ACCEPT</tt>
Line 38: Line 39:
If the above works for you, then you can automate it by adding the first 6 lines to the Startup script: If the above works for you, then you can automate it by adding the first 6 lines to the Startup script:
#Go to tab Administration, Commands. #Go to tab Administration, Commands.
-#Insert <code>sleep 10</code> as the first line. 
#Add above commands number 1 through 6, into the Commands box. #Add above commands number 1 through 6, into the Commands box.
#Click 'Save Startup'. #Click 'Save Startup'.
Line 44: Line 44:
#For good measure, click on (Administration) Management. Click 'Save'. Then: #For good measure, click on (Administration) Management. Click 'Save'. Then:
#Reboot router, '''while''' #Reboot router, '''while'''
-#On your phone, pay attention to the USB Tethering slider. It will be off, and you will not be able to turn it on, until the router boots far enough that Core USB Services are turned back on as part of it's startup. (~10 to 25 seconds) 
-#<u>When you see the option for USB Tethering is no longer greyed-out</u>, slide the switch to turn it on. 
-#*''Noobs: This is why <code>sleep 10</code> was added to the Startup script. It gives you time to turn on USB Tethering.'' 
-#*Note: the slider switch for tethering may 'bounce', appear to turn off for a split second, but then will turn back on. That is 'normal android behaviour'. You may also get a pop-up for the connection method of the phone. Just click on MTP (or another selection) and the pop-up will go away. 
''Credits: Users sydlexia and shenoyh on the forums.<br> ''Credits: Users sydlexia and shenoyh on the forums.<br>

Revision as of 18:00, 4 April 2020


Main Guide [Updated 3/2020]

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

USB Phone Tethering

Tethering your DD-WRT router to an Android phone?

Here is a Step-by-Step, I did with a $40/m unlimited plan and a $5 router

Phone: Verizon Visible R2 (ZTE) $19 phone with a $40/m completely unlimited LTE-only pre-pay
Router: Linksys EA6400 running DD-WRT v3.0-r37012 std (2018/09/21) and also worked with r42819 (2020/03/30) Note: I had not used the router in awhile, and had no reason to immediately upgrade the firmware.

This assumes you have reset your router FIRST. If you have an existing custom config, back it up, then reset the router, and test this out. If you can get it working from a reset router, then you'll have to figure out what you need to do after reloading your custom config if it does not work.

  1. Phone: Turn on your Android Developer Options
  2. Search for 'Default USB Configuration'. Set it to 'USB Tethering'
  3. Turn off your screen lock (PIN or pattern etc). [testing this]. The phone must be unlocked for USB Tethering to turn on automatically.
  4. Router: Services, USB: Enable 'Core USB Support'. Apply.
  5. Android phone connected to router's USB port
  6. Phone: USB Tethering will turn on automatically.
  7. Telnet into the router. Run the following commands:
    1. cd /lib/modules/build
      • The last folder, e,g, .../4.4.157, will vary in name, depending on the build/version of DD-WRT.
      • For noobs: do a cd /lib/modules, then an ls to see what the name of the folder is. Or look in Status tab.
    2. insmod usbnet.ko
    3. insmod cdc_ether.ko
    4. insmod rndis_host.ko
    5. ifconfig usb0 up
    6. 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.
    7. iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE
    8. iptables --append FORWARD --in-interface br0 -j ACCEPT

You should now be able to also ping google.com from any client devices.

If the above works for you, then you can automate it by adding the first 6 lines to the Startup script:

  1. Go to tab Administration, Commands.
  2. Add above commands number 1 through 6, into the Commands box.
  3. Click 'Save Startup'.
  4. Paste commands 7 & 8 (iptables commands) into Commands, then click 'Save Firewall'.
  5. For good measure, click on (Administration) Management. Click 'Save'. Then:
  6. Reboot router, while

Credits: Users sydlexia and shenoyh on the forums.

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

USB Modem: dongle

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.