Damon Cortesi's blog

Musings of an entrepreneur.

Quickie for Choosing Interface for Tcpdump

| Comments

I’m frequently firing up tcpdump on my mac, but then having to restart it with the correct interface if I happened to be on a wireless network (which I frequently am on the mac). I finally got tired of that, so I whipped up a quick script that determines which interface is up and consequently starts tcpdump on that interface.  Allow me to cat /usr/bin/stcpdump for you:


INT=`ifconfig | grep -A3 "en.:" | grep -B2 inet\  | head -n 1 | cut -f1 -d:`
sudo tcpdump -i $INT $@

Much better - saves me a big of grief. ;o)