Ubuntu 20.04 LTS Server Edition
Checking the Server For Unwanted Inbound Paths

Updated 27 July 2021


When deploying a server that faces the Internet with a public IP address, one needs to verify that only those services that are intended to be accessible by the world at large are indeed accessible. Two tools give you visibility to what is exposed to the outside world: netstat(8) and nmap(1) .

When you find a port that is open to the world that shouldn't be, you will need to look at the service that is opening the port, and pay particular attention to what interfaces that service binds the port to. (Ending with a preposition — Ed) The first place to look is in the configuration file for that service. Many common services, like BIND9, DOVECOT, and SSH use "Listen" directives, or something like them. Postfix uses a different scheme: the IP address of the interface you to which you want to bind the port is prefixed to the service name, separated by a colon.

For some services, though, you will need to look into the systemd files: suffix unit and/or socket. The man files describe how to bind a service to a single interface.


netstat(8): Run this command as root on the server to be examined. The command lists the ports available to the outside world. Run it twice, once for TCP ports and once for UDP ports.


nmap(8): Run this command as root on another computer. The command lists the ports available to the outside world. Run it twice, once for TCP ports and once for UDP ports.


That's how a server builder can run an initial pen test on a new or updated server. This is a low-cost alternative to having a pen tester service try to break in using unexpected public ports. Using a pen tester service is still recommended just before a server is put into production, in case there are other flaws (like zero-day exploits) that would provide an entry point to ne'er-do-wells.


Comments, suggestions, and error reports are welcome.
Send them to: spamfilter (at) satchell (dot) net)
© 2021 Stephen Satchell, Reno NV