tcpdump is one of the most powerful linux/unix commands that helps us to analyze the network packet mainly for troubleshooting purpose. It mainly captures packets received or transferred over a network on a specific interface .
tcpdump is mainly used on linux/unix distro and can be easily installed.
INSTALLING TCPDUMP
$ sudo apt-get install tcpdump [On Debian, Ubuntu and Mint]
$ sudo yum install tcpdump [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a sys-apps/tcpdump [On Gentoo Linux]
$ sudo pacman -S tcpdump [On Arch Linux]
$ sudo zypper install tcpdump [On OpenSUSE]
TCPDUMP COMMANDS
1. CAPTURE HOST
# tcpdump -i < interface name > host <host ip >
# tcpdump -i eth0 host 10.1.1.1
2. NO DOMAIN LOOKUP
# tcpdump -i eth0 -n host 8.8.8.8
3. NO DOMAIN AND PROTOCOL LOOKUP
# tcpdump -i eth0 -nn host 8.8.8.8
4. CAPTURE SERVICE
# tcpdump -i eth0 -nn port 443
5. CAPTURE HOST AND SERVICE
# tcpdump -i eth0 -nn host 118.91.171.10 and port 80
6. CAPTURE HOST AND PROTOCOL
# tcpdump -i eth0 -nn host 118.91.171.10 and udp
7. NEGATE FILTER
# tcpdump -i eth0 -nn host 118.91.171.10 and not icmp -c 5
8. COMPLEX COMBINATION
# tcpdump -i eth0 -nn "dst 8.8.8.8 or dst 1.1.1.1" and port 443 -c 10
9. CAPTURE MAC ADDRESS
#tcpdump -i eth0 -nn -e host 8.8.8.8 and icmp -c 100
10. VPN TRAFFIC
#tcpdump -i eth0 -nn host 118.91.171.10 and esp -c 50 ( FOR PHASE II )
#tcpdump -i eth0 -nn host 118.91.171.10 and udp and port 500 -c 100 ( IKE PHASE I )
11. VERBOSE ( PROVIDES HEADER LEVEL INFO )
#tcpdump -i eth0 -nn -vv host 118.91.171.10 and tcp -c 100
12. SAVE THE CAPTURE FILES
#tcpdump -i eth0 -nn -vv host 118.91.171.10 and port 80 -c 100 > /var/log/capture.txt
#tcpdump -i eth0 -nn -vv host 118.91.171.10 and port 80 -c 100 > /var/log/capture.cap
13 . CAPTURE NETWORK
#tcpdump -i eth0 -nn net 118.91.171.0/24
Note : Capturing for network can only be for classful network and we cannot define classless network. tcpdump will simply not capture the packet
Comments
Post a Comment