Log inSign up

Find exposed services on your server with an nmap audit

Install nmap on a second machine you control (sudo apt install nmap or sudo dnf install nmap), then run sudo nmap -sS -p- 198.51.100.24 against your own VPS and repeat it with -6 for the IPv6 address. Every port reported as open is reachable from the internet; compare that list with sudo ss -tulpn on the server and close or firewall anything you did not intend to expose. Only scan addresses you own or have written permission to test.

Topic: Security · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

Why audit ports from outside the server?

An outside scan shows the truth an attacker sees, which can differ from what you believe your firewall does. Rules get edited, a package starts a service on install, Docker publishes a container port that bypasses UFW, or an IPv6 rule was never written. Looking at the server from the inside tells you what is listening; looking from the outside tells you what is actually reachable. You need both views to be sure.

Your BitcoinVPS server has one public IPv4 and one IPv6 address and no filtering device in front of it, so whatever the operating system accepts is public. A port audit after each major change, and on a schedule, catches the surprises early.

Who am I allowed to scan?

Scan only machines you own or that you have explicit written permission to test. Port scanning someone else's network can break the law in some countries and breaks the acceptable use terms of most networks, including ours. Your own VPS addresses, a home lab and a test server you rent are fine targets.

Keep scans reasonable even on your own hardware: a full TCP sweep of one address is light, but aggressive timing against a busy production server can trip your own intrusion detection (fail2ban, CrowdSec) and ban the scanning machine. Allowlist the scanner first or expect a temporary block.

How do I install nmap?

Install it on the machine that will do the scanning, ideally a different server or your workstation, because a scan of 127.0.0.1 or of the server's own public IP from itself skips the firewall path. On Ubuntu and Debian:

sudo apt update
sudo apt install nmap
nmap --version

On Rocky Linux 9 and AlmaLinux 9 the package lives in AppStream:

sudo dnf install nmap
nmap --version

Versions differ by release; check what your repository offers with apt policy nmap or dnf info nmap. Any 7.9x build handles everything in this guide. Windows and macOS installers exist on the project site if your workstation is the scanner.

Which scan should I run first?

Start with a full TCP SYN scan of every port. It needs root because it crafts raw packets, and -Pn stops nmap from giving up when your server ignores ping:

sudo nmap -sS -Pn -p- --open -T4 198.51.100.24

The --open flag hides closed and filtered ports so the output stays short. A hardened web server usually shows only 22, 80 and 443. Without root, nmap falls back to a connect scan (-sT), which works the same way but leaves full connections in your logs.

Now repeat the scan against IPv6. Many audits stop at IPv4 and miss services that only the v6 rules expose:

sudo nmap -6 -sS -Pn -p- --open 2001:db8:4f2a::24

The scanning machine needs working IPv6 for this; test with ping -6 2001:db8:4f2a::24 first.

How do I find out what runs behind each open port?

Add version detection on the ports you found. Limiting the port list keeps the run quick:

sudo nmap -sV -Pn -p 22,80,443 198.51.100.24

The VERSION column names the software and often its release. Treat that as a hint, not gospel: banners can be changed, and distributions backport fixes without changing the upstream version string. Add the default script set for a little more detail, such as TLS certificate names and SSH host key types:

sudo nmap -sV -sC -Pn -p 22,443 198.51.100.24
nmap --script ssl-enum-ciphers -p 443 example.net
nmap --script ssh2-enum-algos -p 22 198.51.100.24

The last two show which TLS ciphers and SSH algorithms the server offers, which helps when you tighten crypto settings.

Should I scan UDP ports too?

Yes, at least the most common ones, because DNS, NTP, WireGuard and game servers all use UDP. UDP scanning is slow since closed ports often do not answer, so scan the top ports instead of all 65,535:

sudo nmap -sU -Pn --top-ports 100 198.51.100.24

Results such as open|filtered mean nmap got no reply and cannot tell whether a firewall dropped the probe or the service ignored it. Confirm on the server itself. A WireGuard port, for example, stays silent to probes by design, so a filtered result there is normal.

How do I compare the scan with what listens on the server?

Log in to the VPS and list every listening socket with the owning process:

sudo ss -tulpn

Read the Local Address column. Entries bound to 127.0.0.1 or [::1] are local only and safe. Entries on 0.0.0.0, * or [::] accept connections on every interface, so the firewall is the only thing keeping them private. Anything that shows up in both the ss list and the outside scan is public.

For each unexpected entry decide one of three fixes: stop and disable the service (sudo systemctl disable --now name), bind it to localhost in its own configuration, or block it in the firewall with UFW on Ubuntu and Debian or firewalld on Rocky and Alma. Binding to localhost is the strongest choice because it still holds if the firewall is ever switched off. The ss and netstat guide explains the columns in more depth.

How do I keep a record and spot changes?

Save each scan in all three nmap formats with a dated name, then compare runs with an ordinary diff:

mkdir -p ~/scans
sudo nmap -sS -Pn -p- --open -oA ~/scans/web1-$(date +%F) 198.51.100.24
grep -h "Ports:" ~/scans/web1-*.gnmap

The .gnmap file keeps one line per host, which is easy to diff between two dates. To run the audit weekly from your scanning machine, add a root cron entry:

sudo crontab -e
# Mondays at 04:30
30 4 * * 1 /usr/bin/nmap -sS -Pn -p- --open -oA /root/scans/web1-$(date +\%F) 198.51.100.24

Percent signs must be escaped in crontab, as shown. Review new files after each run, or wrap the command in a small script that mails you when the open port list changes. See cron jobs for scheduling details.

Why does a port show as filtered or closed when I expected open?

A filtered state means packets were dropped, usually by a firewall on the target or somewhere on the path. A closed state means the host answered but nothing listens. If a web port you expected shows closed, check that the service runs and listens on the public address, not only on localhost. If it shows filtered, review your firewall rules and remember that a ban from fail2ban or CrowdSec against the scanner IP looks exactly like a firewall drop. Some home and office connections also block outgoing traffic to unusual ports, so test from a second network before you blame the server.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-1a separate small scanner box needs very little1 vCPU, 1 GB RAM, 25 GB NVMe$3.60/mo$43.20 for 12 months

Questions about Audit open ports with nmap

Is it safe to scan my own VPS?

Yes. Scanning addresses you own is a normal audit step. Keep the timing moderate on busy servers and allowlist the scanner so your own ban tools do not block it.

Why should I not scan from the server itself?

Traffic to the server's own address never crosses the inbound firewall path in the same way, so the result can look more open than the outside view. Scan from another host to see what the internet sees.

Does a closed port mean I am safe?

A closed or filtered port is not reachable, which is good. Still check ss -tulpn on the server, because a service bound to all interfaces becomes public the moment a firewall rule changes.

Why does Docker show ports my UFW rules should block?

Docker writes its own packet filter rules for published ports, which are evaluated before UFW. Publish container ports on 127.0.0.1 and place a reverse proxy before the app, or filter in the DOCKER-USER chain.

Can nmap find vulnerabilities?

Its script engine includes checks for some known issues, but it is no replacement for keeping packages updated. Use version detection to find outdated software, then patch it with automatic security updates.