LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 10-11-2007, 05:41 PM   #1
leosgb
Member
 
Registered: Nov 2004
Location: Brazil
Distribution: Gentoo
Posts: 363

Rep: Reputation: 31
Is there a way to reboot a router when connections isnt working?


Hi all,

I have a web server and sometimes it goes offline because of some sort of DSL problem. All I need to do is to go there and reboot my modem and sometimes my router and it is back up again.

I wonder if anyone knows of a way to automate this process. Something like the server would monitor the network status, say ping some address at regular intervals, and if it doenst get a reply it would send a command to the modem and router (maybe control a switch that would reset them both at the same time.

This is not a linux questions but since I will implement any control for my server, that is a Gentoo machine I thought this is an appropriate forum.

Any ideas? Thank you.
 
Old 10-11-2007, 06:59 PM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
If you can reboot the router/modem by sending it a signal over the network, then sure. It is a matter of working out how to use the command-line to do this and putting it in a script.

Unfortunately, the exact commands depends on your HW. Some routers/modems allow connect via ssh - in which case it should be easy. Most insist on html - and mine offers web-pages that insist on javascript where simple hrefs are all that is required.

These are trickier.

The script is the hard part. Checking to make sure the things are running and setting up thu cron-job is the easy bit.

For a web-server, you are much much better off fixing the trouble and/or replacing the offending HW.
 
Old 10-11-2007, 07:17 PM   #3
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
If your router/modem supports SNMP then it would be easy to make a script to query the status and then react to it by sending an SNMP request to reboot.
 
Old 10-11-2007, 11:33 PM   #4
leosgb
Member
 
Registered: Nov 2004
Location: Brazil
Distribution: Gentoo
Posts: 363

Original Poster
Rep: Reputation: 31
How can I find out if my router and my modem can do that? Once I arrived at home I found out that today's problem was a quick power outage we experienced. And my modem was configured with the incorrect user name... But I still want to be able to reboot both of them in the event of a DSL problem. I am looking at the SNMP stuff now. Thanks for the tip!
 
Old 10-12-2007, 12:41 AM   #5
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 43
I would consider getting a good UPS to put your router/modem and PC on. That way if the power blips for a few seconds you wont lose your router/modem. Also it will give you a chance to shutdown your PC or have it shutdown automatically in case of power failure.
 
Old 10-13-2007, 10:21 AM   #6
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
You will have to check with the Manufacturer's specs.
There would also be some SNMP configuration screen somewhere (to configure communities) if it did support it.

Note that most routers support only SNMP traps and not management.
 
Old 10-14-2007, 07:59 AM   #7
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
Thought you might be interested in this (Remote Power Management):

http://www.avocent.co.uk/web/uk.nsf/...PC400_European
 
Old 10-29-2007, 01:44 PM   #8
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 51
Quote:
Originally Posted by Simon Bridge View Post
If you can reboot the router/modem by sending it a signal over the network, then sure. It is a matter of working out how to use the command-line to do this and putting it in a script.

Unfortunately, the exact commands depends on your HW. Some routers/modems allow connect via ssh - in which case it should be easy. Most insist on html - and mine offers web-pages that insist on javascript where simple hrefs are all that is required.

These are trickier.

The script is the hard part. Checking to make sure the things are running and setting up thu cron-job is the easy bit.

For a web-server, you are much much better off fixing the trouble and/or replacing the offending HW.
Hi, I am encountering too that problem, that the router shoould be rebooted. I am using the computer and suddenly nthg. Go to the router, unplug the electric. plug and replug, working then.

So, my question :

Code:
Have you got a script as example, then we could google that with some m ore clear ideas ?
Thank you !
 
Old 10-29-2007, 02:38 PM   #9
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
As Simon Bridge said, checking to see if the connection is working is the easy bit.
The difficult question is "What do you do if it is not working?".

For example: The modem /router has experienced a power glitch. If it is still in a sane state, most can be configured to re-establish the DSL and LAN connections automatically if they have been dropped. But if it is not in a sane state, it may not be responding to connections from over the LAN, let alone the DSL interface. So you cannot issue it a command to "Reboot", because it is not listening. You have to power it off, and then on again.

So I think you need to look at a way you can control the power supply to your modem / router from a machine that is physically nearby. That's where you should run the network-monitoring script and if the connection has failed:
turn off the power
sleep 10
turn on the power
sleep 120
re-test the connection

Disillusionist's post points to some suitable hardware, there will undoubtedly be others (and they'll all co$t), or you could hack some simple hardware together yourself.
 
