NetCat - Check Open Ports

If you want to check if a Port on a remote server is open or closed, you can use netcat. This is a better and more modern alternative to the telnet method from the past.

Check Single Port

You need to provide the parameter -v, otherwise you will not get output, even if the connection was successful.

[tux@server]$ nc -v <servername or ip> <port>
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to<port>.

If you provide Parameter -z you will check to port without establishing a connection.

Check Port Range

You can also scan a range of ports like so

# Scan ports 1 to 100
[tux@server]$ nc -v <servername or ip> 1-100

If you only want the successful connections, you can filter the output with grep

[tux@server]$ nc -v <servername> 1-100 | grep succeeded
profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.