How to detect filtered (and opened) outgoing ports on a network?

May 16, 2023 by Thibault Debatty | 108 views

Sysadmin Offensive Security

Sometimes you want to access services running on unusual ports, like a SSH server running on port 2222 for example. If connection fails, how can we detect the outgoing ports that are filtered or open on the network?

Well, there is a solution:

This server listens on all ports for incoming connections. So you can test for filtered outgoing ports using nmap, netcat, wget or curl. And on windows you can use powershell.

Test with nmap

To test a single port:

nmap -p 1234

Test popular ports:


To test all ports (very slow):

nmap -p-

Test with netcat, curl or wget


nc -v 1234




wget -qO-


Test on Windows

PS C:\> Test-NetConnection -InformationLevel detailed -ComputerName -Port 80

How it works ?

On this server, there is actually a single (and simple) web server running on port 80. And there is an iptables rule to redirect other ports to this web server:

iptables -t nat -A PREROUTING -p tcp -j DNAT --to-destination :80

You can find the details on the blog post of the author: