1

I am using a CentOS server which has about 6 active interfaces with different IPs, I'd want to automatically bring down all the interfaces when any one of the 6 interfaces is down. Is there a way this can be done?

I've been trying to find a method to do this, but so far failed.

Any help is appreciated.

Thanks

Ralf
  • 11
  • 1
  • How do you define down? Is it loss of link on the cable connecting to the interface, or some kind of upstream loss? – Zoredache Aug 01 '12 at 21:18
  • I'll say its a loss of link on the cable connecting to the interface.. – Ralf Aug 01 '12 at 21:24
  • You might want to look [here](http://stackoverflow.com/questions/2261759/get-notified-about-network-interface-change-on-linux) to get started. – rnxrx Aug 01 '12 at 21:49
  • If you bring down _all_ the network interfaces, you'll have to have some way to bring them back up later. – Michael Hampton Aug 01 '12 at 22:02

2 Answers2

0

Take a look at Monit. You can configure it to monitor your network connections and have it act when a failure is detected.

FoamyBeer
  • 371
  • 1
  • 5
0

If you are using NetworkManager: NM automatically executes scripts found in /etc/NetworkManager/dispatcher.d/ every time any interface changes its status (see man NetworkManager). You can write a script to manually bring down the other interfaces and put the script in the dispatcher.d/. NM passes 2 arguments to scripts found in the dispatcher.d/ , the name of the device and the action (whether an interface is brought up or down, again see NM manual for exact key words). So your script should only bring down the other interfaces if the 2nd argument is down.

If you aren't using NetworkManager, there's a software called ifplugd which might help you. However, this software is quite old. Last update was on 2005.

fduff
  • 115
  • 4
Hermes Conrad
  • 63
  • 1
  • 1
  • 4
  • I wouldn't want to use NetworkManager if I can avoid it (too many bad experiences previously).. although I'll give this a shot.. and just thinking out loud here, how about using 'ifup' and 'ifdown' within a script?.. is this something I can explore? – Ralf Aug 01 '12 at 23:48
  • You can put a script in /var/run/netreport and this script will run when you deactivate an interface manually, ie ifdown eth1. I don't know of an automatic way to do this. I think you have to have some daemon running in the background that will let you know that an interface has been brought down. Besides NM, I don't know if a default CentOS installation already has that already. – Hermes Conrad Aug 01 '12 at 23:57