I have been strugling for some time now to open ports on some Linux machines and I have followed some tutorials, which I tried in 2 different Linux VMs and failed for either, and after some research I think I have found out why this is failing.
So, what did was to download gufw, set a rule to allow inbound connections to a specific port or disabled the firewall and rebooted. After that, when I scanned with zenmap I could see that the port was still closed.
But when I used nc -l -p port I could see that the port was open. The same thing happened on port 80 when the apache server was running for that machine.
Then, I configured the firewall to deny all inbound traffic and rebooted. I started the apache service and ran nc -l -p port and then scanned with zenmap and it said port 80 and the port chosen by nc were filtered
From this I draw the following conclusions:
- Listening means that the port isn't protected by a firewall or the firewall allows inbound traffic to there and that there is a service listening on that port
- Filtered means that there may be or may not be a service listening to that port but the firewall is denying inbound traffic
- Closed means that the port isn't protected by the firewall and but there is no service/application listening on that port
So, opening a port means making it available to the outside if an application is listening. If it isn't, it will show as "closed" on nmap scans.
To sum up, if I want an application to be accessible to the outside, I have to bind it (is that the word?) to a port and then open that port on the firewall.
Is this correct? If you could add something to this I would appreciate it, I asked another question similar to this one but at the time I didn't know much about ports and firewalls, so if my conclusions are correct I can answer that question and hopefuly that will be helpful to someone.
Also, is it still possible to connect to a port in some way even if it isn't listening?