Koozali.org: home of the SME Server
Contribs.org Forums => General Discussion => Topic started by: MSmith on July 12, 2012, 05:43:44 PM
-
So I've been tasked with shutting off internet access every day at 5 p.m. and restarting it every day at 6 a.m. Crontab magicians, will these entries work?
* 17 * * * /sbin/ifdown eth1
* 6 * * * /sbin/ifup eth1
-
You can set times in dans guardian i believe. Might be better to go that way?
-
So I've been tasked with shutting off internet access every day at 5 p.m. and restarting it every day at 6 a.m. Crontab magicians, will these entries work?
* 17 * * * /sbin/ifdown eth1
* 6 * * * /sbin/ifup eth1
man 5 crontab
will help you
-
Well, that's what I get for reading the man pages, working up the commands and thinking that I'd get a bit of feedback that I'd gotten the syntax right, or wrong, as the case may be. I had hoped that someone who's more familiar than I am with crontab entries would look at these and say, "Looks good" or "No, you'd be better off writing a small script that calls ifconfig" or some such.
Gentlemen, I do appreciate your taking the time to reply, but neither of you provided actual help. Thanks anyway.
-
Hello MSmith, I tends to agree with you, we could be more helpful. I am not a guru by any means but there may be a way around this: I have schedule your requirements in dungog-cronjob (I know it works) and then copy and paste the actual commands.
#(lan off)
0 17 * * 0-6 /sbin/ifdown eth1
#(lan on)
0 6 * * 0-6 /sbin/ifup eth1
Hope it helps, no warranty...
-
Thank you, Chris, that was very helpful indeed. I used mrhjb3's suggestions (well, with nano instead of pico, and rebooted instead of doing restart-crond) so we'll know shortly on my test machine! :) Thanks again.
-
So I had to edit those slightly ...
#(lan off)
0 17 * * * root /sbin/ifdown eth1
#(lan on)
0 6 * * * root /sbin/ifup eth1
The "ifdown" command worked great but "ifup" gives me an IP of 1.1.1.1 :(
Gonna dig around a little more to see how to restart networking in SME 8.
-
Gonna dig around a little more to see how to restart networking in SME 8.
something like
service network restart
should work
-
This whole thing is showing me just how little I've actually learned about Linux. One way or another, I'm just misunderstanding what's happening.
The cronjobs run fine ... ifdown works great ... but ifup does not bring eth1 back to functionality! This is completely stock SME8, on an old P4, and I've tried two different NICs for eth1.
"ifup eth1" gives eth1 an IP address of 1.1.1.1 and obviously that doesn't work.
"ifconfig eth1 up" results in the correct IP, but the SME machine can't reach out to the Internet.
"service network restart" doesn't restore network function either. Only a reboot fixes Internet access.
The test box is behind another NAT router, is it possible that could be the problem? I *can* hook directly to my Internet feed for testing if necessary.
So, does this actually warrant a trip to the bug tracker? I'm thinking it's just me.
-
It looks like You are loosing your default route. You can try:
ifconfig eth1 up && route add default gw your.router.ip.addr
-
Interesting. That restored DNS lookup when, for instance, pinging google.com but resulted in "Destination host unreachable" for ping reply. HOWEVER, I *can* ping the next hop gateway, i.e. eth1 pulls 10.20.30.101 from DHCP, SME can ping 10.20.30.1. But not beyond.
Subsequently, "service network restart" = no eth1 !
I'm wondering if being behind a NAT box is the problem. May have to grub around in the wires after all.
-
and with:
ifconfig eth1 up && route add default gw your.router.ip.addr dev eth1
-
something like
service network restart
should work
No. The WAN interface has its own service.
sv down /service/wan
will bring the WAN interface down (you could also use "service wan stop"). I'll let you guess what you would do to bring the interface 'up'.
-
Charlie, thanks for entering the discussion. However, on a completely stock SME 8.0 with all updates to date, neither of those commands did what I wanted.
"sv down" returned me to the command line, but ifconfig eth1 showed address and ping to Internet still worked.
"service wan" returned "shutting down wan ... OK" but again, ifconfig showed address and ping to Internet still worked.
Submitted:
http://bugs.contribs.org/show_bug.cgi?id=7047