Posts Tagged dlink

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.

#!/usr/bin/ruby
require 'net/telnet'
require 'optparse'

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

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

server = Net::Telnet::new('Host'=>host,
                          'Port'=> 23,
                          'Timeout'=>25,
                          'Prompt'=> />/)
server.waitfor(/ogin:/)
server.print("admin\n")
server.waitfor(/ssword:/)
server.print("#{passwd}\n")
server.cmd("adsl connection --down")
server.cmd("adsl connection --up")
server.cmd("logout")

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.

, ,

Leave a comment

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: