hping3 Guide: Cheat Sheet, Manual Flags and Command Examples

hping3 is a command-line packet crafter. Where ping only sends ICMP echo requests, hping3 lets you send TCP, UDP, ICMP or raw IP packets with the flags, ports, TTL and payload size you choose, and then shows you how the target replied. That makes it handy for checking firewall rules, finding where packets get dropped, and seeing whether a port is open, closed or filtered.
This guide covers installing hping3 on current Linux distributions and macOS, the flags you will use most (straight from the hping3 manual), and practical examples. If you only want the one-page version, see the hping command-line cheat sheet.
Use it on your own systems. hping3 can spoof addresses and flood a host. Only point it at servers, firewalls and networks you own, or ones you have written permission to test. Flooding someone else’s host is a denial of service attack, and it is illegal in most countries.
What’s changed recently
- hping3 itself has not changed in years. The last upstream release is 3.0.0-alpha-2 (snapshot 20051105), and the antirez/hping repository has been quiet since 2014. The distributions keep it building: Debian uploaded 3.a2.ds2-10.2 in July 2026, Arch rebuilt 3.0.0-6 in July 2025, and Fedora rebuilds it each release.
- The options are the same as in 2005. Commands in older guides still work. Most mistakes in those guides are typos in the flags (for example,
-Tis traceroute mode, not TTL; TTL is lowercase-t). - No CVEs. I found no CVEs or vendor advisories for hping3 on the Debian package tracker or in the usual advisory searches. It is a test tool, so the bigger risk is running it carelessly against the wrong host.
- RHEL, Rocky and AlmaLinux need EPEL. hping3 is in Fedora and in EPEL 8 and 9, not in the base RHEL repositories. CentOS Linux itself is end of life.
- NixOS does ship hping3. The
hpingpackage in nixpkgs builds thehping3binary (from the 2014 git snapshot).
If you want something maintained alongside your other scanning tools, Nmap’s nping covers most of the same ground (more on that below).
Why is Hping3 Important?
In the Context of Cybersecurity
Firewall rules are easy to write and hard to prove. hping3 lets you send exactly the packet you want to test: a SYN to port 22 from outside, a UDP packet to port 53, a TCP packet with only the ACK flag set. The reply (SYN/ACK, RST, an ICMP error or nothing at all) tells you what your firewall or host actually did with it. You can also run it from a lab machine to see how your IDS or logging reacts to a SYN scan or a burst of traffic, before someone else tries it for real.
In the Context of Sysadmins
For day-to-day admin work, hping3 answers questions ping cannot:
- Is the server up but ICMP blocked? Send a TCP SYN to a port you know is open.
- Which hop drops my traffic? Run a TCP or UDP traceroute to the port the application uses.
- Is a NAT or load balancer doing what I expect? Watch the TTL, window size and IP ID in the replies.
Installing Hping3 on Various Systems
hping3 needs raw sockets, so run it with sudo (or as root). Without it you will see an “Operation not permitted” error when it tries to open the socket.
Debian/Ubuntu
hping3 is in the main Debian and Ubuntu repositories (Kali ships it too):
sudo apt update
sudo apt install hping3
Fedora, RHEL, Rocky and AlmaLinux
On Fedora it is in the standard repositories:
sudo dnf install hping3
On RHEL, Rocky Linux and AlmaLinux 8 or 9, enable EPEL first:
sudo dnf install epel-release
sudo dnf install hping3
(On RHEL itself, follow the EPEL instructions to enable the repository and CodeReady Builder.) At the time of writing, the Fedora package list shows hping3 for EPEL 8 and 9 but not EPEL 10.
Arch Linux
The package is called hping but it installs the hping3 binary:
sudo pacman -S hping
macOS
Homebrew has a formula called hping:
brew install hping
NixOS
The nixpkgs hping package provides hping3. For a one-off shell:
nix-shell -p hping
Or install it into your profile:
nix-env -iA nixpkgs.hping
Check the install
hping3 -v
Lowercase -v prints the version. Uppercase -V is verbose mode.
Hping Guide Command Line Examples
In these examples, replace 192.168.1.10 with a server you own. hping3 defaults to TCP to port 0 with no flags set, so most commands choose a mode and a port.
Sending ICMP Echos
The closest thing to a normal ping:
sudo hping3 -1 -c 4 192.168.1.10
-1 selects ICMP mode and -c 4 stops after four packets.
Checking a TCP Port with SYN
Send one SYN packet to port 443:
sudo hping3 -S -p 443 -c 1 192.168.1.10
How to read the reply:
flags=SA(SYN/ACK): the port is open.flags=RA(RST/ACK): the port is closed, but the host is up and nothing in the way dropped it.- No reply at all: a firewall is probably dropping the packet.
This is the quickest way to tell “service down” from “firewall blocking it”.
Scanning a Small Port Range
hping3 has a built-in scan mode (-8 or --scan) that takes a list or range of ports:
sudo hping3 -8 20-25,80,443 -S 192.168.1.10
For anything bigger than a handful of ports, Nmap is the better tool.
Testing a Firewall Rule with ACK Packets
A stateful firewall should drop a lone ACK that does not belong to an existing connection. A host with no firewall answers it with an RST:
sudo hping3 -A -p 80 -c 3 192.168.1.10
If you get RST replies through a firewall you expected to be stateful, look at your rules.
Traceroute Using TCP or UDP Packets
-T (or --traceroute) starts at TTL 1 and goes up one hop per packet. Pairing it with a TCP SYN to the port your application uses shows where that traffic stops, even when ICMP is blocked:
sudo hping3 -T -S -p 443 192.168.1.10
Or with UDP packets (-2 selects UDP mode):
sudo hping3 -T -2 -p 33434 192.168.1.10
Add --tr-stop to stop at the first reply that is not an ICMP time exceeded message, or --tr-keep-ttl to keep watching a single hop.
Setting the TTL by Hand
Lowercase -t sets the TTL of outgoing packets. This sends packets that should expire at the third hop:
sudo hping3 -S -p 80 -t 3 -c 3 192.168.1.10
Crafting Custom ICMP Packets
-d sets the data size in bytes, which is useful for checking MTU and fragmentation behaviour:
sudo hping3 -1 -c 3 -d 1400 192.168.1.10
Controlling the Rate
By default hping3 sends one packet per second. -i changes the interval:
sudo hping3 -S -p 80 -i u100000 192.168.1.10
That is one packet every 100,000 microseconds (10 per second). --fast is a shortcut for 10 packets per second and --faster for 100.
Flood Attack Simulation
--flood sends packets as fast as the machine can and does not show replies:
sudo hping3 --flood -S -p 80 192.168.1.10
Only run this against your own lab hardware, on a network you control, and preferably not on a link other people depend on. It can knock over small routers and fill logs quickly. Press Ctrl+C to stop it.
Command-Line Options
These are the most used switches, as listed in the hping3 usage output (hping3 -h) and the manual page.
| Command Line Switch | Description |
|---|---|
-0, --rawip | Raw IP mode. |
-1, --icmp | ICMP mode (echo request by default). |
-2, --udp | UDP mode. |
-8, --scan <ports> | Scan mode, for example --scan 1-1024 or --scan known. |
-S, --syn | Set the SYN flag. |
-A, --ack | Set the ACK flag. |
-F, --fin | Set the FIN flag. |
-R, --rst | Set the RST flag. |
-P, --push | Set the PUSH flag. |
-U, --urg | Set the URG flag. |
-p <port> | Destination port. +port increases it for each reply, ++port for each packet sent. |
-s <port> | Base source port (random by default). |
-k, --keep | Keep the source port fixed. |
-c <count> | Number of packets to send. |
-i <interval> | Wait between packets, in seconds or uX microseconds. |
--fast, --faster | 10 or 100 packets per second. |
--flood | Send as fast as possible and don’t show replies. |
-d <size> | Data (payload) size in bytes. |
-E <file> | Read the payload from a file. |
-t <ttl> | Set the IP time to live (default 64). |
-T, --traceroute | Traceroute mode (implies --bind and --ttl 1). |
-I <iface> | Interface to send from. |
-a <addr> | Spoof the source address (replies go to that address, not you). |
--rand-source | Random source address for each packet. |
-n | Numeric output, no DNS lookups. |
-q | Quiet: only print the summary. |
-V | Verbose output. |
-v | Show the version. |
Tips and Tricks
Integrating Hping3 with Wireshark or tcpdump
hping3 shows you the replies, but not what happened on the way. Run a capture on the target (or on a mirror port) while you test, so you can see whether packets arrived and what the host sent back:
sudo tcpdump -ni eth0 tcp port 443
Open the saved capture in Wireshark if you want the graphical view.
Automating Tasks with Bash Scripts
A short script can check that your firewall still blocks what it should after a change. For example, this exits with an error if port 22 answers on a public address where it should be filtered:
#!/usr/bin/env bash
# Run from outside your network, against your own public IP.
if sudo hping3 -S -p 22 -c 2 203.0.113.10 2>/dev/null | grep -q "flags=SA"; then
echo "Port 22 is open from outside" >&2
exit 1
fi
echo "Port 22 is not answering, as expected"
Spoofed Source Addresses
-a and --rand-source change the source address. Replies then go to the spoofed address, not to you, so they are mostly useful for checking that your firewall and upstream router drop spoofed traffic (anti-spoofing and BCP 38 filtering). Many ISPs drop spoofed packets before they leave your connection anyway.
Legal Considerations in Network Testing
- Only test systems you own, or ones you have written permission to test, and keep that permission on file.
- Check your hosting provider’s or cloud provider’s rules before load testing. Many require notice or ban flood tests outright.
- Keep tests short and rate limited unless the goal is a stress test in a lab.
Using Nping as a Modern Alternative
nping comes with Nmap, which is actively maintained, and covers most hping3 jobs with similar flags:
nping -c 1 --tcp -p 443 192.168.1.10
nping --icmp -c 4 192.168.1.10
If you already use the Nmap cheat sheet, nping is one less tool to install.
Troubleshooting
- “Operation not permitted” or no output at all. hping3 needs raw sockets. Run it with
sudo. - Packets go out the wrong interface. On machines with several interfaces or a VPN, hping3 may pick the wrong one. Set it with
-I eth0(or your interface name). --floodshows nothing. That is expected: flood mode does not print replies. Use-cand-ifor a test you can read.- Every port looks closed or filtered. Remember the default port is 0. Set
-pand a flag such as-S, otherwise you are sending a TCP packet with no flags to port 0.
Wrapping Up
hping3 is old but still one of the most useful tools for proving what a firewall really does. Install it from your distribution’s packages (EPEL on RHEL clones), keep -t and -T straight, read the reply flags, and only aim it at systems you are allowed to test.
Sources
- hping3 manual page (Debian)
- Kali Linux tools: hping3 (version and
hping3 -husage output) - Debian package tracker: hping3
- Fedora packages: hping3 (Fedora and EPEL versions)
- EPEL: Getting started
- Arch Linux package: hping
- Homebrew formula: hping
- MyNixOS: nixpkgs hping
- antirez/hping on GitHub
- nping manual page
Updated 19 November 2026: checked against current hping3 packages, fixed the -t and -T flags, added EPEL, Arch, macOS and NixOS install steps, more examples and a defensive testing note.