How to view DNS domain only with IP number?

Asked

Viewed 90 times

1

when we ping a URL address type www.google.com the prompt returns us the IP 172.217.30.4, now I would like to know how to get the URL address only with the IP number through PHP, preferably. Thanks in advance for your understanding.

  • https://stackoverflow.com/questions/3621682/reverse-ip-find-domain-names-on-ip-address,

  • 1

    @Magichat did not understand the reason for the negative, this question asked by him does not have in SOPT.

  • @Hiagosouza is because you think I know the reason for the negativity, or you’re implying that I was the one who denied it?

  • @Magichat is that I saw your comment so I thought it had been you, if it wasn’t forgiveness.

1 answer

2

What you’re describing is a Reverse DNS Lookup.

In PHP you can use the function gethostbyaddr to resolve names through an ip. This does not mean that you will get the main domain from an ip.

<?php

    echo gethostbyaddr("172.217.30.4"); // rio01s23-in-f4.1e100.net

?>

It is necessary to do a lookup on us DNS Records to obtain this information (A, CNAME, PTR and etc). For this there is the function dns_get_record:

<?php

   echo var_dump(dns_get_record("google.com"));

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.