When specifying a “host name”, do we still need to specify a port?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







4















https://en.wikipedia.org/wiki/Virtual_hosting says




Name-based virtual hosts use multiple host names for the same IP address.




Does a "host name" correspond to an IP address or a pair of IP address and a port?



When specifying a "host name", do we still need to specify a port?



If that matters, consider only in virtual hosting.



Thanks.










share|improve this question































    4















    https://en.wikipedia.org/wiki/Virtual_hosting says




    Name-based virtual hosts use multiple host names for the same IP address.




    Does a "host name" correspond to an IP address or a pair of IP address and a port?



    When specifying a "host name", do we still need to specify a port?



    If that matters, consider only in virtual hosting.



    Thanks.










    share|improve this question



























      4












      4








      4








      https://en.wikipedia.org/wiki/Virtual_hosting says




      Name-based virtual hosts use multiple host names for the same IP address.




      Does a "host name" correspond to an IP address or a pair of IP address and a port?



      When specifying a "host name", do we still need to specify a port?



      If that matters, consider only in virtual hosting.



      Thanks.










      share|improve this question
















      https://en.wikipedia.org/wiki/Virtual_hosting says




      Name-based virtual hosts use multiple host names for the same IP address.




      Does a "host name" correspond to an IP address or a pair of IP address and a port?



      When specifying a "host name", do we still need to specify a port?



      If that matters, consider only in virtual hosting.



      Thanks.







      web-server virtualhost port hostname






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 12 at 12:18









      Robert Riedl

      23729




      23729










      asked Feb 11 at 16:24









      TimTim

      68231527




      68231527






















          3 Answers
          3






          active

          oldest

          votes


















          22














          Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






          share|improve this answer
























          • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

            – Tim
            Feb 11 at 16:37






          • 3





            @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

            – Romeo Ninov
            Feb 11 at 16:56






          • 2





            @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

            – MSalters
            Feb 11 at 17:39






          • 2





            @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

            – viraptor
            Feb 12 at 0:09



















          9














          A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



          An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



          The classic example is an HTTP Server using name-based virtual hosting, which works like this:




          • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

          • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

          • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


            • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

            • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



          • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






          share|improve this answer































            1














            Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



            When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



            Also DNS can have multiple IPs resolving to the same name, and vice versa.






            share|improve this answer
























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "2"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f953380%2fwhen-specifying-a-host-name-do-we-still-need-to-specify-a-port%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              22














              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






              share|improve this answer
























              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                Feb 11 at 16:37






              • 3





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                Feb 11 at 16:56






              • 2





                @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                Feb 11 at 17:39






              • 2





                @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                Feb 12 at 0:09
















              22














              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






              share|improve this answer
























              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                Feb 11 at 16:37






              • 3





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                Feb 11 at 16:56






              • 2





                @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                Feb 11 at 17:39






              • 2





                @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                Feb 12 at 0:09














              22












              22








              22







              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






              share|improve this answer













              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Feb 11 at 16:31









              Jenny DJenny D

              24.2k116196




              24.2k116196













              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                Feb 11 at 16:37






              • 3





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                Feb 11 at 16:56






              • 2





                @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                Feb 11 at 17:39






              • 2





                @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                Feb 12 at 0:09



















              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                Feb 11 at 16:37






              • 3





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                Feb 11 at 16:56






              • 2





                @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                Feb 11 at 17:39






              • 2





                @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                Feb 12 at 0:09

















              Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

              – Tim
              Feb 11 at 16:37





              Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

              – Tim
              Feb 11 at 16:37




              3




              3





              @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

              – Romeo Ninov
              Feb 11 at 16:56





              @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

              – Romeo Ninov
              Feb 11 at 16:56




              2




              2





              @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

              – MSalters
              Feb 11 at 17:39





              @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

              – MSalters
              Feb 11 at 17:39




              2




              2





              @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

              – viraptor
              Feb 12 at 0:09





              @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

              – viraptor
              Feb 12 at 0:09













              9














              A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



              An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



              The classic example is an HTTP Server using name-based virtual hosting, which works like this:




              • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

              • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

              • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



              • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






              share|improve this answer




























                9














                A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



                An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



                The classic example is an HTTP Server using name-based virtual hosting, which works like this:




                • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

                • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

                • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                  • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                  • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



                • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






                share|improve this answer


























                  9












                  9








                  9







                  A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



                  An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



                  The classic example is an HTTP Server using name-based virtual hosting, which works like this:




                  • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

                  • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

                  • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                    • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                    • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



                  • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






                  share|improve this answer













                  A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



                  An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



                  The classic example is an HTTP Server using name-based virtual hosting, which works like this:




                  • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

                  • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

                  • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                    • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                    • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



                  • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 11 at 18:22









                  IMSoPIMSoP

                  23517




                  23517























                      1














                      Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                      When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                      Also DNS can have multiple IPs resolving to the same name, and vice versa.






                      share|improve this answer




























                        1














                        Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                        When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                        Also DNS can have multiple IPs resolving to the same name, and vice versa.






                        share|improve this answer


























                          1












                          1








                          1







                          Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                          When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                          Also DNS can have multiple IPs resolving to the same name, and vice versa.






                          share|improve this answer













                          Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                          When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                          Also DNS can have multiple IPs resolving to the same name, and vice versa.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 11 at 19:51









                          Steve ButlerSteve Butler

                          837817




                          837817






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Server Fault!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f953380%2fwhen-specifying-a-host-name-do-we-still-need-to-specify-a-port%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Questions related to Moebius Transform of Characteristic Function of the Primes

                              List of scandals in India

                              Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?