Created
January 13, 2023 16:07
-
-
Save martinkennelly/c07bcb50b04a1a62293e24a5e69748ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When this exits, exit all background processes: | |
trap 'kill $(jobs -p) &> /dev/null && sleep 0.2 && echo ' EXIT | |
# Create one tcpdump output per interface and add an identifier to the beginning of each line: | |
if [[ $@ =~ -i[[:space:]]?[^[:space:]]+ ]]; then | |
tcpdump -l $@ | sed 's/^/[Interface:'"${BASH_REMATCH[0]:2}"'] /' & | |
else | |
for interface in $(ifconfig | grep '^[a-z0-9]' | awk '{print $1}'i | sed "/:[0-9]/d") | |
do | |
tcpdump -l -i $interface -nn $@ | sed 's/^/[Interface:'"$interface"'] /' 2>/dev/null & | |
done | |
fi | |
# wait .. until CTRL+C | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment