How can I block ports from being visible/accessible from the outside using ufw
?
If I nmap
my server I can see all my running Docker containers (all ports from 8080 to 8086), which I do not want, because I only need them locally on the system:
myuser@mysystem:~$ nmap example.com
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-22 04:21 CEST
Nmap scan report for example.com (123.123.123.123)
Host is up (0.048s latency).
Not shown: 990 filtered tcp ports (no-response)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
8080/tcp open http-proxy
8081/tcp open blackice-icecap
8082/tcp open blackice-alerts
8083/tcp open us-srv
8084/tcp open websnp
8085/tcp open unknown
8086/tcp open d-s-n
So, my approach was to block all these ports with ufw:
ufw deny 8080
ufw deny 8081
ufw deny 8082
ufw deny 8083
ufw deny 8084
ufw deny 8085
ufw deny 8086
ufw deny out 8080
ufw deny out 8081
ufw deny out 8082
ufw deny out 8083
ufw deny out 8084
ufw deny out 8085
ufw deny out 8086
ufw reload
But, if I now execute "nmap example.com" I can still see all open ports. What must be done to block these ports?