Date: Sat, 01 Sep 2007 13:53:37 +1200 From: Hinkie <Hinkie@paradise.net.nz> To: Hinkie <Hinkie@paradise.net.nz>, freebsd-questions@FreeBSD.ORG Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up) Message-ID: <033a01c7ec3a$ea145d90$1e00a8c0@cheqsoft.local>
next in thread | raw e-mail | index | archive | help
Dear People As a courtesy to anyone interested I have finally sovled this (I hope), = this is what I did, this is on a FreeBSD pfSense firewall router. Essentially the fix is to ping the static IP's first hop, if this is = down then flick the WAN NIC state down and up, this restores=20 the lost connection where the Motorola 5101 has stopped sending packets = (presumably for some incompatibility reason) The Motorola=20 5101 has today been replaced with a 5100, the ISP tell me most = commercial lines are running the 5100 as they say it is more router=20 compatible than the newer 5101. I'll advise if the 5100 exhibits the = same behaviour(!) however if it does the following should=20 address it within a minute. If you are copying it be sure to copy it = exactly as spaces in the wrong place stuff it up....etc!! For both the lists and my record it is done by: =3D> in /etc/crontab add */1 * * * * root /usr/bin/pinger.sh =3D> from edit.php create / write into new file /usr/bin/pinger.sh #!/bin/sh ping -c1 Insert_1st_Gateway_Hop_Here_commonly_Static_IP_a.b.c.1 if [ $? -eq 2 ]; then ifconfig em0 down ifconfig em0 up echo 'Gateway Down' else echo 'Gateway Up' fi =3D> from exec.php run chmod u+x /usr/bin/pinger.sh =3D> from exec.php run ls -l /usr/bin/pinger.sh and check there is an x in the file permissions (for executable) It will have run when you see a log series of commands starting with Sep 1 11:32:13 kernel: em0: link state changed to UP Sep 1 11:32:11 kernel: em0: link state changed to DOWN The only problem I see with this approach is that whenever the Internet = is down for whatever reason the WAN interface is going to be=20 disconnected and reconnected every minute, as well as filling the logs = with this info, but that seems only of concern from the=20 perspective of filling the log with rubbish. I might tinker with it to = send me an email to advise me when the code has also run . Thank you again to the people who worked with me on this. Kind regards David Hingston=20
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?033a01c7ec3a$ea145d90$1e00a8c0>