0
How can I force all currently open sockets in linux to close from the command line?
0
How can I force all currently open sockets in linux to close from the command line?
1
Maybe it's easier to shut down a specific interface, for example:
# ifconfig eth0 down
0
to flush all your rules in the filter table
iptables -F
set default behavior to drop in INPUT chain
iptables -P INPUT DROP
at this point all local sockets should be unavailable to a remote host if you have a redhat based os you should also use iptables -X to get rid of their custom chain for INPUT
if you want to the rules to remain on startup then you need to either include these in a script that runs in the /etc/rc.local file or use iptables save
This is all assuming that what you said you want to do is what you want to do.
2This is hard, I think it would be easier to answer if you said why. All of your sockets? All on the computer? Kill apps or not? – Rich Homolka – 2010-09-14T22:28:47.470
If you do that, the programs using these sockets will encounter errors, which they might or might not handle. Is that what you want? – sleske – 2010-09-14T22:43:04.187
Maybe you could describe why you want to do this. Then it'll be easier to help. Also see: http://stackoverflow.com/questions/41602/how-to-forcibly-close-a-socket-in-time-wait
– sleske – 2010-09-14T22:43:25.137