Get the domain name from IP address

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











up vote
0
down vote

favorite












I am using the following commands to get the domain name using the IP address



dig -x IPaddress


But it gives me some host names like ns1 etc. Is there any bash command that can give the actual domain name?







share|improve this question





















  • Can you show us what you get?
    – ctrl-alt-delor
    May 18 at 15:14










  • And what you expected.
    – ctrl-alt-delor
    May 18 at 15:25














up vote
0
down vote

favorite












I am using the following commands to get the domain name using the IP address



dig -x IPaddress


But it gives me some host names like ns1 etc. Is there any bash command that can give the actual domain name?







share|improve this question





















  • Can you show us what you get?
    – ctrl-alt-delor
    May 18 at 15:14










  • And what you expected.
    – ctrl-alt-delor
    May 18 at 15:25












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using the following commands to get the domain name using the IP address



dig -x IPaddress


But it gives me some host names like ns1 etc. Is there any bash command that can give the actual domain name?







share|improve this question













I am using the following commands to get the domain name using the IP address



dig -x IPaddress


But it gives me some host names like ns1 etc. Is there any bash command that can give the actual domain name?









share|improve this question












share|improve this question




share|improve this question








edited May 18 at 15:41









Andy Dalton

4,7561520




4,7561520









asked May 18 at 14:59









Ricky mem

102




102











  • Can you show us what you get?
    – ctrl-alt-delor
    May 18 at 15:14










  • And what you expected.
    – ctrl-alt-delor
    May 18 at 15:25
















  • Can you show us what you get?
    – ctrl-alt-delor
    May 18 at 15:14










  • And what you expected.
    – ctrl-alt-delor
    May 18 at 15:25















Can you show us what you get?
– ctrl-alt-delor
May 18 at 15:14




Can you show us what you get?
– ctrl-alt-delor
May 18 at 15:14












And what you expected.
– ctrl-alt-delor
May 18 at 15:25




And what you expected.
– ctrl-alt-delor
May 18 at 15:25










2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Using the +short option of dig you can get only the dns name.



dig -x 8.8.8.8 +short | awk -F '.' 'print $2"."$3'


There's probably a nicer way to reassemble it with awk Or just return the DNS Domain.



Have a read through the QUERY OPTIONS in man dig






share|improve this answer




























    up vote
    1
    down vote













    When I do it I get something like this



    dig +short -x $(dig +short example.com)



    I get



    host-198-51-100-0.as13285.net.



    This is not the original domain name, because the domain name system has no easy way to look it up, as the real name is not registered in the database, however the one that was returned was. It would be to expensive to ask every DNS server in the world.



    In addition there is a many to one relationship. Each IP can have many domain names (sometimes a domain name has many IP addresses, used for load balancing).






    share|improve this answer





















    • There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
      – Johan Myréen
      May 18 at 16:03










    • @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
      – ctrl-alt-delor
      May 18 at 16:32










    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%2f444630%2fget-the-domain-name-from-ip-address%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
    1
    down vote



    accepted










    Using the +short option of dig you can get only the dns name.



    dig -x 8.8.8.8 +short | awk -F '.' 'print $2"."$3'


    There's probably a nicer way to reassemble it with awk Or just return the DNS Domain.



    Have a read through the QUERY OPTIONS in man dig






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      Using the +short option of dig you can get only the dns name.



      dig -x 8.8.8.8 +short | awk -F '.' 'print $2"."$3'


      There's probably a nicer way to reassemble it with awk Or just return the DNS Domain.



      Have a read through the QUERY OPTIONS in man dig






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Using the +short option of dig you can get only the dns name.



        dig -x 8.8.8.8 +short | awk -F '.' 'print $2"."$3'


        There's probably a nicer way to reassemble it with awk Or just return the DNS Domain.



        Have a read through the QUERY OPTIONS in man dig






        share|improve this answer













        Using the +short option of dig you can get only the dns name.



        dig -x 8.8.8.8 +short | awk -F '.' 'print $2"."$3'


        There's probably a nicer way to reassemble it with awk Or just return the DNS Domain.



        Have a read through the QUERY OPTIONS in man dig







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered May 18 at 15:17









        Sir_Scofferoff

        33623




        33623






















            up vote
            1
            down vote













            When I do it I get something like this



            dig +short -x $(dig +short example.com)



            I get



            host-198-51-100-0.as13285.net.



            This is not the original domain name, because the domain name system has no easy way to look it up, as the real name is not registered in the database, however the one that was returned was. It would be to expensive to ask every DNS server in the world.



            In addition there is a many to one relationship. Each IP can have many domain names (sometimes a domain name has many IP addresses, used for load balancing).






            share|improve this answer





















            • There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
              – Johan Myréen
              May 18 at 16:03










            • @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
              – ctrl-alt-delor
              May 18 at 16:32














            up vote
            1
            down vote













            When I do it I get something like this



            dig +short -x $(dig +short example.com)



            I get



            host-198-51-100-0.as13285.net.



            This is not the original domain name, because the domain name system has no easy way to look it up, as the real name is not registered in the database, however the one that was returned was. It would be to expensive to ask every DNS server in the world.



            In addition there is a many to one relationship. Each IP can have many domain names (sometimes a domain name has many IP addresses, used for load balancing).






            share|improve this answer





















            • There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
              – Johan Myréen
              May 18 at 16:03










            • @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
              – ctrl-alt-delor
              May 18 at 16:32












            up vote
            1
            down vote










            up vote
            1
            down vote









            When I do it I get something like this



            dig +short -x $(dig +short example.com)



            I get



            host-198-51-100-0.as13285.net.



            This is not the original domain name, because the domain name system has no easy way to look it up, as the real name is not registered in the database, however the one that was returned was. It would be to expensive to ask every DNS server in the world.



            In addition there is a many to one relationship. Each IP can have many domain names (sometimes a domain name has many IP addresses, used for load balancing).






            share|improve this answer













            When I do it I get something like this



            dig +short -x $(dig +short example.com)



            I get



            host-198-51-100-0.as13285.net.



            This is not the original domain name, because the domain name system has no easy way to look it up, as the real name is not registered in the database, however the one that was returned was. It would be to expensive to ask every DNS server in the world.



            In addition there is a many to one relationship. Each IP can have many domain names (sometimes a domain name has many IP addresses, used for load balancing).







            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered May 18 at 15:25









            ctrl-alt-delor

            8,75831947




            8,75831947











            • There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
              – Johan Myréen
              May 18 at 16:03










            • @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
              – ctrl-alt-delor
              May 18 at 16:32
















            • There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
              – Johan Myréen
              May 18 at 16:03










            • @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
              – ctrl-alt-delor
              May 18 at 16:32















            There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
            – Johan Myréen
            May 18 at 16:03




            There is no need to ask every DNS server in the world. The domain name system has a way to look it up, and it's not more complicated than a forward lookup. In fact, it's very similar: instead of looking up, say, google-public-dns-b.google.com, the PTR record for the domain name 4.4.8.8.in-addr.arpa is searched hierarchically starting from arpa.
            – Johan Myréen
            May 18 at 16:03












            @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
            – ctrl-alt-delor
            May 18 at 16:32




            @Yes sorry If I suggested that it can not be done, I only mean that It can not be done, if it is not entered into the database. Searching the world is what would be needed to do it in reverse, but we don't have to do this, as sometimes there reverse lookup is added to the database.
            – ctrl-alt-delor
            May 18 at 16:32












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444630%2fget-the-domain-name-from-ip-address%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)