D-Link DSL-604+ Wireless ADSL Router – Support Forum

Telnet Scripting for the DSL-604+ [D-Link DSL-604+ Wireless ADSL Router - 104294]

  • rperkin
  • Posts: 2535
  • Join Date: 12 August 2003
  • Location: UK
Over on the DSL-G604T forum I posted about how to use a Telnet script to execute commands on the router. For info, find that thread here. This post repeats some of the same information, but this time with emphasis on issuing Command Line Interface (CLI) commands for the DSL-604+ To use the technique, you will first need to have Telnet access to the router. Whether you have this already may depend on the firmware version you are running - if you don't have it, find info on how to enable Telnet here. This post documents how to automate the issuing of CLI commands, and gives some simple examples. The process is called Telnet Scripting. To use it you need: - a Telnet Scripting tool - a file containing Telnet commands (that is, a script file) The Telnet Scripting tool that I use is TST10.EXE, written by Albert Yale. It can be downloaded from here. [Note: if the link doesn't work, Google on "tst10.zip" for alternative download locations] Here's a trivial example of its use, a script to login to the DSL-604+ and display the help text:
192.168.0.1 23
WAIT "password:"
SEND "private\m"
WAIT ">"
SEND "help\m"
WAIT ">"
The script assumes the default IP address of the router (192.168.0.1) and the default login password (private). Change these to match your router settings. If the script were stored in the file help.txt then the command to issue it (assuming it is in the same directory as TST10.EXE) would be: tst10 /r:help.txt Info on the script syntax and the parameters of TST10.EXE can be found by running the program without any parameters. A small example of where this is useful is given below, and was prompted by a poster who wished to force other all other users off his network by running a program - see this thread. The technique for doing this is: - configure the 'master' PC with a static local IP address - set up two firewall filter rules using the router's Configuration | Advanced Filtering & Firewall screen, one to allow all traffic from the Internet to the local IP address of the 'master' PC, one to allow all outgoing traffic, and enable both rules - set the overall rules to 'If not matched = block' and 'IP Filter State = disabled' - write two scripts which will change the IP Filter State to either Enabled or Disabled When the state is Disabled, no rules are applied, and the router functions as normal. When the state is Enabled, all traffic which does not match the two rules is blocked - so only that PC with that specific IP address can send or receive any traffic. Here's the script to Enable the firewall rules, which I have saved in the file block_them.txt
192.168.0.1 23
WAIT "password:"
SEND "private\m"
WAIT ">"
SEND "ip_filter\m"
WAIT ">"
SEND "change global enable\m"
WAIT ">"
SEND "home\m"
WAIT ">"
SEND "@close\m"
CONTINUED...
  • rperkin
  • Posts: 2535
  • Join Date: 12 August 2003
  • Location: UK
...CONTINUED Here's the script to Disable the firewall rules, which I have saved in the file allow_them.txt 192.168.0.1 23 WAIT "password:" SEND "private\m" WAIT ">" SEND "ip_filter\m" WAIT ">" SEND "change global disable\m" WAIT ">" SEND "home\m" WAIT ">" SEND "@close\m" Edit the default IP address and password to match your installation. Run a command prompt, change to the directory with the script + program, and execute the specific script to achieve the desired effect with: tst10 /r:block_them.txt /m or tst10 /r:allow_them.txt /m You can also enter the above commands in a batch file, create a shortcut on the Windows desktop, and execute it with a click or two of the mouse. How easy do you want it to get? Here are copies of two trivial batch files for use under Windows, allow_them.bat and block_them.bat respectively which can be placed in the root directory of drive C: and then executed: echo off cls @echo *** Run Telnet script to allow Internet access to all *** cd \ tst10 /r:allow_them.txt /m echo off cls @echo *** Run Telnet script to deny Internet access to all but 'master' PC *** cd \ tst10 /r:block_them.txt /m Notes: 1. This has been tested, and the rules (see this thread for details) the scripts and the batch files work just fine. 2. The commands (for example, ip_filter change global disable) could be executed on a single line. However, I've structured it like this even in this simple example so that further ip_filter subcommands could be included, and also to force the CLI to the top level with the 'home' command. If this is not done, the next time the CLI is accessed it will be at the last subcommand level used. 3. The ip_filter command set is complex, and is not documented in any ATMOS manual that I have seen. It is possible to configure 4 sets each of 16 rules, and is probably a good example of where a Telnet script may be useful. The web-based interface only allows the configuring of set 1. You can extend this Telnet Scripting technique to do as many things as your ATMOS knowledge and the CLI in the DSL-604+ allows. Clearly this won't cover everything, but I'm sure you get the idea... Hope this helps
;