Life's random bits By b1thunt3r (aka Ishan Jain)…
Test TCP connections with cURL

Test TCP connections with cURL

Ishan jain
Sometimes ping is not just enough, you need to bring TCP along.

Update: Added heredoc and pipe examples for automating the command.

With DDoS on the rise, most systems are disabling possibility to ping. But there are times, you just need to check connectivity to certain services.

If the service we need to check is running on TCP, we can you cURL to achieve the (almost) same result. The only think missing will be the "ping" time.

In bash:

HOST=example.com; PORT=443; curl -v telnet://$HOST:$PORT

Note: You will need to use CTRL+C to break out of the telnet session.

We can use heredoc to automate this:

HOST=example.com; PORT=443; curl -v telnet://$HOST:$PORT <<EOF
quit
EOF

Or we can pipe quit command:

HOST=example.com; PORT=443; echo quit | curl -v telnet://$HOST:$PORT