Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turning Ping off

Status
Not open for further replies.

jwant

Technical User
Jul 2, 2001
17
0
0
US
I am trying to figure out how to turn ping off, can someone tell me how?

JA
 
Hi,

Assuming you want to stop people pinging you, use iptables (2.4 series kernels) / ipchains (2.2 series kernels) to drop the relevant packets. You just add some icmp rules something like the following :

/sbin/iptables -A INPUT -p icmp --icmp-type echo-requested -j DROP
/sbin/iptables -A OUTPUT -p icmp --icmp-type echo-reply -J DROP

or

ipchains -A input -p icmp -s any/0 8 -d any/0 -j DROP
ipchains -A output -p icmp -s any/0 0 -d any/0 -j DROP

(Type 8 icmp = Echo request; Type 0 = Echo reply)

Rgds, Iain

 
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

Bye.
 
You might read you question a little more different. I therefor post this... Perhaps you just want to know how to turn the ping command off. Default it runs until you stop it.
Try ctrl+c or ctrl+break
In some Unix systems (SCO for instance), the delete button has the same affect.
When breaking the ping command you recieve statistics regarding packet loss and more.
/Sören
 
Just to clarify, the 'echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all' quoted by marsd is certainly a good suggestion and is undoubtedly simplest as long as you want to block <all> interfaces on your machine. If you just want to block on a given interface you will have to use iptables/ipchains. Typically, you'd want to suppress pings from outside your lan but allow from inside, or perhaps from a nominated machine only. Also remember if you do use packet filtering that you do not want to block all icmp protocol packets - just those packet types that relate to ping.

If you meant as per Nostradamus' response you can use the syntax 'ping -c 5 127.0.0.1' where -c means number of pings. In this example ping would stop after 5 as it would on a Windows box.

Rgds
 
You can also use a dumbping script
to supress output. This is in expect.

#!/usr/bin/expect
set timeout -1
log_user 0

proc debug_ {} {
global argv
if {[string match &quot;debug&quot; $argv]} {

puts &quot;Debug enable.&quot;
exp_internal 1

} else {

puts &quot;No debug.&quot;
}
}

proc pingit {host} {
set timeout 15

spawn ping -c4 $host

expect {

-gl &quot;*64*&quot; {
send_user &quot;Host Up.&quot;
}

eof {puts &quot;Bye.&quot;}

timeout {puts &quot;$host, no response.&quot;}

}
}

debug
while 1 {
send_user &quot;Target host: &quot;
expect_user -re &quot;(.*)\n&quot;
set target $expect_out(1,string)
puts &quot;Quit to end.&quot;
if {[regexp &quot;(Q|q)uit&quot; $target}} {
exit
} else {
continue
}
pingit $target
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top