1

I have a direct Ethernet connection between a Windows box and a Linux box. If I disable the connection on the Windows side Linux still seems to believe the link is up.

Is this normal behaviour? I would like Linux to run if down if the link fails and ifup when it returns. Is that possible?

7

You're trying to add a Windows misfeature to Linux. Linux doesn't have this misfeature on purpose.

I call it a misfeature because when Windows does this, it kills off all connections using that network interface even if no packets were ever lost. Also, unless you're in the simplest possible case, with just two machines and a crossover cable (or MDI-X) it can't detect failures in intermediary or remote parts of the physical layer connection.

Think about that: Windows is only dropping connections when it detects a local failure which may well be temporary, but doesn't even try to detect failures further down the line.

Windows may hope that these intermediaries and its remote peers will copy its misfeature, but they don't because they are designed with the same principles as the protocols of the Internet itself, which was designed with failure in mind. The whole Internet doesn't blow up when a core router has a little blip. It copes.

If you wonder what my standing is in holding this strong opinion, it's that I've been writing networked programs for about two decades now. That experience pounds Murphy's Law into you: anything that can go wrong will. Tossing up your hands at every little failure just makes your programs brittle. Coping is better.

Ever notice that your web browser doesn't close all its tabs when the network link goes down? That's because it copes with network failures. Some of this is is due to the design of HTTP, but some is also a choice by the designers of the web browser in handling detectable failures. By contrast, Windows Explorer shoots all open Explorer windows back to the default folder (My Computer, usually), so when you come back to the machine after a blip, you've lost your working place.

If you absolutely had to do this, the tools suggested in robbat2's answer will do this. Far better, however, to write your network programs to cope with network link failure.

When failure is not an option, set up redundant network interfaces using the NIC channel bonding feature of the Linux kernel. You can configure a system to automatically fail over to a second (or third!) network interface if one link fails.

  • 1
    Thanks Warren. Appreciate your position and your comments taken under advisement. – Ian Dec 9 '13 at 2:04
2

Install netplug, ifplugd or a similar package in your distribution; they can cycle your interface addresses based on link physical status.

  • Thanks robbat2. netplug isn't available for centos6 (Warren deleted that information, not sure why). I tried ifplugd and whilst promising it didn't properly detect the down state: it notices it, then thinks its come back up. Tried all its interface modes with the same result. Apparently netplug had the same issue on centos5. I'm thinking this /should/ be the answer, Warren's comments and flaky software notwithstanding... – Ian Dec 9 '13 at 2:09
  • @IanWorthington: I didn't delete anything about netplug. I did replace my hacky script with a reference to robbat2's answer because I'm sure it doesn't work as well as dedicated programs. – Warren Young Dec 9 '13 at 3:07
  • I know I've seen some hardware that didn't always toggle state correctly, and I'm not sure Windows actually implements their down offhand. If it only drops the addresses, but doesn't actually force the PHY down, then Linux is still going to see it as 'up', despite being unable to talk to Windows. Doing arping/ping between the systems to check status is probably safer. – robbat2 Dec 9 '13 at 4:27
  • Hi Warren, that was a reference to ifplugd's flaky software, didn't mean to suggest it was yours! – Ian Dec 9 '13 at 12:35
  • Robbat2: Ah, that might be it then. I'm several thousand miles away from these boxes so it's a bit tricky to do a physical pull test. And logical connectivity is what I do need to test practically. – Ian Dec 9 '13 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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