Are you sure that ipv6 address has any revers DNS associated with it? dig
reports it doesn't:
$ dig -x 2404:6800:8004::68
; <<>> DiG 9.4.3-P5 <<>> -x 2404:6800:8004::68
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 35573
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;8.6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.0.0.8.0.0.8.6.4.0.4.2.ip6.arpa. IN PTR
;; Query time: 364 msec
;; SERVER: 12.165.58.2#53(12.165.58.2)
;; WHEN: Thu Sep 2 03:45:50 2010
;; MSG SIZE rcvd: 90
edit: Finally found an ipv6 address that has reverse DNS associated. In short, works4me.
>>> import socket
>>> socket.has_ipv6
True
>>> socket.getfqdn('2001:838:2:1::30:67')
'gatey.sixxs.net'
And from dig:
$ dig -x 2001:838:2:1::30:67
; <<>> DiG 9.4.3-P5 <<>> -x 2001:838:2:1::30:67
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 934
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 1
;; QUESTION SECTION:
;7.6.0.0.0.3.0.0.0.0.0.0.0.0.0.0.1.0.0.0.2.0.0.0.8.3.8.0.1.0.0.2.ip6.arpa. IN PTR
;; ANSWER SECTION:
7.6.0.0.0.3.0.0.0.0.0.0.0.0.0.0.1.0.0.0.2.0.0.0.8.3.8.0.1.0.0.2.ip6.arpa. 43200 IN PTR gatey.sixxs.net.
;; AUTHORITY SECTION:
. 517204 IN NS e.root-servers.net.
. 517204 IN NS m.root-servers.net.
. 517204 IN NS a.root-servers.net.
. 517204 IN NS l.root-servers.net.
. 517204 IN NS c.root-servers.net.
. 517204 IN NS h.root-servers.net.
. 517204 IN NS j.root-servers.net.
. 517204 IN NS g.root-servers.net.
. 517204 IN NS f.root-servers.net.
. 517204 IN NS i.root-servers.net.
. 517204 IN NS d.root-servers.net.
. 517204 IN NS b.root-servers.net.
. 517204 IN NS k.root-servers.net.
;; ADDITIONAL SECTION:
a.root-servers.net. 604222 IN A 198.41.0.4
;; Query time: 383 msec
;; SERVER: 12.165.58.2#53(12.165.58.2)
;; WHEN: Thu Sep 2 03:55:03 2010
;; MSG SIZE rcvd: 343