First let's block all incoming / outgoing traffic.
vi /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A OUTPUT -j DROP
-A INPUT -j DROP
-A FORWARD -j DROP
COMMIT
Next: let's test ping
ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
at that point ping stalls.. perhaps will wait until times out.
Now let's disconnect the network interface and try again:
ping 8.8.8.8
connect: Network is unreachable
beautiful, it stopped instantly. ( no stalling or waiting for time out )
Some recommended using "REJECT" in the iptables-rules
and even play with the -j REJECT --reject-with flags..
I have tried them all.
there is no way to send the same signal the kernel
is sending to the program when the network interface is disconnected.
( via iptables )
This is what I want to do for now:
figure a way to ensure Kernel tells ping that network is disconnected.
( or run a command in another terminal manually to send such a signal )
this way ping will not stall. it will simply say
connect: Network is unreachable
and stop.
Can it be done & how ?