Study of tcpdump Command
Experiment
Study of tcpdump Command
๐ฏ Aim
To capture and analyze network packets using the tcpdump command.
๐ Objective
By the end of this experiment, students will be able to:
- Capture live network traffic
- Filter packets based on protocol, port, or host
- Analyze packet-level communication
- Understand basic packet structure
๐ Theory
The tcpdump command is a packet analyzer (sniffer) used to:
- Capture network packets in real time
- Display detailed information about each packet
๐ It works at a low level and can capture:
- TCP, UDP, ICMP traffic
- Packets to/from specific hosts or ports
๐ Commonly used for:
- Network troubleshooting
- Security analysis
- Debugging network applications
๐งพ Syntax
๐ง Common Options
-
-i <interface>→ Specify interface (e.g.,eth0) -
-n→ Do not resolve hostnames -
-c <count>→ Capture limited number of packets -
-w <file>→ Save packets to file -
-r <file>→ Read packets from file -
-v,-vv,-vvv→ Verbose output
๐งฐ Prerequisites
- Linux system
- Root/sudo privileges
-
tcpdumpinstalled
Installation:
๐ฌ Procedure & Commands
1️⃣ Capture Packets on Default Interface
2️⃣ Capture on Specific Interface
3️⃣ Capture Limited Packets
4️⃣ Disable Hostname Resolution
5️⃣ Capture Only ICMP (Ping Traffic)
6️⃣ Capture Traffic for Specific Host
7️⃣ Capture Specific Port Traffic
8️⃣ Save Packets to File
9️⃣ Read from Saved File
๐ฅ️ Sample Output
๐ Output Interpretation
| Field | Meaning |
|---|---|
| IP | Protocol |
| Source | Source IP and port |
| Destination | Destination IP and port |
| Flags | TCP flags (S = SYN, A = ACK) |
| seq | Sequence number |
๐ Common TCP Flags
-
S→ SYN (connection start) -
A→ ACK (acknowledgment) -
F→ FIN (connection close) -
R→ RST (reset)
๐ Exercises for Students
- Capture packets while browsing a website.
-
Filter only ICMP packets and run
ping. - Capture traffic for a specific port (e.g., 80).
- Save captured packets and analyze later.
- Identify TCP handshake packets (SYN, ACK).
❓ Viva Questions
-
What is
tcpdump? - What is packet sniffing?
- Why are root privileges required?
-
What is a
.pcapfile? - What are TCP flags?
⚠️ Precautions
- ⚠️ Capture only authorized network traffic (ethical use)
- Packet capture may expose sensitive data
- Use filters to limit excessive output
✅ Result
The tcpdump command is a powerful tool for capturing and analyzing network packets, essential for network troubleshooting and security analysis.
Comments
Post a Comment