TCP Ping – How to Ping a TCP Port

Tags: , , , , , , , , ,


Ping is an extremely useful utility for troubleshooting network connectivity. However, on today’s networks, icmp pings are often discarded. And with the prevalence of firewalls and load balancers it is often necessary to test the availability and response time of a particular port anyway. In this article we will use the hping utility to perform a tcp ping (ping a tcp port).

Running the TCP Ping

Hping is a network packet crafting utility. It is extremely flexible. This article only scratches the surface of what it can do.

In this example we will tcp ping a web server on tcp port 80 (-p 80) by sending it a SYN (-S) packet.

$ hping -S -p 80
HPING (eth0 S set, 40 headers + 0 data bytes
len=44 ip= ttl=47 id=10442 sport=80 flags=SA seq=0 win=5720 rtt=97.7 ms
len=44 ip= ttl=47 id=40838 sport=80 flags=SA seq=1 win=5720 rtt=97.7 ms
len=44 ip= ttl=47 id=64607 sport=80 flags=SA seq=2 win=5720 rtt=97.7 ms
len=44 ip= ttl=47 id=10443 sport=80 flags=SA seq=3 win=5720 rtt=97.7 ms
--- hping statistic ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 97.7/97.7/97.7 ms

Look familiar? The output is formatted very similarly to ping. In fact hping can perform traditional icmp echo pings as well by using the “-1” switch.

This utility has been immensely helpful in troubleshooting and documenting performance problems and testing the capabilities of firewalls. It’s also very useful for detecting when sshd comes back up after a system reboot (hint: -p 22).

More information

The hping utility is available on a wide variety of unix and windows operating systems.

Hping on Mac OSX is available using homebrew:

Hping on RedHat compatible Linux distributions is available from EPEL

Hping on debian/ubuntu is available through apt.

Hping on windows is available from the hping download site

2 Responses to “TCP Ping – How to Ping a TCP Port”

  1. Peter Says:

    To test if services published behind firewalls work as expected, i use another TCP Ping tool, which might interest you. A web-based tool for performing anIPv4 and IPv6 TCP Ping can be found here:


  2. mass ping Says:

    I wull rright away clutch your rss feed as I can’t in finding your
    email subscription hytperlink or newslertter service. Do you’ve
    any? Pleasee let me realoze so that I mayy just subscribe.


Join the Conversation