Verbose DNS query to see DNS query order?

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











up vote
3
down vote

favorite












I typically determine the IP of a host by doing: $ host -t A example.com. Is there a more verbose version of this that tells me what's happening in the background, specifically the order of what is queried (/etc/hosts 1st, dns server 2nd)?



As many people can attest to, OS X Lion resolves local /etc/hosts entries painfully slowly, and I'd like to see what bottlenecks are causing this. Seems like in theory, /etc/hosts should be queried first and name resolution should happen instantaneously for manually entered hosts.










share|improve this question



























    up vote
    3
    down vote

    favorite












    I typically determine the IP of a host by doing: $ host -t A example.com. Is there a more verbose version of this that tells me what's happening in the background, specifically the order of what is queried (/etc/hosts 1st, dns server 2nd)?



    As many people can attest to, OS X Lion resolves local /etc/hosts entries painfully slowly, and I'd like to see what bottlenecks are causing this. Seems like in theory, /etc/hosts should be queried first and name resolution should happen instantaneously for manually entered hosts.










    share|improve this question

























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I typically determine the IP of a host by doing: $ host -t A example.com. Is there a more verbose version of this that tells me what's happening in the background, specifically the order of what is queried (/etc/hosts 1st, dns server 2nd)?



      As many people can attest to, OS X Lion resolves local /etc/hosts entries painfully slowly, and I'd like to see what bottlenecks are causing this. Seems like in theory, /etc/hosts should be queried first and name resolution should happen instantaneously for manually entered hosts.










      share|improve this question















      I typically determine the IP of a host by doing: $ host -t A example.com. Is there a more verbose version of this that tells me what's happening in the background, specifically the order of what is queried (/etc/hosts 1st, dns server 2nd)?



      As many people can attest to, OS X Lion resolves local /etc/hosts entries painfully slowly, and I'd like to see what bottlenecks are causing this. Seems like in theory, /etc/hosts should be queried first and name resolution should happen instantaneously for manually entered hosts.







      networking osx dns dnsmasq






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 23 '16 at 11:10









      Jeff Schaller

      32.6k849110




      32.6k849110










      asked May 14 '12 at 18:56









      mmla

      485147




      485147




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          Since Apple has done away with nsswitch.conf in Lion, you can view the resolver order with scutil --dns.



          My guess is you will see "DNS" listed before "local".



          It's a bit of a hack, but you can install DNSMasq on your OS X host and have your system query it for DNS resolution. DNSMasq can read /etc/hosts first and serve up the entries it finds there before searching DNS. This restores the proper order to resolution.



          The gentleman who wrote this blog has done all of the hard work for you. He describes how to install DNSMasq and configure it on OS X Lion.






          share|improve this answer




















          • This is very helpful. Thank you!
            – mmla
            May 15 '12 at 3:53






          • 1




            ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
            – Shadur
            May 15 '12 at 8:25










          • @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
            – Shadok
            May 15 '12 at 12:09










          • @Shadur Ask Different. apple.stackexchange.com :)
            – George M
            May 15 '12 at 12:48

















          up vote
          0
          down vote













          I find dig particularly useful in that realm. The default output is verbose and shows what is being done (what gets sent and what is received.)



          There is an example:



          alex$ dig m2osw.com

          ; <<>> DiG 9.10.3-P4-Ubuntu <<>> m2osw.com
          ;; global options: +cmd
          ;; Got answer:
          ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52965
          ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

          ;; OPT PSEUDOSECTION:
          ; EDNS: version: 0, flags:; udp: 512
          ;; QUESTION SECTION:
          ;m2osw.com. IN A

          ;; ANSWER SECTION:
          m2osw.com. 85160 IN A 138.197.205.139

          ;; Query time: 18 msec
          ;; SERVER: 75.75.75.75#53(75.75.75.75)
          ;; WHEN: Sun Aug 19 18:02:58 PDT 2018
          ;; MSG SIZE rcvd: 54

          alex$





          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f38665%2fverbose-dns-query-to-see-dns-query-order%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            Since Apple has done away with nsswitch.conf in Lion, you can view the resolver order with scutil --dns.



            My guess is you will see "DNS" listed before "local".



            It's a bit of a hack, but you can install DNSMasq on your OS X host and have your system query it for DNS resolution. DNSMasq can read /etc/hosts first and serve up the entries it finds there before searching DNS. This restores the proper order to resolution.



            The gentleman who wrote this blog has done all of the hard work for you. He describes how to install DNSMasq and configure it on OS X Lion.






            share|improve this answer




















            • This is very helpful. Thank you!
              – mmla
              May 15 '12 at 3:53






            • 1




              ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
              – Shadur
              May 15 '12 at 8:25










            • @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
              – Shadok
              May 15 '12 at 12:09










            • @Shadur Ask Different. apple.stackexchange.com :)
              – George M
              May 15 '12 at 12:48














            up vote
            3
            down vote













            Since Apple has done away with nsswitch.conf in Lion, you can view the resolver order with scutil --dns.



            My guess is you will see "DNS" listed before "local".



            It's a bit of a hack, but you can install DNSMasq on your OS X host and have your system query it for DNS resolution. DNSMasq can read /etc/hosts first and serve up the entries it finds there before searching DNS. This restores the proper order to resolution.



            The gentleman who wrote this blog has done all of the hard work for you. He describes how to install DNSMasq and configure it on OS X Lion.






            share|improve this answer




















            • This is very helpful. Thank you!
              – mmla
              May 15 '12 at 3:53






            • 1




              ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
              – Shadur
              May 15 '12 at 8:25










            • @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
              – Shadok
              May 15 '12 at 12:09










            • @Shadur Ask Different. apple.stackexchange.com :)
              – George M
              May 15 '12 at 12:48












            up vote
            3
            down vote










            up vote
            3
            down vote









            Since Apple has done away with nsswitch.conf in Lion, you can view the resolver order with scutil --dns.



            My guess is you will see "DNS" listed before "local".



            It's a bit of a hack, but you can install DNSMasq on your OS X host and have your system query it for DNS resolution. DNSMasq can read /etc/hosts first and serve up the entries it finds there before searching DNS. This restores the proper order to resolution.



            The gentleman who wrote this blog has done all of the hard work for you. He describes how to install DNSMasq and configure it on OS X Lion.






            share|improve this answer












            Since Apple has done away with nsswitch.conf in Lion, you can view the resolver order with scutil --dns.



            My guess is you will see "DNS" listed before "local".



            It's a bit of a hack, but you can install DNSMasq on your OS X host and have your system query it for DNS resolution. DNSMasq can read /etc/hosts first and serve up the entries it finds there before searching DNS. This restores the proper order to resolution.



            The gentleman who wrote this blog has done all of the hard work for you. He describes how to install DNSMasq and configure it on OS X Lion.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 14 '12 at 20:30









            George M

            8,79623247




            8,79623247











            • This is very helpful. Thank you!
              – mmla
              May 15 '12 at 3:53






            • 1




              ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
              – Shadur
              May 15 '12 at 8:25










            • @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
              – Shadok
              May 15 '12 at 12:09










            • @Shadur Ask Different. apple.stackexchange.com :)
              – George M
              May 15 '12 at 12:48
















            • This is very helpful. Thank you!
              – mmla
              May 15 '12 at 3:53






            • 1




              ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
              – Shadur
              May 15 '12 at 8:25










            • @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
              – Shadok
              May 15 '12 at 12:09










            • @Shadur Ask Different. apple.stackexchange.com :)
              – George M
              May 15 '12 at 12:48















            This is very helpful. Thank you!
            – mmla
            May 15 '12 at 3:53




            This is very helpful. Thank you!
            – mmla
            May 15 '12 at 3:53




            1




            1




            ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
            – Shadur
            May 15 '12 at 8:25




            ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ?
            – Shadur
            May 15 '12 at 8:25












            @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
            – Shadok
            May 15 '12 at 12:09




            @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand...
            – Shadok
            May 15 '12 at 12:09












            @Shadur Ask Different. apple.stackexchange.com :)
            – George M
            May 15 '12 at 12:48




            @Shadur Ask Different. apple.stackexchange.com :)
            – George M
            May 15 '12 at 12:48












            up vote
            0
            down vote













            I find dig particularly useful in that realm. The default output is verbose and shows what is being done (what gets sent and what is received.)



            There is an example:



            alex$ dig m2osw.com

            ; <<>> DiG 9.10.3-P4-Ubuntu <<>> m2osw.com
            ;; global options: +cmd
            ;; Got answer:
            ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52965
            ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

            ;; OPT PSEUDOSECTION:
            ; EDNS: version: 0, flags:; udp: 512
            ;; QUESTION SECTION:
            ;m2osw.com. IN A

            ;; ANSWER SECTION:
            m2osw.com. 85160 IN A 138.197.205.139

            ;; Query time: 18 msec
            ;; SERVER: 75.75.75.75#53(75.75.75.75)
            ;; WHEN: Sun Aug 19 18:02:58 PDT 2018
            ;; MSG SIZE rcvd: 54

            alex$





            share|improve this answer
























              up vote
              0
              down vote













              I find dig particularly useful in that realm. The default output is verbose and shows what is being done (what gets sent and what is received.)



              There is an example:



              alex$ dig m2osw.com

              ; <<>> DiG 9.10.3-P4-Ubuntu <<>> m2osw.com
              ;; global options: +cmd
              ;; Got answer:
              ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52965
              ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

              ;; OPT PSEUDOSECTION:
              ; EDNS: version: 0, flags:; udp: 512
              ;; QUESTION SECTION:
              ;m2osw.com. IN A

              ;; ANSWER SECTION:
              m2osw.com. 85160 IN A 138.197.205.139

              ;; Query time: 18 msec
              ;; SERVER: 75.75.75.75#53(75.75.75.75)
              ;; WHEN: Sun Aug 19 18:02:58 PDT 2018
              ;; MSG SIZE rcvd: 54

              alex$





              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                I find dig particularly useful in that realm. The default output is verbose and shows what is being done (what gets sent and what is received.)



                There is an example:



                alex$ dig m2osw.com

                ; <<>> DiG 9.10.3-P4-Ubuntu <<>> m2osw.com
                ;; global options: +cmd
                ;; Got answer:
                ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52965
                ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

                ;; OPT PSEUDOSECTION:
                ; EDNS: version: 0, flags:; udp: 512
                ;; QUESTION SECTION:
                ;m2osw.com. IN A

                ;; ANSWER SECTION:
                m2osw.com. 85160 IN A 138.197.205.139

                ;; Query time: 18 msec
                ;; SERVER: 75.75.75.75#53(75.75.75.75)
                ;; WHEN: Sun Aug 19 18:02:58 PDT 2018
                ;; MSG SIZE rcvd: 54

                alex$





                share|improve this answer












                I find dig particularly useful in that realm. The default output is verbose and shows what is being done (what gets sent and what is received.)



                There is an example:



                alex$ dig m2osw.com

                ; <<>> DiG 9.10.3-P4-Ubuntu <<>> m2osw.com
                ;; global options: +cmd
                ;; Got answer:
                ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52965
                ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

                ;; OPT PSEUDOSECTION:
                ; EDNS: version: 0, flags:; udp: 512
                ;; QUESTION SECTION:
                ;m2osw.com. IN A

                ;; ANSWER SECTION:
                m2osw.com. 85160 IN A 138.197.205.139

                ;; Query time: 18 msec
                ;; SERVER: 75.75.75.75#53(75.75.75.75)
                ;; WHEN: Sun Aug 19 18:02:58 PDT 2018
                ;; MSG SIZE rcvd: 54

                alex$






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 20 at 1:04









                Alexis Wilke

                854614




                854614



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f38665%2fverbose-dns-query-to-see-dns-query-order%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    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?