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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-11-2007, 04:41 PM
|
#1
|
|
Member
Registered: Nov 2004
Location: Brazil
Distribution: Gentoo
Posts: 363
Rep:
|
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.
|
|
|
|
10-11-2007, 05:59 PM
|
#2
|
|
Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,209
Rep: 
|
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.
|
|
|
|
10-11-2007, 06:17 PM
|
#3
|
|
Member
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702
Rep:
|
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.
|
|
|
|
10-11-2007, 10:33 PM
|
#4
|
|
Member
Registered: Nov 2004
Location: Brazil
Distribution: Gentoo
Posts: 363
Original Poster
Rep:
|
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!
|
|
|
|
10-11-2007, 11:41 PM
|
#5
|
|
Member
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770
Rep:
|
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.
|
|
|
|
10-13-2007, 09:21 AM
|
#6
|
|
Member
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702
Rep:
|
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.
|
|
|
|
10-29-2007, 12:44 PM
|
#8
|
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546
Rep:
|
Quote:
Originally Posted by Simon Bridge
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 !
|
|
|
|
10-29-2007, 01:38 PM
|
#9
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
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.
|
|
|
|
10-29-2007, 02:09 PM
|
#10
|
|
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334
Rep:
|
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.
|
|
|
|
10-29-2007, 02:17 PM
|
#11
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
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.
|
|
|
|
10-29-2007, 02:17 PM
|
#12
|
|
Guru
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,231
Rep: 
|
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
|
|
|
|
10-29-2007, 02:22 PM
|
#13
|
|
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334
Rep:
|
Quote:
Originally Posted by tredegar
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.
|
|
|
|
10-29-2007, 05:36 PM
|
#14
|
|
Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,209
Rep: 
|
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 05:48 PM.
|
|
|
|
10-31-2007, 10:01 AM
|
#15
|
|
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:20 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|