Ubuntu – One liner to check if specific port(s) is/are open

commandfirewallredisSecurityUbuntu

Redis Quick Start states:

Make sure the port Redis uses to listen for connections (by default 6379 and additionally 16379 if you run Redis in cluster mode, plus 26379 for Sentinel) is firewalled, so that it is not possible to contact Redis from the outside world.

Is there a short command to check if the ports are firewalled?

Typically, I have ufw installed on the hosts (almost always Ubuntu), but not nmap.

Best Answer

for port in 6379 16379 26379;do nc -zv 127.0.0.1 $port;done

Ofcause, you should use another server to check your firewall from the outside and not from the localhost to be sure that apps are blocked.