David <(E-Mail Removed)> wrote:
> We have an issue where our linux gateway resets each night. However,
> last night the ISP did not hand out a IP address or some other crucial
> part of information. As such during the reboot the eth<X> did not come
> back up. We had to wait until a good point to reset it, as it also
> provides NAT access between arious networks. What would you all
> recommend running on say a cron job (open to suggestions), to detect
> if an interface is not correctly connected to the internet, so that if
> could be brought down and back up. As i use this for remote access all
> the time, up and down no matter what, is as a preference not a nice
> option.
>
I used to do various checks in a script and I replaced this with a much
simpler ping to google.com - if this succeeds then my DNS is OK, my route
is setup, and I can talk to the net. I realise that this could fail if
google stops responding to ping echo-requests (unlikely) -- more than often
there is as you say a slight misconfig and all that is needed is a quick
ifup/ifdown. So I have the following in which I'm using ppp0 and I've
expanded it for clarity. I'm assuming that your firewall allows outbound
pings and incoming replies..
/usr/local/bin/testremotenet:
#!/bin/sh
semfile=/var/run/remote-net-up
rm -f $semfile
ping -c4
www.google.com &>/dev/null
if [ $? -ne 0 ]
then
/sbin/ifdown eth0
/bin/sleep 15
/sbin/ifup eth0
if [ $? -ne 0 ]
then
mail -s "eth0 dead at $(date -R)" \ root@localhost </dev/null
exit 1
fi
fi
touch $semfile
exit 0
and in root's crontab:
0,15,30,45 * * * * /usr/local/bin/testremotenet &>/dev/null
will run this every 15 mins. You can drop in extra bits between ifup and
ifdown if you have a trick to get the interface back up.. or maybe loop
this bit to have a few more goes at getting it going before dying. Good
luck.
--
Jamin @ Home: Chester UK -<(E-Mail Removed)>