Access To Modem Configuration

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 06:33, 29 March 2010 (edit)
Ikonst (Talk | contribs)
(The way to follow - Oops :))
← Previous diff
Revision as of 20:42, 30 March 2010 (edit) (undo)
Phuzi0n (Talk | contribs)
(Using a virtual interface in ifconfig is crucial to allowing simultaneous access to the internet and the modem configuration.)
Next diff →
Line 5: Line 5:
In this case the router itself creates the PPPoE connection to the ISP server; but to work, the connection between the modem and the router must have an IP address. Usually the modem gives an address to the client; but this address will never be used except to access the configuration interface of the modem. In this case the router itself creates the PPPoE connection to the ISP server; but to work, the connection between the modem and the router must have an IP address. Usually the modem gives an address to the client; but this address will never be used except to access the configuration interface of the modem.
-My modem is a Speedtouch 510, is IP address is 10.0.0.138 and it gives the 10.0.0.1 address to the device connected to it. The easiest way to know these addresses is to connect the modem directly to your computer and take a look at your network card configuration. The default gateway is the Modem address and the Card address is the one provided by the modem. It should be noted that a lot of modems come preconfigured to use the 192.168.1.x IP range. This will need to be changed for this to work.+My modem is a Speedtouch 510, is IP address is 10.0.0.138 and it gives the 10.0.0.1 address to the device connected to it. The easiest way to know these addresses is to connect the modem directly to your computer and take a look at your network card configuration. The default gateway is the Modem address and the Card address is the one provided by the modem. It should be noted that a lot of modems come configured to use the 192.168.1.x IP range. This will need to be changed for this to work.
So it looks like this. So it looks like this.
Line 14: Line 14:
=== The way to follow === === The way to follow ===
 +'''Replace the 10.0.0.1 with the address for the router to use to access the modem (ie. if your modem's address is 10.0.0.1 then assign something else for the router)'''
* Go to Administration -> Commands * Go to Administration -> Commands
* Enter * Enter
- ifconfig $(nvram get wan_ifname) 10.0.0.2 netmask 255.255.255.0+ ifconfig `nvram get wan_ifname`:0 10.0.0.1 netmask 255.255.255.0
and click on ''Save Startup'' and click on ''Save Startup''
* Enter * Enter
- /usr/sbin/iptables -t nat -I POSTROUTING 1 -o $(nvram get wan_ifname) -j MASQUERADE+ iptables -t nat -I POSTROUTING -o `nvram get wan_ifname` -j MASQUERADE
and click on ''Save Firewall'' and click on ''Save Firewall''
Line 25: Line 26:
'''Notes:''' '''Notes:'''
-# The IP address (in the example, 10.0.0.2) should be different from the IP address used by your modem. For example, if your modem uses the address 10.0.0.138, the IP address 10.0.0.2 will be good.+# `nvram get wan_ifname` gets the WAN port of your router automatically. If you wish to enter it manually, you should run '''echo `nvram get wan_ifname`''' to get your WAN interface name.
-#* A "cleaner" solution is to use DHCP, but this is out of the scope of this tutorial.+
-# $(nvram get wan_ifname) gets the WAN port of your router automatically. If you wish to enter it manually, you should use the following command to get your WAN interface name:+
- nvram get wan_ifname+
====Alternative way==== ====Alternative way====
-A alternative (and cleaner) way to execute the above commands on startup is the following:+An alternative way to execute the above commands on startup if you have JFFS enabled is the following:
-* Log in via ssh (or telnet)+* Log in via ssh/telnet
* create a file with the following content: * create a file with the following content:
#!/bin/sh #!/bin/sh
- ifconfig $(nvram get wan_ifname) 10.0.0.2 netmask 255.255.255.0+ ifconfig `nvram get wan_ifname`:0 10.0.0.1 netmask 255.255.255.0
* save it as "/jffs/etc/config/modem.startup" * save it as "/jffs/etc/config/modem.startup"
* create another file with the following content: * create another file with the following content:
#!/bin/sh #!/bin/sh
- /usr/sbin/iptables -t nat -I POSTROUTING 1 -o $(nvram get wan_ifname) -j MASQUERADE+ iptables -t nat -I POSTROUTING -o `nvram get wan_ifname` -j MASQUERADE
* save it as "/jffs/etc/config/modem.wanup" * save it as "/jffs/etc/config/modem.wanup"
-* make them executables:+* make them executable:
chmod +x /jffs/etc/config/modem.* chmod +x /jffs/etc/config/modem.*

Revision as of 20:42, 30 March 2010

Contents


Case of a Bridged modem

Presentation

In this case the router itself creates the PPPoE connection to the ISP server; but to work, the connection between the modem and the router must have an IP address. Usually the modem gives an address to the client; but this address will never be used except to access the configuration interface of the modem.

My modem is a Speedtouch 510, is IP address is 10.0.0.138 and it gives the 10.0.0.1 address to the device connected to it. The easiest way to know these addresses is to connect the modem directly to your computer and take a look at your network card configuration. The default gateway is the Modem address and the Card address is the one provided by the modem. It should be noted that a lot of modems come configured to use the 192.168.1.x IP range. This will need to be changed for this to work.

So it looks like this.

image:access.to.modem.png

By default if you type the IP address of the modem you have an "Impossible to contact the server" error.

The way to follow

Replace the 10.0.0.1 with the address for the router to use to access the modem (ie. if your modem's address is 10.0.0.1 then assign something else for the router)

  • Go to Administration -> Commands
  • Enter
ifconfig `nvram get wan_ifname`:0 10.0.0.1 netmask 255.255.255.0

and click on Save Startup

  • Enter
iptables -t nat -I POSTROUTING -o `nvram get wan_ifname` -j MASQUERADE

and click on Save Firewall

Notes:

  1. `nvram get wan_ifname` gets the WAN port of your router automatically. If you wish to enter it manually, you should run echo `nvram get wan_ifname` to get your WAN interface name.

Alternative way

An alternative way to execute the above commands on startup if you have JFFS enabled is the following:

  • Log in via ssh/telnet
  • create a file with the following content:
#!/bin/sh 
ifconfig `nvram get wan_ifname`:0 10.0.0.1 netmask 255.255.255.0
  • save it as "/jffs/etc/config/modem.startup"
  • create another file with the following content:
#!/bin/sh 
iptables -t nat -I POSTROUTING -o `nvram get wan_ifname` -j MASQUERADE
  • save it as "/jffs/etc/config/modem.wanup"
  • make them executable:
chmod +x /jffs/etc/config/modem.*