...
Skip to main content
Print

How to Check Open Ports on Your Server

With ss -tulpn you see on a Linux server which services listen on which port. With nmap you check from your own computer which ports are really reachable from outside. Every open port is a possible entry point for attackers. So check regularly what is open.

Viewing listening ports on Linux

ss -tulpn

Pay attention to the address in front of the port. If it says 127.0.0.1, the service is only reachable locally. If it says 0.0.0.0 or an asterisk, it listens on all addresses.

Scanning from outside with nmap

Install nmap on your own computer and scan your server:

nmap -Pn JOUW-IP

Only scan servers that belong to you.

Viewing ports on Windows Server

Get-NetTCPConnection -State Listen | Sort-Object LocalPort

Closing an unnecessary port

  • Stop the service if you do not use it, for example with systemctl disable --now dienstnaam.
  • Or block the port in the firewall with UFW or CSF.

Related articles

Table of Contents