lostprophetpunk Posted August 18, 2009 Share Posted August 18, 2009 I know how to get an ip adress from a domain by using gethostbyname(), but I wanted to know if it was possible to get the domain name from the ip address. As in a website address (example.com) has a ip address of xxx.xx.xxx.xxx What I am trying to do is to get the 'example.com' domain name from the ip address. Is this at all possible, if so, how can it be done? Thanks in advance for any that helps out. Quote Link to comment https://forums.phpfreaks.com/topic/170798-getting-domain-name-from-ip-address/ Share on other sites More sharing options...
DEVILofDARKNESS Posted August 18, 2009 Share Posted August 18, 2009 <?php $ip = $REMOTE_ADDR;//capture IP $domain = GetHostByName($ip); ?> it works in two directions I guess Quote Link to comment https://forums.phpfreaks.com/topic/170798-getting-domain-name-from-ip-address/#findComment-900756 Share on other sites More sharing options...
lostprophetpunk Posted August 18, 2009 Author Share Posted August 18, 2009 <?php $ip = $REMOTE_ADDR;//capture IP $domain = GetHostByName($ip); ?> it works in two directions I guess I forgot to mention (sorry) that I have tried this already, but all it echos is the ip address. Quote Link to comment https://forums.phpfreaks.com/topic/170798-getting-domain-name-from-ip-address/#findComment-900764 Share on other sites More sharing options...
sahaya Posted June 2, 2011 Share Posted June 2, 2011 <?php $ip = $REMOTE_ADDR;//capture IP $domain = GetHostByName($ip); ?> it works in two directions I guess you can get the domain from ip. check this site http://www.whoisxy.com to get the information. Quote Link to comment https://forums.phpfreaks.com/topic/170798-getting-domain-name-from-ip-address/#findComment-1223928 Share on other sites More sharing options...
xyph Posted June 2, 2011 Share Posted June 2, 2011 Multiple domains can easily be hosted on the same IP, making this difficult. Quote Link to comment https://forums.phpfreaks.com/topic/170798-getting-domain-name-from-ip-address/#findComment-1223930 Share on other sites More sharing options...
ignace Posted June 2, 2011 Share Posted June 2, 2011 I know how to get an ip adress from a domain by using gethostbyname(), but I wanted to know if it was possible to get the domain name from the ip address. Yes, use gethostbyaddr Quote Link to comment https://forums.phpfreaks.com/topic/170798-getting-domain-name-from-ip-address/#findComment-1223939 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.