1

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?

2 Answers 2

5

A port is just a concept for a connection between an application and a layer-4 protocol. There really isn't a "port" as such. When an application wants to receive traffic from a layer-4 protocol (TCP, UDP, etc.), it requests that the protocol send any layer-4 segments for that protocol which are addressed with a particular port number to the application.

When a layer-4 protocol has no application which has requested that layer-4 segments addressed to a particular port number, the port is Closed.

When an application has requested and been granted the use of a port number by a layer-4 protocol, the port is Open.

Firewalls can be set to drop layer-3 packets containing layer-4 segments for a particular layer-4 protocol addressed to a particular port. This means that the port is Filtered or Blocked on the firewall.

Each layer-4 protocol has its own ports, or it many not even use ports. For instance, one application can be receiving traffic for TCP 12345, and another application can be receiving traffic for UDP port 12345; they are not the same port because ports don't actually exist. The use of a particular port number on a particular layer-4 protocol is exclusive to the application granted use of the port by the layer-4 protocol.

0

man nmap

The output from Nmap is a list of scanned targets, with supplemental information on each depending on the options used. Key among that information is the “interesting ports table”.. That table lists the port number and protocol, service name, and state. The state is either open, filtered, closed, or unfiltered. Open. means that an application on the target machine is listening for connections/packets on that port. Filtered. means that a firewall, filter, or other network obstacle is blocking the port so that Nmap cannot tell whether it is open or closed. Closed. ports have no application listening on them, though they could open up at any time. Ports are classified as unfiltered. when they are responsive to Nmap's probes, but Nmap cannot determine whether they are open or closed. Nmap reports the state combinations open|filtered. and closed|filtered. when it cannot determine which of the two states describe a port. The port table may also include software version details when version detection has been requested. When an IP protocol scan is requested (-sO), Nmap provides information on supported IP protocols rather than listening ports.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .