Script to telnet into another router

I’ve got a problem with a client’s setup where his ADSL connection keeps on dropping.

He seems to be borderline with regard to distance to the DSLAM. For some reason, traffic will just stop on his connection. If he then reboots the ADSL router, traffic returns. ie. He needs to drop the physical ADSL and as soon as the ADSL reconnects, traffic flows again.

I’ve tried three different types of ADSL router so I know it’s not a hardware issue.
I’ve tried them in bridge mode as well as in “normal” mode where they handle the authentication.

I’ve settled on the RB750 doing the PPPOE connection with the ADSL router in bridge mode.

There is always some sort of traffic going back and forth on the ADSL. It’s used in a factory where they run 24x7 and I’m getting grumpy about 3:00am support calls telling me the internet’s been down for the past half an hour.

What I need to do is develop a script that’ll first check the traffic on the PPPOE connection.

If that is “0” then it needs to telnet into the router and send it the admin user name, wait a couple of seconds, send the password, wait a couple of seconds and send “reboot”, then wait 60 seconds while the router reboots and re-establishes the ADSL connection.

My plan would be to then set up a scheduled task to run the script every 10 minutes or so.

It’s all quite simple. I just don’t know that much about the scripting side. Ask me to set up a 50km link and I’ll do it, but ask me to write a simple script and I’m lost.

Any advice would be appreciated.

Thank you.

It is not possible directly form routeros. You need to run expect script from linux or windows machine.

that cannot be done using scripting. you could try some external box with expect scripting.

Use a Netgear DG834 v4 router/modem in bridge mode.

Then add a script to the MT called “reboot modem”

Add this code to the script: /tool fetch url=“http://192.168.0.1/setup.cgi?next_file=diag.htm&todo=reboot” user=admin password=password ;

Schedule the script to run as needed or merge with yours. BTW: copying the line to console won’t work, MT cuts out the ? in the line for some reason. This is why I save it to a script to use it.

Change the code to suite your needs and change the login and password to that of the netgear. Also remember, if the MT can’t reach the netgear then this won’t work so remember your address on the interface of the MT that the modem is on.

Hope this helps, let me know if it doesn’t because I love problems like this :slight_smile:

MT FTW!

R

PS: About that ADSL issue, ask the ISP to drop the line speed slightly for a more stable line. The lower line speed will give you more wiggle room on the margin between noise and clean signal.

Sorry for offtopic janis but did you have a template for expect that works well with colors in termina in RouterOS ? or how to disable colors ?

http://wiki.mikrotik.com/wiki/Manual:Console_login_process#Console_login_options