Community discussions

MikroTik App
 
User avatar
eben
Member
Member
Topic Author
Posts: 479
Joined: Mon Feb 16, 2009 8:37 pm
Location: Somerset West, South Africa
Contact:

Script to telnet into another router

Thu Mar 24, 2011 9:15 am

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.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6048
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Script to telnet into another router

Thu Mar 24, 2011 9:31 am

It is not possible directly form routeros. You need to run expect script from linux or windows machine.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Script to telnet into another router

Thu Mar 24, 2011 10:23 am

that cannot be done using scripting. you could try some external box with expect scripting.
 
User avatar
AnRkey
Member Candidate
Member Candidate
Posts: 119
Joined: Tue Sep 15, 2009 6:01 pm

Re: Script to telnet into another router

Wed Apr 06, 2011 12:17 am

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= ... odo=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 :)

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.
MTCNA
 
cieplik206
Trainer
Trainer
Posts: 290
Joined: Sun Jul 01, 2007 12:25 am
Contact:

Re: Script to telnet into another router

Fri Apr 08, 2011 11:10 am

that cannot be done using scripting. you could try some external box with expect scripting.
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 ?
https://www.wispcasts.com - Mikrotik Video Tutorials.

The best place where you can improve your skills!

Facebook - F/wispcasts
Twitter - @wispcasts
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6048
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Script to telnet into another router

Fri Apr 08, 2011 11:16 am

Who is online

Users browsing this forum: No registered users and 16 guests