Networking Forums

Networking Forums > Computer Networking > Linux Networking > Ethernet interface status detection

Reply
Thread Tools Display Modes

Ethernet interface status detection

 
 
David
Guest
Posts: n/a

 
      08-15-2007, 07:03 PM
Hi all,

Thoughts on a clean and efficient way to do this would be appreciated
thanks.

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.

Please advise.

David

P.S The Linux version is Gentoo, with a full custom kernel build for
this purpose. However, i guess whatever variant of Linux if its
availale then i should be able to setup.

Thanks again in advance for any ideas.

 
Reply With Quote
 
 
 
 
Jamin Davis
Guest
Posts: n/a

 
      08-16-2007, 02:31 AM
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)>

 
Reply With Quote
Reply

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link detection in Sun Happy Meal Ethernet Jakub Kramarz Linux Networking 0 04-02-2011 11:05 PM
How to refresh Ethernet interface? Charles Packer Linux Networking 2 03-19-2011 01:14 AM
Virtual ethernet interface ? ArameFarpado Linux Networking 5 11-17-2006 11:30 PM
serial interface to ethernet interface Kenneth Sparre Linux Networking 9 11-01-2005 12:27 PM
detection of Ethernet link failure Michael L. Linux Networking 1 08-11-2003 10:40 AM



1 2 3 4 5 6 7 8 9 10 11