Your server has 65535 ports whatever the OS installed on your server.

As a reminder, the ports are used by the TCP and UDP protocols of the transport layer of the OSI model.

The nmap tool is very useful to check the ports you have left open on your server:

It is of course preferable to leave only the desired ports open by closing the others via a firewall (iptables for example on Linux).

# Nmap scan par défaut tous les ports jusqu'au 1024 inclus
# Un exemple de sortie :
Starting Nmap 6.40 ( ) at 2020-02-10 14:02 UTC
Nmap scan report for (XXX.XXX.XXX.XXX)
Host is up (0.022s latency).
Other addresses for (not scanned): XXX.XXX.XXX.XXX
Not shown: 997 filtered ports
22/tcp  open  ssh
80/tcp  open  http
443/tcp open  https

To test specific ports, use the -p option:

nmap -p 22
# Du port 1500 au port 1884 :
nmap -p 1500-1884
# Tous les ports :
nmap -p-
# Une liste de ports :
nmap -p 22,25,80,81,443 <YOUR_SERVER_IP>

By default, nmap scans TCP ports. However, you may want to check the status of these UDP ports, because your firewall has allowed a UDP port. This is possible with the -sU option (UDP scan):

nmap -sU -p 255

Here’s a little tip:

nmap -sS -p 22,25,80,81,443 <YOUR_SERVER_IP>

The -sS option allows to do a TCP scan with a “half-handshake”, so the TCP connection is not established: the scan sends a connection request packet to the server and as soon as the server answers, nmap sends a RST (reset) indicating an abnormal break of the connection. Therefore your scan should not be logged on the target server.

But this is useful for hacker bichons, if a hacker bichon passes by here… 😀

Partager sur les réseaux