Uping eth0 after a black out

Discuss Networking
Post Reply
User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Uping eth0 after a black out

Post by Basher52 » Sat Jun 11, 2011 5:44 pm

This evening we had a black out after a short thunderstorm and I wonder if there is a way to 'ifup' a NIC after that?
I do have 'ONBOOT=yes' but when the power was up my ISP didn't have their servers up and running totally.
I need something that can 'ifup' a NIC if it ain't up after a start/restart, such in this case.
Some years ago, after a black out the ISP didn't work until about 30 minutes later and that made my have the connection down for all day since I was at work and couldn't sit in front of the machine to start it manually.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: Uping eth0 after a black out

Post by Void Main » Sun Jun 12, 2011 8:00 am

You could put something as simple as this in root's cron to run like every 15 minutes:

Code: Select all

if ! /bin/ping -c2 www.google.com; then /sbin/ifdown eth0; /sbin/ifup eth0; fi &> /dev/null
Basically all it does is send 2 ping packets to google and if it doesn't get a response it will down and up your eth0.

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Uping eth0 after a black out

Post by Basher52 » Mon Jun 13, 2011 3:30 am

So simple and I couldn't think of it
lol

thx

Post Reply