Suppose, I type the website name www.yahoo.com in my browser. Forward DNS lookup will fetch us the IP address of the server but how does the client (browser) know the port number that the application is running on?
1 Answers
As long as we talk about web browsing it is rather trivial.
Suppose you write http://example.com. The browser will then connect to port 80. Likewise https://example.com will connect to port 443.
A web server can also be configured to run on an alternate port instead (like for instance port 8080).
In that case you need to write: http://example.com:8080/ (or https if the site is encrypted).
However there are other times when you use different applications to connect to a service like IMAP, SMTP, SIP (IP telephone) or the like.
It is possible to enter hostname, port numbers etc manually, but for the not so tech savy people, they prefer as much plug&play as possible.
DNS has the answer: Service records!
For instance you could have the following DNS entries:
_imap._tcp.example.com IN SRV mail.example.com 10 60 143 43200
_smtp._tcp.example.com IN SRV mail.example.com 10 60 25 43200
mail.example.com IN A 1.2.3.4
The way it works is say you have an email address user@example.com. When you setup your mail client for the first time it will initially ask what is your username and password and find out the rest on it's own.
The mail client will in turn do a DNS lookup saying: "Where is the IMAP service for example.com?"
DNS will reply back: "The host mail.example.com has the IMAP service and it is running on port 143".
The following DNS entry says: mail.example.com has the IP address 1.2.3.4.
And the same procedure goes for SMTP.
From end users point-of-view all they see is they were ask for username and password and the next thing was the mail client said: "Everything has been setup.You are good to go.".
Wikipedia has a nice explanation of SRV records in more details that what I can write here.
- 1,293