Is there a daemon which resolves a service name to a port?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















A DNS server resolves a hostname to an IP address. A program can resolve a hostname to an IP address by calling getaddrinfo() which in turn asks a DNS server to do the resolution, if I am correct.



In SysV init, is there some daemon which resolves a service name to a port, just like a DNS server? Does it do that by reading /etc/services? Does getaddrinfo() also invoke the daemon to perform the resolution?



I know that inetd reads /etc/services to decide which sockets to listen to. But inetd doesn't seem to resolve service name to port, does it?



Thanks.










share|improve this question




























    2















    A DNS server resolves a hostname to an IP address. A program can resolve a hostname to an IP address by calling getaddrinfo() which in turn asks a DNS server to do the resolution, if I am correct.



    In SysV init, is there some daemon which resolves a service name to a port, just like a DNS server? Does it do that by reading /etc/services? Does getaddrinfo() also invoke the daemon to perform the resolution?



    I know that inetd reads /etc/services to decide which sockets to listen to. But inetd doesn't seem to resolve service name to port, does it?



    Thanks.










    share|improve this question


























      2












      2








      2








      A DNS server resolves a hostname to an IP address. A program can resolve a hostname to an IP address by calling getaddrinfo() which in turn asks a DNS server to do the resolution, if I am correct.



      In SysV init, is there some daemon which resolves a service name to a port, just like a DNS server? Does it do that by reading /etc/services? Does getaddrinfo() also invoke the daemon to perform the resolution?



      I know that inetd reads /etc/services to decide which sockets to listen to. But inetd doesn't seem to resolve service name to port, does it?



      Thanks.










      share|improve this question
















      A DNS server resolves a hostname to an IP address. A program can resolve a hostname to an IP address by calling getaddrinfo() which in turn asks a DNS server to do the resolution, if I am correct.



      In SysV init, is there some daemon which resolves a service name to a port, just like a DNS server? Does it do that by reading /etc/services? Does getaddrinfo() also invoke the daemon to perform the resolution?



      I know that inetd reads /etc/services to decide which sockets to listen to. But inetd doesn't seem to resolve service name to port, does it?



      Thanks.







      services sysvinit inetd






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 17 at 13:43









      Jeff Schaller

      43.2k1159138




      43.2k1159138










      asked Feb 14 at 0:48









      TimTim

      27.5k78264476




      27.5k78264476




















          1 Answer
          1






          active

          oldest

          votes


















          4














          Note that getaddrinfo() only calls DNS if nsswitch.conf defines it. The files entry reads, directly, from /etc/hosts.



          Basically, the "name service switch" functions (NSS) look at /etc/nsswitch.conf and then may dynamically load "libnss" routines. So, for example, you might have /lib/x86_64-linux-gnu/libnss_files.so.2, which is the library loaded when files is mentioned in nsswitch.conf.



          For hosts, the nsswitch.conf line may read something like



          hosts: files dns


          This will tell the name service resolver to load the "nss_files" library (which will look in /etc/hosts) and if that fails, load the "nss_dns" library. It's that library that calls out to a DNS server.



          For services, the nsswitch.conf line may read something like



          services: files ldap


          This will load the "nss_files" library (which will look in /etc/services), and if that fails then load the "nss_ldap" library.



          There are various different backends (files, db, ldap, nis, compat, dns...) and they determine how names are resolved.



          For an inet entry such as



          service time

          ...



          the time value is looked up in the NSS map for services. If files is used in nsswitch.conf then it will see a line



          time 37/tcp timserver


          which tells inetd to bind to TCP port 37.






          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f500522%2fis-there-a-daemon-which-resolves-a-service-name-to-a-port%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            Note that getaddrinfo() only calls DNS if nsswitch.conf defines it. The files entry reads, directly, from /etc/hosts.



            Basically, the "name service switch" functions (NSS) look at /etc/nsswitch.conf and then may dynamically load "libnss" routines. So, for example, you might have /lib/x86_64-linux-gnu/libnss_files.so.2, which is the library loaded when files is mentioned in nsswitch.conf.



            For hosts, the nsswitch.conf line may read something like



            hosts: files dns


            This will tell the name service resolver to load the "nss_files" library (which will look in /etc/hosts) and if that fails, load the "nss_dns" library. It's that library that calls out to a DNS server.



            For services, the nsswitch.conf line may read something like



            services: files ldap


            This will load the "nss_files" library (which will look in /etc/services), and if that fails then load the "nss_ldap" library.



            There are various different backends (files, db, ldap, nis, compat, dns...) and they determine how names are resolved.



            For an inet entry such as



            service time

            ...



            the time value is looked up in the NSS map for services. If files is used in nsswitch.conf then it will see a line



            time 37/tcp timserver


            which tells inetd to bind to TCP port 37.






            share|improve this answer



























              4














              Note that getaddrinfo() only calls DNS if nsswitch.conf defines it. The files entry reads, directly, from /etc/hosts.



              Basically, the "name service switch" functions (NSS) look at /etc/nsswitch.conf and then may dynamically load "libnss" routines. So, for example, you might have /lib/x86_64-linux-gnu/libnss_files.so.2, which is the library loaded when files is mentioned in nsswitch.conf.



              For hosts, the nsswitch.conf line may read something like



              hosts: files dns


              This will tell the name service resolver to load the "nss_files" library (which will look in /etc/hosts) and if that fails, load the "nss_dns" library. It's that library that calls out to a DNS server.



              For services, the nsswitch.conf line may read something like



              services: files ldap


              This will load the "nss_files" library (which will look in /etc/services), and if that fails then load the "nss_ldap" library.



              There are various different backends (files, db, ldap, nis, compat, dns...) and they determine how names are resolved.



              For an inet entry such as



              service time

              ...



              the time value is looked up in the NSS map for services. If files is used in nsswitch.conf then it will see a line



              time 37/tcp timserver


              which tells inetd to bind to TCP port 37.






              share|improve this answer

























                4












                4








                4







                Note that getaddrinfo() only calls DNS if nsswitch.conf defines it. The files entry reads, directly, from /etc/hosts.



                Basically, the "name service switch" functions (NSS) look at /etc/nsswitch.conf and then may dynamically load "libnss" routines. So, for example, you might have /lib/x86_64-linux-gnu/libnss_files.so.2, which is the library loaded when files is mentioned in nsswitch.conf.



                For hosts, the nsswitch.conf line may read something like



                hosts: files dns


                This will tell the name service resolver to load the "nss_files" library (which will look in /etc/hosts) and if that fails, load the "nss_dns" library. It's that library that calls out to a DNS server.



                For services, the nsswitch.conf line may read something like



                services: files ldap


                This will load the "nss_files" library (which will look in /etc/services), and if that fails then load the "nss_ldap" library.



                There are various different backends (files, db, ldap, nis, compat, dns...) and they determine how names are resolved.



                For an inet entry such as



                service time

                ...



                the time value is looked up in the NSS map for services. If files is used in nsswitch.conf then it will see a line



                time 37/tcp timserver


                which tells inetd to bind to TCP port 37.






                share|improve this answer













                Note that getaddrinfo() only calls DNS if nsswitch.conf defines it. The files entry reads, directly, from /etc/hosts.



                Basically, the "name service switch" functions (NSS) look at /etc/nsswitch.conf and then may dynamically load "libnss" routines. So, for example, you might have /lib/x86_64-linux-gnu/libnss_files.so.2, which is the library loaded when files is mentioned in nsswitch.conf.



                For hosts, the nsswitch.conf line may read something like



                hosts: files dns


                This will tell the name service resolver to load the "nss_files" library (which will look in /etc/hosts) and if that fails, load the "nss_dns" library. It's that library that calls out to a DNS server.



                For services, the nsswitch.conf line may read something like



                services: files ldap


                This will load the "nss_files" library (which will look in /etc/services), and if that fails then load the "nss_ldap" library.



                There are various different backends (files, db, ldap, nis, compat, dns...) and they determine how names are resolved.



                For an inet entry such as



                service time

                ...



                the time value is looked up in the NSS map for services. If files is used in nsswitch.conf then it will see a line



                time 37/tcp timserver


                which tells inetd to bind to TCP port 37.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 14 at 1:23









                Stephen HarrisStephen Harris

                26.5k34779




                26.5k34779



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • 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%2funix.stackexchange.com%2fquestions%2f500522%2fis-there-a-daemon-which-resolves-a-service-name-to-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

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?