Linking an IP to a port number
I received a question today through my Sarasota Web Guy Q&A site today that I thought I would share with everyone. It's a question related to DNS and how IP addresses are published, so I can only assume this came from a DtDNS user:
"Hi Justin, Question: I want to assign an 'A' record to point not only to a specific IP address but also to a specific port number 'xx' (i.e., 000.000.000.000:xx). Is this possible? Cheers, Rick"
Well Rick, there are two parts to the answer. The first is that DNS only translates names to IP addresses. It has no concept of ports. The client software (a web browser, for example), will ask the operating system's stub DNS resolver what IP goes with the name the user entered. It begins the lookup process until an authoritative DNS server for the name entered gives back a response (or it may use a previously cached response). Once the stub resolver has this information, it passes the resulting IP address back to the client software.
The port that is used to connect isn't related to DNS, so the client software will either use a default port (80 or 443 in the case of a web browser, 21 for FTP, etc.) or a custom port supplied by a user. Since DNS doesn't involve ports, you cannot append a port number to the IP address in the DNS records like you're asking about.
However, many people want to run web servers on their home connection, but the provider has likely blocked port 80 for incoming connections. There are a couple of ways around this. The first is to ensure that anyone linking to your site includes an alternate port (that you have configured your server to listen on) in the URL. This would cause the web browser of visitors to use a custom port instead of the default port. This would be in the format:
http://www.example.com:8888/some-file.html
The 8888 in this example would be replaced with your alternate port number. If you're using DtDNS, you can use the "offline" feature in conjunction with a URL redirector to direct visitors to an alternate domain or hostname with the custom port number included as part of the redirection. The DtDNS FAQ covers this in more detail. I don't recommend doing this for any sort of mission-critical or public website, but it's an ok workaround for accessing a personal server at home if your provider blocks port 80.
I hope this information helps, but feel free to ask additional questions at Sarasota Web Guy and I'll try my best to give a clear answer. Thanks!
Rick Tavares, Ph.D. ~ Jun 3, 2010 at 4:01 PM
Justin Scott ~ Jun 3, 2010 at 5:01 PM