Script for reconnect adsl in d-link router

In work I have wireless network with D-Link router “DSL-2640B”, and I need to reconnect ADSL service to change IP adress, so I write this ruby script, which use telnet standard libary.

require 'net/telnet'
require 'optparse'

opts = ARGV.getopts('h:p:')

passwd = opts['-p']
host = opts['-h']

server = Net::Telnet::new('Host'=>host,
                          'Port'=> 23,
                          'Prompt'=> />/)
server.cmd("adsl connection --down")
server.cmd("adsl connection --up")

You can use it in terminal by typing:

reconnect.rb -p <password> -h <host>

You must wait couple of seconds before your d-link router connect to ADSL.


, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: