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.

Today I was trolled^Wasked to implement resetting TCP connection if internet is disconnected, like Windows® does by resetting all related TCP connection when interface goes down. So, question is: is it possible to make linux' TCP stack to behave like Windows does and reset connections if I, for example, unplug ethernet cable?

share|improve this question
    
I'm not sure if it's possible, but I will say I find that behavior slightly undesirable (if I accidentally unplug my network cable and plug it back in quickly 99% of the time all my SSH sessions are still alive - yes it's happened to me a few times, and if all my connections reset that would suck :) –  voretaq7 Jan 25 '11 at 16:28
    
Yeah, I know, but there is one username that really WANTS such behavior :) –  gelraen Jan 25 '11 at 16:32
add comment

1 Answer

up vote 2 down vote accepted

The tcpkill command looks promising -- I suppose you could hook it in the interface-down event scripts...

Cribbed from here

share|improve this answer
    
It is one of possible solutions, but not accurate one :) –  gelraen Jan 25 '11 at 16:48
    
Hm, what doesn't it do that you're looking for? –  voretaq7 Jan 25 '11 at 17:00
    
It requires to write custom script that lists tcp connections and drops them selectively. More accurate would be if kernel itself will drop connections that relied on interface, but I'm not sure that linux kernel has such option. –  gelraen Jan 25 '11 at 17:20
    
The script isn't that hard -- Grab the IP off the interface & kill every connection involving that IP (2 lines, maybe 3). You could get more involved if you want, but don't have to. I agree if someone comes up with a kernel option that's probably a better way to go though. –  voretaq7 Jan 25 '11 at 17:31
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.