5

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

Is that possible?

  • Just be sure to rate limit the notifications since ping floods can send thousands of packets a second and you'll want your notification system to scale and fail gracefully. – bmike Mar 25 '13 at 18:56
  • Thanks for the tip... but how do I get the notifications? – Pier Mar 25 '13 at 19:38
  • 2
    I would probably have a pair of shell scripts. One running tcpdump and grepping for "ICMP echo request" and writing to a pipe and another script reading from the pipe and doing the rate limiting and calling terminal-notifier. However, I've done a fair amount of shell scripting, so you might not want this implementation if you're not handy with light scripting tools and syntax. – bmike Mar 25 '13 at 20:04
  • Try the zonealarm.com/security/en-us/… I did not ry it my self, but that might work for you and it is free. – user44516 Mar 25 '13 at 21:30
  • 1
    @Borderline ... No mac version of that software... – Pier Mar 25 '13 at 21:44
3

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.

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .