I have a number of sites on a shared server in america, and none of them seem to be able to do reverse dns lookups on that server. Things like webserver logs and suchlike which usually give you a hostname and ip address only have the ip address listed.
I'm guessing there is some sort of software that needs to be installed/enabled on the server. If so, can I install it without root access?
I have a good relationship with the provider but I'd rather not have to bother them if I can help it.
Well let's rule out at least one possibility. I'm thinking that the dns server(s) you use for resolvers in /etc/resolv.conf can do reverse lookups just fine. So show me the results for this command to start this test:
cat /etc/resolv.conf
Was this answer helpful ?
Yes No
nameserver 127.0.0.1
nameserver 64.71.141.80
nameserver 216.218.200.200
Was this answer helpful ?
Yes No
Alright, let's see the results for these 3 commands:
dig @127.0.0.1 -x 216.117.186.93
dig @64.71.141.80 -x 216.117.186.93
dig @216.218.200.200 -x 216.117.186.93
Was this answer helpful ?
Yes No
; <<>> DiG 9.2.2-P3 <<>> @127.0.0.1 -x 216.117.186.93
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25774
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;93.186.117.216.in-addr.arpa. IN PTR
;; ANSWER SECTION:
93.186.117.216.in-addr.arpa. 86400 IN PTR mail.dollardns.net.
;; AUTHORITY SECTION:
186.117.216.in-addr.arpa. 86400 IN NS ns2.aitcom.net.
186.117.216.in-addr.arpa. 86400 IN NS ns0.aitcom.net.
186.117.216.in-addr.arpa. 86400 IN NS ns1.aitcom.net.
;; ADDITIONAL SECTION:
ns0.aitcom.net. 169204 IN A 208.234.1.34
ns1.aitcom.net. 169204 IN A 216.117.186.139
ns2.aitcom.net. 169204 IN A 208.234.1.36
;; Query time: 95 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Nov 26 18:57:49 2004
;; MSG SIZE rcvd: 186
; <<>> DiG 9.2.2-P3 <<>> @64.71.141.80 -x 216.117.186.93
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40661
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;93.186.117.216.in-addr.arpa. IN PTR
;; ANSWER SECTION:
93.186.117.216.in-addr.arpa. 86400 IN PTR mail.dollardns.net.
;; AUTHORITY SECTION:
186.117.216.in-addr.arpa. 86400 IN NS ns1.aitcom.net.
186.117.216.in-addr.arpa. 86400 IN NS ns2.aitcom.net.
186.117.216.in-addr.arpa. 86400 IN NS ns0.aitcom.net.
;; ADDITIONAL SECTION:
ns0.aitcom.net. 13462 IN A 208.234.1.34
ns1.aitcom.net. 13462 IN A 216.117.186.139
ns2.aitcom.net. 13462 IN A 208.234.1.36
;; Query time: 117 msec
;; SERVER: 64.71.141.80#53(64.71.141.80)
;; WHEN: Fri Nov 26 18:57:49 2004
;; MSG SIZE rcvd: 186
; <<>> DiG 9.2.2-P3 <<>> @216.218.200.200 -x 216.117.186.93
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1559
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;93.186.117.216.in-addr.arpa. IN PTR
;; ANSWER SECTION:
93.186.117.216.in-addr.arpa. 86400 IN PTR mail.dollardns.net.
;; AUTHORITY SECTION:
186.117.216.in-addr.arpa. 86400 IN NS ns2.aitcom.net.
186.117.216.in-addr.arpa. 86400 IN NS ns0.aitcom.net.
186.117.216.in-addr.arpa. 86400 IN NS ns1.aitcom.net.
;; ADDITIONAL SECTION:
ns0.aitcom.net. 172140 IN A 208.234.1.34
ns1.aitcom.net. 172140 IN A 216.117.186.139
ns2.aitcom.net. 172140 IN A 208.234.1.36
;; Query time: 166 msec
;; SERVER: 216.218.200.200#53(216.218.200.200)
;; WHEN: Fri Nov 26 18:57:50 2004
;; MSG SIZE rcvd: 186
Was this answer helpful ?
Yes No
Now for the final test.
traceroute 216.117.186.93
traceroute uses the system to resolve IPs to domains. So this is a proof that IP resolution works fine not only on all 3 resolver servers, but also by the system that makes use of them.
Was this answer helpful ?
Yes No
1 gsr12008.fmt.ultraservers.net (64.62.137.1) 0.386 ms 0.316 ms 0.168 ms
2 gsr12012.fmt.he.net (64.71.131.173) 0.199 ms 0.498 ms 0.482 ms
3 pos2-1.gsr12416.pao.he.net (64.62.249.122) 194.951 ms 76.082 ms 3.947 ms
4 peer-01.palo.twtelecom.net (198.32.176.111) 1.940 ms 1.948 ms 1.980 ms
5 66.192.250.45 (66.192.250.45) 3.483 ms 3.575 ms 3.469 ms
6 core-02-so-1-0-0-0.chrl.twtelecom.net (66.192.255.22) 76.512 ms 75.991 ms 76.461 ms
7 66.192.242.23 (66.192.242.23) 77.982 ms 78.537 ms 78.442 ms
8 66.192.242.4 (66.192.242.4) 78.426 ms 78.035 ms 78.456 ms
9 66.192.242.41 (66.192.242.41) 78.472 ms 78.650 ms 78.468 ms
10 64-132-140-162.gen.twtelecom.net (64.132.140.162) 87.162 ms 89.439 ms 88.403 ms
11 mail.dollardns.net (216.117.186.93) 89.443 ms 92.391 ms 89.881 ms
So I guess that means it works? So why does the following code:
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo $hostname;
?>
lifted straight from the php manual just return "217.64.123.69" instead of the hostname?
Was this answer helpful ?
Yes No
Dunno, perhaps it's a misconfiguration in PHP? I've written a little program for you that utilizes gethostbyaddr so that you can test to be 100% sure it's not the system's fault.
The attached tar/gz (not a zip) is both gethostbyaddr program and C code. It's written in such a way that should be convenient if you need a script to get the hostname for an IP.
Was this answer helpful ?
Yes No
Wow, thanks for that. I have run it as follows:
Pre...
<?php
echo `./gethostbyaddr 216.239.57.99`;
?>
...Post
(As I have no shell access, this is as good as it gets for me)
and the output I get is:
Pre...
...Post
Have I misunderstood? I have chmodded it to give world executable status
Was this answer helpful ?
Yes No
I take it that it works fine when executed directly? Have PHP check the return code of the program (system function is one way to test this). The return code is 0 if it was successful and it returns the hostname. Otherwise you get an error code of 1, 2, or 3 and there's no output.
Was this answer helpful ?
Yes No