aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes org.xbill.DNS.Lookup() error. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "org.xbill.DNS.Lookup() error." Watch "org.xbill.DNS.Lookup() error." New topic
Author

org.xbill.DNS.Lookup() error.

Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hello,

For email domain validation:



i) Where is 'domainName ' being looked up?
ii) Some kind of configuration for the DNS?
iii) If so how/where?

Thanks,
raj.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
It's looked up using the DNS system. Ultimately, that means the DNS server set up to handle the domain in question.

Note that you can't use the DNS system to validate an email address. The best you can do is to verify that the domain used in the email address has a mail server (meaning, an MX record) associated with it.


Ping & DNS - my free Android networking tools app
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Thank you Ulf.

I can see that is exactly what is being done.



What I would like to know is how the domains are configured on the DNS. Is there any kind of configuration for this?

The way I am thinking is that some domains get 'registered' with the DNS server and when validating a domain, the system checks the registered domains. Am I on the right track?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
When you register a domain, you supply the address(es) of one or more DNS servers to the registrar; those will be used for all DNS queries for that domain - A entries, AAAA entries, MX entries etc.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1



Thanks a TON Ulf!


Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Is there any way for finding out the list of domains that have been registered with the DNS?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
Define "the list of domains". I think there are around 140,000,000 domains registered; surely you don't want a list of all of those...
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Well, I am testing domain validation on my application. Now I need the boundary conditions:
1. An email address with a registered domain should pass and
2. One with an unregistered domain should fail.

Hence.....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
So you need to find out if a given domain is registered. The way to do that is not to get a list of all domains, the way to do it is to query the DNS system. The most basic query is for an A record. If that exists, you can proceed further. Namely, there should be an MX record as well, since that's what's used for sending mail.

If what I wrote above doesn't make sense, then you need to read up on the DNS system, and what the various record types mean and how they are used. Otherwise, you'll just be searching in the dark.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Thank you, Ulf!

I guess there is no easy way out (other than reading up)



Anyways great being part of The Ranch!
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Using the above code to validate an email address or the domain rather.
The validation fails on one of the deployments and does not return Lookup.SUCCESSFUL for a valid Domain. The same domain is validated correctly on other deployments. Detailed logs are not available.

Could this issue could have to do with the DNS configuration?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
Possibly. Or a temporary network issue. Or the environment it's running in. Impossible to say without further information.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


On this deployment this error happens each time this flow is accessed. So I doubt if it is caused by Network related issue(s).
To give it a shot, is there anything I can check on the DNS?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
You can run the command line version of the tool on the machine where it's failing in the server deployment. Or you can check the return value to see if that tells you anything.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Great idea but let me see if I can work my way through the security restrictions in place so that I can do something like that.

THANK YOU Ulf!
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Ulf,

I got a Java program to run on the box and I see that



returns Lookup.TRY_AGAIN and



returns network error.

I am able to ping the DNS server IP.

Can I possibly find more details about the type of network error that is happening?

Note: The same program executes correctly on my local box and the above returns Lookup.SUCCESSFUL
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


On a marathon debugging trail:

I coded a method that would check for internet connection and another to fetch the mail server records for the domain.

Code:-



AND



isInternetReachable() returns true and doLookup(domain) returns 4.

Looks like internet connectivity is not at fault and there are MX records registered for that domain as well.
Now what could be the reason for the "network error"?



Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Finally some light at the end of the tunnel. I felt I should post this out here lest someone face the same issue.

After having reached out to Brian Wellington (author dnsjava) I understand I can enable dnsjava's debugging by setting dnsjava.options property to "verbose".
After I set the debug level to verbose I was able to see that a java.net.PortUnreachableException is thrown.

In Brian's own words - "The exception is because dnsjava is unable to determine the name server that it should be sending to, and is falling back to the local machine, which is likely not running a name server. Modern versions of dnsjava use the sun.net.dns.ResolverConfiguration class to determine this, which works much better than the prior Windows-specific code, but the version of dnsjava you're using predates that."

I checked using a later version (2.1.3) and all went well.

Cheers,
Raj.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19759
    
  20

Thanks for sharing!


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: org.xbill.DNS.Lookup() error.