Can port number get masked like IP?

06
2014-04
  • user3079241

    I have one IP address which looks like this 10.0.0.1:9095 and as far as I know HTTP can only use port 80. How is this masked URL working?

  • Answers
  • Frank Thomas

    On the server side, the service (httpd, for instance) opens a port, and listens for communications on it. the service can listen on any port that is not presently in use on the system.

    IANA provides guidelines on port usage, and allowed well known protocols to reserve ports for use, HTTP [80], FTP [20,21], and SMTP [25] for instance.

    Well Known ports are those below 1024, and are generally expected to carry the protocol indicated. remember any port can carry any protocol, but some network intermediary devices may make management decisions based on these ports.

    Registered ports are between 1024 and 49151, and can be reserved for internet applications. There are many unregistered ports in this range, and many network admins choose to use them when selecting alternate ports for services to run on. As you can see from the link above, ports 9094-9099 are unreserved, making them a perfect choice.

    Ports above 49151 are called Dynamic Ports, and cannot be registered for any particular use. many ISPs block them all together. don't use them for service hosting.

    TL;DR: The admin of the site at that link choose to use an unreserved port from the Registered range. 9094-9099 are unreserved, and can be used for whatever purpose without confusion.


  • Related Question

    internet - What is the purpose of ports?
  • Griffin

    I have a few questions in regard to the following explanation of ports I found.

    The Application layer talks to the Transport layer through a port. Ports are numbered and standard applications always use the same port.

    The use of a port number allows the Transport protocol (typically TCP) to know which kind of contents is inside the packet, allowing it to know, at the reception side, to which Application protocol it should deliver the received data.

    • Why would a port number ever be used to tell what kind of application data protocol resides inside when there's not absolute guarantee?

      To my understanding, there are no restrictions to what kind of application data you send over a port (it's just a suggestion). Plus isn't the protocol data already included somewhere in the packet for this purpose?

    • Also, What happens to the data if you send HTTP or some other kind of protocol to a destination of port 25 (which expects SMTP)?

    • Third, what happens to the data if you send it to a port that isn't bound with any program, and therefore not being listened to?

    • Finally, if a port can only be bound to a single program, how can multiple programs that depend on incoming HTTP data be running on my computer at the same time?**

    Thanks in advance!


  • Related Answers
  • Daniel Pittman

    Why would a port number ever be used to tell what kind of application data protocol resides inside when there's not absolute guarantee?

    Because guessing is a terrible way to run things, and there is no way you can stop, for example, someone malicious from sending the wrong thing anyway. So, it helps in the case where everyone is playing nice, and doesn't make anything worse.

    To my understanding, there are no restrictions to what kind of application data you send over a port (it's just a suggestion).

    Correct. In fact, it isn't even a suggestion, just an agreement that a lot of people happen to share.

    Plus isn't the protocol data already included somewhere in the packet for this purpose?

    No. At least, not at the level that the port usually indicates: you know what sort of higher level IP protocol is being sent (eg: TCP, UDP), but not what the content of that is (eg: HTTP, SMTP).

    Also, What happens to the data if you send HTTP or some other kind of protocol to a destination of port 25 (which expects SMTP)?

    TCP just passes the data to the application layer, which can do anything to it that it wants. Most of the time, you just get errors. Sometimes you get exploitable security holes.

    Occasionally you get nice behaviour for incorrect clients, like the plain text HTTP errors that some HTTPS servers will give when you don't use SSL to the port.

    Third, what happens to the data if you send it to a port that isn't bound with any program, and therefore not being listened to?

    You get an ICMP error message from the receiving system. Technically, the receiver could do anything it pleased, but in practice, that is what happens.

    Finally, if a port can only be bound to a single program, how can multiple programs that depend on incoming HTTP data be running on my computer at the same time?

    When your browser makes an HTTP connection to a remote server it uses a random local port, and talks to the well known port (80 or 443) on the remote server. IN this case the is unique for each distinct outbound connection. (Though, technically, it doesn't have to be, as for the server case.)

    On the server side, when you listen, only one process can accept new connections on a port (in Unix / BSD sockets), but it can pass the established connection to other processes to service. Because the set is unique, traffic can be routed to the right connection.