tcpdump Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

tcpdump is a powerful command-line tool used by Linux administrators and network engineers to capture and analyze network traffic in real-time. It is an essential utility for troubleshooting network problems, monitoring network activity, and understanding how network protocols work.

Linux tcpdump Command Syntax

The syntax for the tcpdump command is as follows:

Where:

  • options: These are flags and arguments that modify the behavior of tcpdump, such as filters, output formatting, and verbosity levels.
  • expression: This is a filter expression used to capture specific packets based on criteria like source or destination IP address, port, protocol, and more.

tcpdump Command Options:

  • -i: Specify the network interface to capture packets from.
  • -n: Display IP addresses and port numbers instead of hostnames and service names.
  • -c: Capture a specified number of packets and then exit.
  • -w: Save captured packets to a file instead of displaying them on the screen.
Sharpen Your Fundamentals with Free Learning

Example Usages

  • Capture all packets on the eth0 interface:

    Output:

    Explanation: This command captures all the packets on the eth0 interface and displays them on the screen.

  • Capture only ICMP packets:

    Output:

    Explanation: This command captures only ICMP packets and displays them on the screen.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Tips

  • Use the -D option to list available network interfaces.

  • Use the -X option to display packet contents in both hexadecimal and ASCII formats.

Advanced Use Cases of tcpdump Command in Linux

  • Capture packets between two specific IP addresses:

    Output:

    Explanation: This command captures packets exchanged between 192.168.1.1 and 192.168.1.2.

  • Capture packets with a specific port number:

    Output:

    Explanation: This command captures packets with a source or destination port number of 80.

  • Capture packets of a specific protocol:

    Output:

    Explanation: This command captures packets using the ICMP protocol.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • tcpdump is a powerful tool for capturing and analyzing network traffic.

  • The command supports various options and filters to target specific traffic.

  • It is an essential utility for network troubleshooting and monitoring.