#!/bin/bash
# sniff network traffic on a given interface and
# display the IP addresses of the machines communicating with the current host (one IP per line)
# http://www.commandlinefu.com/commands/view/13324/sniff-network-traffic-on-a-given-interface-and-displays-the-ip-addresses-of-the-machines-communicating-with-the-current-host-one-ip-per-line

sudo tcpdump -i wlan0 -n ip	\
| awk '{ print gensub(/(.*)\..*/,"\\1","g",$3), $4, gensub(/(.*)\..*/,"\\1","g",$5) }'	\
| awk -F " > " '{print $1"\n"$2}'

exit $?

