📘 Post

Enhance Network Security and Performance with hping3 commands: Packet Manipulation, Firewall Testing, and Intrusion Detection

12/20/2024 By Sanchit Agrawal 3 min read 👁 1,526 views Updated 08/21/2026

Overview – hping3 commands

hping3 commands is a versatile network tool used for testing and auditing network security and performance. It can craft and send custom TCP/IP packets and analyze the responses. Below is a comprehensive guide to its commands and parameters.

Basic Command Syntax – hping3 commands

Command
hping3 [options] [host]

Commonly Used Options

1. Packet Type Options

  • -1: ICMP mode (default is ping).
  • -2: UDP mode.
  • -3: RAW IP mode.
  • -4: Use IPv4 (default).
  • -6: Use IPv6.

2. TCP Specific Options

  • -S: Set SYN flag.
  • -A: Set ACK flag.
  • -P: Set PUSH flag.
  • -R: Set RST flag.
  • -F: Set FIN flag.
  • -U: Set URG flag.
  • -X: Set XMAS flag (FIN, PSH, URG).
  • -Y: Set YMAS flag (SYN, RST).
  • –tcp-timestamp: Enable TCP timestamp option.

3. General Packet Options

  • -p [port]: Set destination port.
  • -s [port]: Set source port.
  • -a [addr]: Spoof source address.
  • -k: Keep the same source port (don’t increment).
  • -n: Numeric output only, no resolution of hostnames.
  • -d [size]: Set packet body size.
  • -E [file]: Use a file as the packet payload.
  • -e [signature]: Add a signature to the packet payload.

4. Advanced Options

  • -c [count]: Stop after sending a specified number of packets.
  • -i [interval]: Packet sending interval (e.g., u1000 for 1000 microseconds).
  • –flood: Send packets as fast as possible.
  • –rand-source: Use random source address.
  • -q: Quiet mode, only show output on errors.
  • –traceroute: Enable traceroute mode.
  • –sign [signature]: Add signature to the packet.

5. Fragmentation and Other IP Options

  • -f: Fragment packets.
  • -x: Set the don’t fragment flag.
  • -y: Set more fragments flag.
  • –ttl [value]: Set time-to-live.
  • -r: Record route.

Example hping3 Commands

Ping a Host with ICMP

Send ICMP echo requests to check if a host is reachable.

Command
hping3 -1 google.com
hping3 Commands

Send TCP SYN Packets to a Specific Port

Perform a simple port scan by sending SYN packets.

Command
hping3 -S -p 80 example.com
image

Perform a Traceroute

Traceroute to a host using ICMP packets to determine the route packets take.

Command
hping3 --traceroute -V -1 google.com
image

Send UDP Packets to a Specific Port

Send UDP packets to test if a service is running on a specific port.

Command
hping3 --udp -p 53 example.com

Flood a Host with TCP SYN Packets

Send TCP SYN packets as fast as possible to simulate a DoS attack. Use with caution and only on networks you own or have permission to test.

Command
hping3 -S -p 80 --flood example.com

Send TCP Packets with Custom Flags

Send TCP packets with ACK, PUSH, and URG flags set to a specified host.

Command
hping3 -A -P -U example.com

Measure Bandwidth

Measure the bandwidth between two points by sending packets at a controlled rate.

Command
hping3 -1 -d 120 -i u10000 example.com
image
image

Test Firewall Rules

Send packets with specific characteristics to test if they pass through the firewall.

Command
hping3 -S -p 80 -c 3 --tcp-timestamp example.com

Fragment Packets

Send fragmented packets to test how a network handles fragmentation.

Command
hping3 -f -S -p 80 example.com

Record Route

Send packets and record the route they take through the network.

Command
hping3 -r -S -p 80 example.com

Advanced Usage Scenarios – hping3 Commands

SYN Flooding

Simulate a SYN flood attack by sending a large number of SYN packets rapidly.

Command
hping3 -S --flood -V -p 80 example.com

Sending Data from a File

Send the contents of a file as the payload of each packet.

Command
hping3 -E payload.txt -d 100 -S -p 80 example.com

Spoofing Source IP Address

Send packets with a spoofed source IP address to test network defenses.

Command
hping3 -S -a 192.168.1.1 -p 80 example.com

Summary – hping3 Commands

hping3 Commands is a highly versatile network tool used for security auditing, network testing, and performance measurement. It allows you to craft and send custom TCP/IP packets, providing detailed control over packet headers and options. While it offers powerful features, it requires a good understanding of networking concepts and responsible usage to avoid misuse. Mastering hping3 Commands can greatly enhance your ability to manage, secure, and optimize network infrastructure.

Enhance Network Security and Performance with hping3 commands: Packet Manipulation, Firewall Testing, and Intrusion Detection

This article provided insights on the topic. For latest updates and detailed guides, stay connected with Sanchit Gurukul.

Disclaimer: This article may contain information that was accurate at the time of writing but could be outdated now. Please verify details with the latest vendor advisories or contact us at admin@sanchitgurukul.com.

Your feedback matters

Was this post helpful?

0 reactions

SanchitGurukul — Technology • Education • Innovation

Discussion

0 approved comments

No approved comments yet. You can start the discussion below.

Leave a Comment

No login is required. Name and email are used for moderation/security. Your email is never displayed publicly. All comments require administrator approval.

This field is not used to determine whether a comment is safe.

Plain text only. File uploads, scripts, executable code, abuse and spam are not accepted.


Discover more from SanchitGurukul

Subscribe to get the latest posts sent to your email.

Share this article

Help others find this guide.

Namaste! I’m SG Saarthi 👋Need help learning or finding something?

Discover more from SanchitGurukul

Subscribe now to keep reading and get access to the full archive.

Continue reading