Old 10-29-2007, 03:09 PM   #10
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
most routers have a reset link in the web-interface configuration.

you may be able to use lynx with authentication to submit the reset form. Could be something as simple as:

Code:
if (no internet) then
  lynx -auth=admin:password http://192.168.0.1/reset
endif
the trick, of course, is finding what the URL is to do the reset & if it's a simple URL or a form submission.

Just a thought.
 
Old 10-29-2007, 03:17 PM   #11
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Quote:
most routers have a reset link in the web-interface configuration.
But this will not work if the modem / router needs to be reset before it will start listening for commands. If the device is confused, it needs power-cycling. Nothing else will do.
 
Old 10-29-2007, 03:17 PM   #12
farslayer
Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,232
Blog Entries: 5

Rep: Reputation: 189Reputation: 189
could probably do the same thing with the x10 hardware. Write your monitoring script and use it to trigger the x10 device to reboot the router/modem.

X10 home automation

x10 Linux resources
 
Old 10-29-2007, 03:22 PM   #13
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by tredegar View Post
But this will not work if the modem / router needs to be reset before it will start listening for commands. If the device is confused, it needs power-cycling. Nothing else will do.
totally depends on how it's confused. It is certainly plausible (and even likely) that the modem is losing its internet connection, but still responds to the local network. Especially on modems that are also routers (i.e. have multiple ports). If the whole thing was bad, then all internal communication would be bad. if that were the case, then the modem itself is bad & would need to be replaced.
 
Old 10-29-2007, 06:36 PM   #14
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Hmmm... I just had a go manipulating my router from cli... it's awful!
You need to read the preceding posts more carefully, I know it's a pain but it's good practise.

The salient points:

1. Test the internet connection
... if it is OK, do nothing
... if it is not, then 2.

2. Test connection to router
... if it is OK then 3.
... if it is not - then do MPCPM[1]

3. Issue a command to reboot
... this is going to depend on the exact HW you use and it's firmware.

As suggested earier, your HW may accept SNMP commands (though it may need to be enabled). In which case, this (SNMP) is what you want to google about. There are a large number of snmp network monitoring scripts arount, the trick will be wading through them to locate just the simple functions you want. Or you can use a tutorial.

Otherwise you need to work out the series of steps needed to login to your router's interface using only cli tools. Once you can do this, you can put the steps into a script. You certainly want to see if you can login to a shell on your router - but however you go, you have some learning to do.



...............................................................................
[1] Manual Power Cycle and Percussive Maintenance

Last edited by Simon Bridge; 10-29-2007 at 06:48 PM.
 
Old 10-31-2007, 11:01 AM   #15
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 53
curl is a one way to send http get/post commands
If you're router is still accessible from the LAN and it has a webinterface with a button to restart the router, then it's a one line script using curl
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sar isnt working rsmccain Suse/Novell 1 10-07-2006 04:48 AM
YaST isnt working DickH Suse/Novell 19 06-12-2006 01:22 AM
Multi-OS is that why it isnt working??? CiscoNinja Linux - Newbie 8 10-01-2005 08:05 PM
Sound Isnt Working LinuxNoob1234 Linux - Newbie 8 05-07-2005 01:51 AM
help,windows isnt working Geefthegreat Linux - Newbie 2 04-06-2004 02:06 AM


All times are GMT -5. The time now is 02:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration