Last active
October 4, 2019 22:28
-
-
Save ntrogers/bd5179dbe0ead11769beb0c6cdda8e40 to your computer and use it in GitHub Desktop.
[tcpdump - Monitor DHCP Traffic] Monitor DHCP traffic via tcpdump #tcpdump
This file contains hidden or 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
| #!/bin/sh | |
| #=================================================================================== | |
| # | |
| # FILE: dump.sh | |
| # USAGE: dump.sh [-i interface] [tcpdump-parameters] | |
| # DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data. | |
| # OPTIONS: same as tcpdump | |
| # REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching | |
| # BUGS: --- | |
| # FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started. | |
| # - In 1.1 VLAN's would not be shown if a single interface was dumped. | |
| # - In 1.3 Some fixes for virtual interfaces have been provided by Reiner Keller. (Thanks!) | |
| # NOTES: --- | |
| # - 1.2 git initial | |
| # AUTHOR: Sebastian Haas | |
| # VERSION: 1.2 | |
| # CREATED: 16.09.2014 | |
| # REVISION: 22.09.2014 | |
| # | |
| #=================================================================================== | |
| # 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 |
This file contains hidden or 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
| tcpdump -i eth0 -n port 67 and port 68 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment