Moin!

On 24.07.2010, at 17:25, Marc Vilanova wrote:
> I am trying to get the second level domain name from a host name using
> the "dns.resolver.zone_for_name" function as it is shown in the
> following piece of code, but I am having problems with some TLDs and ccTLDs.
> 
> host_name = "www.forsight.com.au"
> domain_name = dns.resolver.zone_for_name(host_name,resolver=my_resolver)
> print str(domain_name)
> com.au. (correct, but I was interested in obtaining "forsight.com.au.")
Well this function will only work if the domain is actually delegated, which 
forsight.com.au is not:
rwe...@pinkfloyd:~/source/dnspython-1.8.0/dns$ dig SOA forsight.com.au

; <<>> DiG 9.6.0-APPLE-P2 <<>> SOA forsight.com.au
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 12026
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;forsight.com.au.               IN      SOA

;; AUTHORITY SECTION:
com.au.                 0       IN      SOA     ns1.ausregistry.net.au. 
dns.ausregistry.net.au. 2040519490 14400 3600 3600000 14400

> Is there a better way to do it that will work for all TLDs and ccTLDs?
> Thanks in advance.
If you are just interested in skipping the first label a:
        domain = str (dns.name.from_text("www.forsight.com.au").parent())
might help.

So long
-Ralf
---
Ralf Weber (Internet Citizen)
e: [email protected]



_______________________________________________
dnspython-users mailing list
[email protected]
http://howl.play-bow.org/mailman/listinfo.cgi/dnspython-users

Reply via email to