views:

95

answers:

3

Which of the following ports is the best one to use for a program I'm working on using a custom protocol still under development. I'm looking for one that will be accessible to virtually every host that is connected to the public internet (ie every host that can view websites can use this port). The three main options are:

  • port 53 udp (dns)
  • port 80 tcp (http)
  • port 443 tcp (https)

Which of these is most widely accessible over the internet, including all isps, corporate firewalls, etc.

+1  A: 

Not port 53. Toss-up between 80 and 443. If you make your protocol look sufficiently like HTTPS that a proxy will forward it the same way, then maybe 443 is your best choice.

james woodyatt
thanks, port 53 can't go through proxies that have internal dns, https port 443 is probably the best as transparent proxies can't modify it (without generating errors in browsers for https users behind the firewall) unlike port 80 where they might try caching it and modifing http headers so on and so mess up my data
David Kumu
+10  A: 

All of those ports are used by well-known services, and you should use none of them (if your product is not a webserver or a DNS server.) DCCP Well Known ports SHOULD NOT be used without IANA registration. If your service is commercially viable or has benefits for the network as a whole, consider registering it for a lower port number: The registration procedure is defined in RFC4340, Section 19.9.

For experimental use, use a port between 1024 and 49151. Remember that even those ports should be registered with the IANA as soon as your service goes "live".

Regarding firewalls: You cannot predict if your service will be available to any network at all. Even if you use port 80, you probably will run against firewalls that do content checking.

Martin Hohenberg
I posted an answer that said the same thing, but deleted it before I saw your answer. You put it so much better so I didn't bother to resurrect mine.
ChrisF
As much as I appreciate the sentiment, I have to downvote this because it answers the wrong question. The question was about choosing a port to maximize reachability of a service on the public Internet. It is a fact that many hosts on private networks have limited access to public Internet services. Many have access only to tcp/80 and tcp/443, with application layer proxies that interfere heavily on tcp/80.
james woodyatt
+1  A: 

As all the ports you've nominated are used for particular well-specified protocols, it's a very bad idea to use these for a different protocol. There's a convention that for a well-known port, there's a corresponding protocol, and if you break this convention, then at the least you're going to cause confusion, and at worst be suspected of nefarious intentions and be blocked. Martin's answer points you in the right direction.

Brian Agnew
I agree with you that it's a dangerous game, but it's also sometimes necessary in order to make your service available from within a very restricted network. IIRC, AIM will attempt to use a bunch of different ports to get out if its normal ports are blocked. I've seen it settle on both port 80 and port 23. A number of filesharing apps use this technique as well.
rmeador
If it's a restricted network, trying to circumvent that can lead to bad things. Like expulsion, firing, and/or civil or criminal penalties. Do not attempt to work around policy with technology. Been there, done that, got the t-shirt.
Randal Schwartz