if the network interface is disconnected:
ping 8.8.8.8
connect: Network is unreachable
terminates nicely
kernel is sending a specific signal to the
ping and thus ping is shutting itself down.
But if network interface is up and
I am blocking all traffic via iptables..
vi /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A OUTPUT -j REJECT --reject-with icmp-net-unreachable
-A INPUT -j DROP
-A FORWARD -j DROP
COMMIT
but it will not make ping shut off. and stop.
ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.0.100 icmp_seq=1 Destination Net Unreachable
From 192.168.0.100 icmp_seq=1 Destination Net Unreachable
From 192.168.0.100 icmp_seq=1 Destination Net Unreachable
it simply keeps on continuing.
I have tried other --reject-with flags
such as:
icmp-net-unreachable
icmp-host-unreachable
icmp-port-unreachable
icmp-proto-unreachable
icmp-net-prohibited
icmp-host-prohibited
icmp-admin-prohibited
none of them can make ping quit.
What I want to see is ping terminate the same way
it terminates when network interface is disconnected.
if this can not be done via iptables..
is there a command I can run to send ping the same
signal the kernel sends .. to tell it "network interface is not connected" ?
( it would be a lie but I want it to shut itself off basically )
If you want ping to really fail, you can also "null-route" the target IP you are trying to ping, but it will prevent any communication with this IP. You can also remote the default gateway or remove the address from the interface, but you will loose network connectivity on the computer!
But, at the end, what are you trying to achieve here?!
– Elektordi Jan 29 '17 at 23:25