Cellular Phone/USB Modem as WAN connection

From DD-WRT Wiki

Revision as of 08:46, 12 April 2020 by S2s2 (Talk | contribs)
Jump to: navigation, search

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)

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: connect to router's USB port
  2. Turn on Developer Options
  3. Search for 'Default USB Configuration'. Set it to 'USB Tethering'
  4. 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 is plugged in & powered-up from the Router USB port.
  5. Router: Services, USB: Enable 'Core USB Support'. Apply.
  6. Phone: USB Tethering will turn on automatically. Check to make sure this is happening.
  7. Telnet into the router. Run the following commands:
    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
    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.

If the above works for you, then you can automate it by adding the following lines to the Startup script:
1. Go to tab Administration, Commands.
2. Paste:
cd /lib/modules/x.x.xxx #change these values 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

You may also need to add:

  • 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
  • If you have problems with some websites not working correctly [MTU issues]:
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
You may also have to specify a smaller MTU in the main router Setup page.

3. Click 'Save Startup'.

Alternatively, you can break the iptables commands out into the Firewall script. But I haven't gotten it to work (no connectivity after Applying changes)

4. For good measure, click on (Administration) Management. Click 'Save'. Then 'Reboot Router'

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:


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.