Working with open ports and connections
Checking open ports on our local and/or remote machine is often part of security and configuration auditing processes. It's something that we use to check if we can connect to some remote ports to verify that a service works, whether a firewall is configured properly, or whether routing works – just regular, everyday tasks. Of course, it can also be a part of some hacking processes, which often start by using nmap
and similar utilities to check for open ports and OS fingerprints. But, let's check how we can use utilities such as netstat
, lsof
, ss
, and nmap
to do good for our network and security.
Getting ready
Keep the client1 virtual machine powered on and let's continue using our shell. Generally speaking, if we're doing this on Ubuntu, we need to install some packages such as traceroute
and nmap
using apt-get
:
apt-get -y install traceroute nmap
If, however, we are using CentOS, we need to use yum
or dnf...