<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">

<channel>
<title>[HOWTO] Connecting to modem through router in TekSavvy</title>
<link>http://www.dslreports.com/forum/r20459971</link>
<description></description>
<language>en</language>
<pubDate>Thu, 03 Dec 2009 09:24:39 EDT</pubDate>
<lastBuildDate>Thu, 03 Dec 2009 09:24:39 EDT</lastBuildDate>

<item>
<title>[HOWTO] Connecting to modem through router</title>
<link>http://www.dslreports.com/forum/remark,20459971</link>
<description><![CDATA[<A HREF="/useremail/u/1530685"><b>mactalla</b></A> : This question has come up many times and always seems to be new for people.  So I'm making a whole new topic with appropriate subject so this can hopefully be found more easily via search, etc.  I will endever to keep this generic to all modem/router/firmware configurations yet also easy to follow step-by-step.  Corrections and improvements are welcome.<br><br><b>=== What ===</b><br>Modems often permit connecting to them via a web or telnet interface to configure or obtain useful information.  When a modem is plugged into a router which then is connected to the computers on the network, the modem cannot be accessed.  This How-to explains how to access the modem just like any other computer on the network.<br><br><b>=== Why ===</b><br>Especially on these forums, running DMT to connect to the modem (which is done via telnet) is a convenient way to get line stats.  This is useful both for an initial setup, but also to audit occasionally.  Unplugging the modem to connect directly to it at these times is both troublesome and disruptive to anyone else attempting to access the internet in the same home.<br><br><b>=== How ===</b><br><u>Preparation: A-C</u><br><br><b>A.</b> First, you need to be able to make changes to the routing. If you walk into your favourite computer store, buy a router and bring it home, you cannot make the necessary changes.  For this (and other) reasons, we have custom firmware.  Three popular firmwares are: DD-Wrt, OpenWrt and Tomato.<br><br>For more information on each of these, see their respective sites:<br>DD-Wrt: &raquo;<A HREF="http://www.dd-wrt.com" >www.dd-wrt.com</A><br>OpenWrt: &raquo;<A HREF="http://www.openwrt.org" >www.openwrt.org</A><br>Tomato: &raquo;<A HREF="http://www.polarcloud.com/tomato" >www.polarcloud.com/tomato</A><br><br><b>B.</b> Secondly, you need to know the IP address your modem will respond to.  We'll call this $MODEM_IP.<br>Some known modem IP's:<br>ST516: 192.168.1.254 and 10.0.0.138<br>2Wire: 192.168.1.254<br>DLink 300i: 192.168.1.1 (could be 192.168.0.1 -- I may have changed mine)<br><br><b>C.</b> Finally, you need to know the name of the interface on your router where your modem is plugged in.  The modem is usually plugged into the WAN port of the router.  See &raquo;wiki.openwrt.org/OpenWrtDocs/Configuration for a list of routers and their interface names.  We'll call this $WAN_IFACE.<br>The name of the WAN interface for a few common routers are:<br>Linksys WRT54GL: vlan1<br>Linksys WRTSL54GS: eth1<br>Asus WL-500g: eth1<br>Asus WL-500g Deluxe/Premium: vlan1<br><br>Once you have the information for your particular modem and router, we can configure the router.<br><br><u>Steps: 1-3</u><br><br><b>1.</b> First, we need to set the interface identified in '<b>C</b>' to an IP address that is on the same subnet. For example, if the modem is on 192.168.1.254, then we want 192.168.1.pick-a-number (where pick-a-number is not 254 (the modem), or 255 (broadcast), or any other machine on the network. 250 would likely be good. We'll call this $WAN_IP. The command "ipconfig $WAN_IFACE $WAN_IP" should do the trick.<br><br><b>2.</b> Now, we need to update the routing with these two commands:<br>iptables -A forwarding_rule -d $MODEM_IP -j ACCEPT<br>iptables -t nat -A POSTROUTING -d $MODEM_IP -j MASQUERADE<br><br><b>3.</b> And of course you want that to happen automatically anytime your router (re)boots. So make a script that does this and have it run on boot.<br><br>The exact location to place these commands differs depending on the firmware.<br><br>On DD-Wrt routers, place the script files in /jffs/etc/config/<br>This can be done by ssh'ing into the router and pasting the following lines to the console (set the values on lines 3, 4 and 8 to be correct for your setup):<br><textarea name="code" class="text" cols=50 rows=10>cd /jffs/etc/config/&#012;echo '#!/bin/sh' &gt; modem.startup&#012;echo 'WAN_IFACE="eth1" # Set this to the name of your WAN port found in step C' &gt;&gt; modem.startup&#012;echo 'WAN_IP="192.168.1.250" # Set this to the IP you selected in step 1' &gt;&gt; modem.startup&#012;echo 'ipconfig $WAN_IFACE $WAN_IP' &gt;&gt; modem.startup&#012;chmod +x modem.startup&#012;echo '#!/bin/sh' &gt; modem.wanup&#012;echo 'MODEM_IP="192.168.1.254" # Set this to the IP address of your modem found in step B' &gt;&gt; modem.wanup&#012;echo 'iptables -A forwarding_rule -d $MODEM_IP -j ACCEPT' &gt;&gt; modem.wanup&#012;echo 'iptables -t nat -A POSTROUTING -d $MODEM_IP -j MASQUERADE' &gt;&gt; modem.wanup&#012;chmod +x modem.wanup&#012;</textarea><!--end code block--><br><i>Note: the above is slightly modified from &raquo;<A HREF="http://www.dd-wrt.com/wiki/index.php/Access_To_Modem_Configuration" >www.dd-wrt.com/wiki/index.php/Ac&middot;&middot;&middot;guration</A> I would appreciate if anyone running DD-Wrt could confirm here that the above works correctly for you.</i><br><br>On OpenWrt routers, startup scripts are placed in /etc/init.d/ <br>SSH into the router and paste the following commands to the console (set the values on lines 9, 10 and 11 to be correct for your setup):<br><textarea name="code" class="text" cols=50 rows=10>cd /etc/init.d/&#012;echo '#!/bin/sh' &gt; S52modemroute&#012;echo '' &gt;&gt; S52modemroute&#012;echo '# Get the protocol of the WAN connection' &gt;&gt; S52modemroute&#012;echo 'WANPROTO="$(nvram get wan_proto)"' &gt;&gt; S52modemroute&#012;echo '' &gt;&gt; S52modemroute&#012;echo 'if &#91;  "$WANPROTO" = "pppoe" &#93;; then' &gt;&gt; S52modemroute&#012;echo '  # Static IP addresses for the modem and WAN device:' &gt;&gt; S52modemroute&#012;echo '  WAN_IFACE="eth1" # Set this to the name of your WAN port found in step C' &gt;&gt; S52modemroute&#012;echo '  WAN_IP="192.168.1.250" # Set this to the IP you selected in step 1' &gt;&gt; S52modemroute&#012;echo '  MODEM_IP="192.168.1.254" # Set this to the IP address of your modem found in step B' &gt;&gt; S52modemroute&#012;echo '' &gt;&gt; S52modemroute&#012;echo '  # Assign a static IP address to the WAN interface' &gt;&gt; S52modemroute&#012;echo '  ipconfig $WAN_IFACE $WAN_IP' &gt;&gt; S52modemroute&#012;echo '' &gt;&gt; S52modemroute&#012;echo '  # Create firewall rules' &gt;&gt; S52modemroute&#012;echo '  iptables -A forwarding_rule -d $MODEM_IP -j ACCEPT' &gt;&gt; S52modemroute&#012;echo '  iptables -t nat -A POSTROUTING -d $MODEM_IP -j MASQUERADE' &gt;&gt; S52modemroute&#012;echo 'fi' &gt;&gt; S52modemroute&#012;chmod +x S52modemroute&#012;</textarea><!--end code block--><br><i>Note: this works for WhiteRussian. I don't know whether the script needs to be modified for Kamizake -- the only part that might is whether pppoe is still detected via nvram.</i><br><br>On Tomato routers... could someone chime in here?  Where do scripts belong?<br><br>If you've read this far, hopefully it was helpful.  Again, corrections/improvements are welcome!]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,20459971</guid>
<pubDate>Sat, 10 May 2008 00:21:03 EDT</pubDate>
</item>

</channel>
</rss>
