0

When I was reading about web servers, I came to know that though servers listen to static port (say port 80 for http), immediately after the connection, they assign a different port and thread to process. This helps in scalability; otherwise the server cannot listen to the static port until the processing of the previous request is finished.

Now my question is that if you have a stateless firewall at the client side (I know it is not a common scenario), how can we configure this? We can allow outbound and inbound to/from the destination server at port 80. But since the target port is randomly assigned, we cannot be sure of the inbound port number. Since the firewall is stateless, it doesn't have any previous knowledge of outbound connection initiation. How do we configure this then? Thanks in advance.

1 Answer 1

1

You have a misunderstanding of the communication. The server is not assigning the high port (it’s not actually random), the client is the one doing the high port selection which in turn establishes the firewall permissions for that high port.

Nor does the server assign a new port to get off of 80 (or whatever). It continues listening on 80.

A “connection” is a quad of:

    Server IP
    Server Port (80)
    Client IP
    Client High-Port  (Dynamic)

The server listens on 80 and talks on the client defined High Port, the Client does the reverse.

There’s a whole bunch of handlers and threads involved for efficiency, but this is the essence.

1
  • Thank you. I knew that client side is having the random port, but I thought that at server side also this happens once connection is established. Now I understand - the server side port remains the same. Thank you.
    – SRaj
    Commented Sep 11, 2019 at 19:17

You must log in to answer this question.

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