0

I am trying to link a website to a particular opened port. However, using both netstat and lsof, I found that when I open a single website on firefox (say facebook), there are multiple process and ports opened.I don't understand why a single website open multiple processes and ports? Should it not be that one application associates with one single process and port number? Could anyone please suggest me, how is it possible to identify a website using the process id and port used ? As mentioned above, I have tried netstat and lsof, which gives multiple process id and port number which makes it hard to uniquely identify the website.

Thank you

bislinux
  • 193
  • 2
  • 3
  • 12

1 Answers1

0

If you are the server providing services, the port is manage by you and the service example http is 80, https is 443.

In the other hand if you are the client, your browser will use an available port, that means that the port you use is not going to be the same and is not going to be 80 or 443.

Websites can have content from many sources, images can be on a server, javascript, css can be on another server and the main content must be from the actual web-site.

Hope it helps.

Vidal
  • 2,605
  • 2
  • 16
  • 32
  • But should my request not go to main server first? Eg: If I type a facebook on my browser, it should open a port & send the request from one single port to one server(considering DNS query is done). On the server it constructs the requested page from respective sources such as image source,css .Is this not correct? If not, does it mean that when i input the website name on the browser and get the IP from DNS query , the browser it sends that request to multiple servers?But then how does it reconstruct the page? It is a bit confusing now. This working concept would be very useful. Thank you – bislinux Dec 17 '19 at 14:13
  • 1
    you enter facebook.com > it got resolve to 157.240.22.35 once on facebook.com it will request (the page) content from all king of places and sources. for example some images came from pixel.facebook.com, recaptcha from google.com (to validate that you are not a robot), gstatic.com (google static css server), static.xx.fbcdn.net (facebook static content javascript) and this are a few of the hundreds that may be included in a page like facebook.com. Use your browser developer tools and g oto network and you will see all the requests that a page make to be able to render to the user. – Vidal Dec 17 '19 at 14:24
  • Ah That definitely cleared the server side. Thank you for that. But on the client side: I enter facebook.com, DNS query resolves to 157.240.22.35. My browser should than open a single port 23456 and send the request to 157.240.22.35. But when i look at the trace of my browser using netstat/lsof/ssldump etc, it shows multiple ports have been opened by my browser. That is why i am confused as to how to tag one open port to facebook.com? – bislinux Dec 17 '19 at 14:41
  • 1
    Yep your browser is going to pick a port 23456 for example, as mention before your browser may make more than one connection to the server. that's why you see multiple connections. A regular http/https request is going to die after the data is sent, but we also have websockets that leave the connection open so the server can send data anytime to the client like the alert and messages at least that is the case with facebook and mayor companies. – Vidal Dec 17 '19 at 16:00