Cellular Phone/USB Modem as WAN connection

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 10:24, 14 April 2020 (edit)
S2s2 (Talk | contribs)
m (minor layout)
← Previous diff
Revision as of 23:07, 3 May 2020 (edit) (undo)
S2s2 (Talk | contribs)
(Layout improvements.)
Next diff →
Line 2: Line 2:
__FORCETOC__ __FORCETOC__
-=Main Guide [Updated 3/2020]=+=Main Guide [Updated 5/2020]=
USB Tethering with an Android phone, or using a USB Modem, on your DD-WRT-enabled router. USB Tethering with an Android phone, or using a USB Modem, on your DD-WRT-enabled router.
Line 14: Line 14:
Router: Linksys EA6400 running DD-WRT v3.0-r37012 std (2018/09/21) and also works with r42819 (2020/03/30) Router: Linksys EA6400 running DD-WRT v3.0-r37012 std (2018/09/21) and also works with r42819 (2020/03/30)
-'''Requirements:'''<br>+==='''Requirements:'''===
-1. '''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. '''This assumes you have saved your existing Router settings first''', before resetting your router and testing the USB Tethering settings. If you've done some custom config since flashing your router, 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.
-2. '''This also assumes that the build you downloaded and flashed of DD-WRT, has the modules <tt>cdc_ether.ko</tt> and <tt>rndis_host.ko</tt>''' If it does not, you may need either: a larger version of DD-WRT that includes them, or to reflash over to OpenWRT. They are -very small- modules (8kb) but are not included on some larger builds for some routers. ''Noobs: These instructions walk you through how to figure out if the modules exist.''+2. '''Make sure the necessary modules exist on your build:''' 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 <tt>cdc_ether.ko</tt> and <tt>rndis_host.ko</tt>, which are not present on some builds (regardless of build size). If they do not, 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.
-'''Steps:'''+==='''Steps:'''===
-#Phone: connect to router's USB port+#Router: Main configuration page: leave WAN on Automatic DHCP. Set the MTU manually to 1200 [https://forum.xda-developers.com/showthread.php?t=997116]. Set your timezone. Save & Apply.
-#Turn on your phone's Developer Options: [Click 'Build Number' in 'About Phone', 7 times in rapid succession]+#Phone: connect it to router's USB port with a USB cable you've already used for successful tethering with your laptop.
-#Search for 'Default USB Configuration' in 'Developer Options'. Set it to 'USB Tethering'+#Phone: Turn on your phone's Developer Options: [Click 'Build Number' in 'About Phone', 7 times in rapid succession]
-#Use Android's Smart Lock feature to automatically unlock your phone, or 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, the phone plugged in & powered-up from the Router USB port.+#Phone: Search for 'Default USB Configuration' in 'Developer Options'. Set it to 'USB Tethering'
 +#Phone: Use Android's Smart Lock feature to automatically unlock your phone, or '''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.
#Router: Services, USB: Enable 'Core USB Support'. Apply. #Router: Services, USB: Enable 'Core USB Support'. Apply.
#Phone: USB Tethering will turn on automatically. '''Check to make sure this is happening.''' #Phone: USB Tethering will turn on automatically. '''Check to make sure this is happening.'''
-#Telnet into the router. Run the following commands:+#Router: Telnet into the router. Run the following commands:
-##<tt>cd /lib/modules/...</tt> where '...' is your kernel version+#: Press Enter after each command. <tt>insmod</tt> commands will insert modules quietly, and not report success.
 +##<tt>cd /lib/modules/... </tt>
 +##:where '...' is your kernel version
##:The last folder, e,g, <tt>.../4.4.157</tt>, will vary in name, depending on the build of DD-WRT. ##:The last folder, e,g, <tt>.../4.4.157</tt>, will vary in name, depending on the build 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.''
Line 39: Line 42:
##<tt>iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE</tt> ##<tt>iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE</tt>
##<tt>iptables --append FORWARD --in-interface br0 -j ACCEPT</tt> ##<tt>iptables --append FORWARD --in-interface br0 -j ACCEPT</tt>
-##:You should now be able to <tt>ping google.com</tt> from any client devices.+##:You should now be able to <tt>ping google.com</tt> from any client devices.
 +##Set the following: further corrects potential MTU issues when connecting a phone to a router (not only DD-WRT!):<br>
 +##: <code>iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu</code>
 +##(Optional: Not tested)If you are trying to hide tethering (not tested):<br>
 +##: <code>iptables -t mangle -I POSTROUTING -o `get_wanface` -j TTL --ttl-set 65<br>
 +##: iptables -t mangle -I PREROUTING -i `get_wanface` -j TTL --ttl-set 65</code><br>
