get a notification when my machine is pinged

I'd like to be able to be notified in any way (sound, notification, growl, etc) when someone pings my machine.

Is that possible?


Little Snitch may have the feature you want. It allows you to set up rules on network traffic, both inbound and outbound, mostly for blocking unwanted traffic, but I believe it can perform arbitrary actions such as notification for specific rules and types of traffic like ICMP pings.

There's a trial version that you can use to test.

I have no affiliation with Little Snitch or the company behind it.


Here is a 1st draft of a simple sonar:

$ cat >sonar.pl <<____eof
#!/usr/bin/perl
use strict ;
use warnings ;

$< == 0         ||      die "$0: should be run as root" ;

my $host = `hostname` ;
chomp ($host)  ;

# the targetted tcpdump buffered
my $command = "tcpdump -i en1 -l -n -q \'dst host " . $host . " and ( icmp[icmptype] != icmp-echoreply )\' 2>/dev/null" ;

sub bing {
        printf ("^G") ; # ^G == a real ctl-G
}

open (PIPE, "$command |")       ||      die "couldn't start pipe: $! $?" ;

# print without buffering
$| = 1 ;

while (my $line = <PIPE>) {
        bing() ;
}

close (PIPE)    ||      die "couldn't close pipe: $! $?" ;
____eof
$ chmod u+x sonar.pl