Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
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 1 '12 at 21:18
    
I'll say its a loss of link on the cable connecting to the interface.. –  Ralf Aug 1 '12 at 21:24
    
You might want to look here to get started. –  rnxrx Aug 1 '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 1 '12 at 22:02
add comment

2 Answers

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 directory. NM passes 2 arguments to scripts found in the dispatcher.d directory, 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.

share|improve this answer
    
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 1 '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 1 '12 at 23:57
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.