-If the above works for you, then you can automate it by adding the following lines to the Startup script:<br>+::'''Everything should be working at this point.'''
-1. Go to the tab <tt>Administration</tt>, <tt>Commands</tt>.<br>+
-2. Paste:<br>+
-<code>+
-cd /lib/modules/x.x.xxx #change these values based on your kernel build<br>+
-insmod usbnet.ko<br>+
-insmod cdc_ether.ko<br>+
-insmod rndis_host.ko<br>+
-ifconfig usb0 up<br>+
-udhcpc -i usb0<br>+
-iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE<br>+
-iptables --append FORWARD --in-interface br0 -j ACCEPT</code>+
-You may also need to add:+::To make the router configure automatically on bootup, you can automate it by adding the following lines to the Startup script:<br>
-* If you are trying to hide tethering:<br>+<ol start="11">
-: <code>iptables -t mangle -I POSTROUTING -o `get_wanface` -j TTL --ttl-set 65<br>+::<li>Go to the tab <tt>Administration</tt>, <tt>Commands</tt>.</li>
-: iptables -t mangle -I PREROUTING -i `get_wanface` -j TTL --ttl-set 65</code><br>+::<li>Paste:</li>
-* If you have problems with some websites not working correctly [MTU issues]:<br>+::<code>cd /lib/modules/x.x.xxx #change these values x, exactly as you did above, based on your kernel build<br>
-: <code>iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu</code>+::insmod usbnet.ko<br>
-: You may also have to specify a smaller MTU in the main router Setup page.+::insmod cdc_ether.ko<br>
 +::insmod rndis_host.ko<br>
 +::ifconfig usb0 up<br>
 +::udhcpc -i usb0<br>
 +::iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE<br>
 +::iptables --append FORWARD --in-interface br0 -j ACCEPT</code>
 +::iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
 +::<li> Click 'Save Startup'.</li>
 +::*Alternatively, (not tested) you could break out the iptables commands into the Firewall script. But I haven't gotten it to work (no connectivity after Applying changes). Instead, reboot the router after making personal additional changes.<br>
 +::<li> Click on (Administration) Management. Click 'Save'. Then 'Reboot Router'.</li>
 +</ol>
-3. Click 'Save Startup'.<br>+::'''Again, everything should be working at this point.'''
-: Alternatively, you could break out the iptables commands into the Firewall script. But I haven't gotten it to work (no connectivity after Applying changes). Usually, just reboot the router after making additional changes.<br>+
-4. Click on (Administration) Management. Click 'Save'. Then 'Reboot Router'.+
-''Credits: Users sydlexia and shenoyh on the forums.<br>+''Credits: Users sydlexia and shenoyh on the forums for the source information.<br>
See link: https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1128616#1128616 See link: https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1128616#1128616

Revision as of 23:07, 3 May 2020


Contents

Main Guide [Updated 5/2020]

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

USB Phone Tethering [Attach a phone via USB to a router]

Tethering your DD-WRT router to an Android phone?

Here is a Step-by-Step, 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 works with r42819 (2020/03/30)

Requirements:

1. This assumes you have saved your existing Router settings first, before resetting your router and testing the USB Tethering settings. If you've done some custom config since flashing your router, 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.

2. Make sure the necessary modules exist on your build: 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). If they do not, 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.

Steps:

  1. Router: Main configuration page: leave WAN on Automatic DHCP. Set the MTU manually to 1200 [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: Use Android's Smart Lock feature to automatically unlock your phone, or 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.
  6. Router: Services, USB: Enable 'Core USB Support'. Apply.
  7. Phone: USB Tethering will turn on automatically. Check to make sure this is happening.
  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/...
      where '...' is your kernel version
      The last folder, e,g, .../4.4.157, will vary in name, depending on the build 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
      Use the command 'lsmod' to verify the modules usbnet, cdc_ether and rndis_host are running.
    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 ping google.com from any client devices.
    9. 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
    10. (Optional: Not tested)If you are trying to hide tethering (not tested):
      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
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:
  1. Go to the tab Administration, Commands.
  2. Paste:
  3. cd /lib/modules/x.x.xxx #change these values x, exactly as you did above, based on your kernel build
    insmod usbnet.ko
    insmod cdc_ether.ko
    insmod rndis_host.ko
    ifconfig usb0 up
    udhcpc -i usb0
    iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE
    iptables --append FORWARD --in-interface br0 -j ACCEPT
    iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
  4. Click 'Save Startup'.
    • Alternatively, (not tested) you could break out the iptables commands into the Firewall script. But I haven't gotten it to work (no connectivity after Applying changes). Instead, reboot the router after making personal additional changes.
  5. Click on (Administration) Management. Click 'Save'. Then 'Reboot Router'.
Again, everything should be working at this point.

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.