Foolproof way to check if a domain exists?

Discussion in 'Java' started by laredotornado@zipmail.com, Apr 4, 2013.

  1. Guest

    Hi,

    We're using Java 6. We are trying to use the following code to determine if a domain exists:

    ????????????InetAddress inetHost = InetAddress.getByName(domain);
    ????????????String hostName = inetHost.getHostName();

    This usually works fine -- if a domain doesn't exist, an "UnknownHostException" is thrown. However, we notice this isn't true for the Verizon ISP. Instead hostname is equal to the domain (e.g. "locohost") that doesn't exist.. Therefore, it is hard to tell what exists and what doesn't.

    Is there a more foolproof way to verify the existence of a domain?

    Thanks, - Dave
    , Apr 4, 2013
    #1
    1. Advertising

  2. Roedy Green Guest

    On Thu, 4 Apr 2013 07:17:33 -0700 (PDT),
    wrote, quoted or indirectly quoted someone who said :

    >
    >Is there a more foolproof way to verify the existence of a domain?


    there are various WHOIS services you could probe. They will tell you a
    domain exists if it is registered, even if no server is handling it
    currently.
    see http://mindprod.com/jgloss/whois.html
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    Motors make noise, and that tells you about the feelings and attitudes
    that went into it. Something was more important than sensory pleasure --
    nobody would invent a chair or dish that smelled bad or that made horrible
    noises -- why were motors invented noisy? How could they possibly be
    considered complete or successful inventions with this glaring defect?
    Unless, of course, the aggressive, hostile, assaultive sound actually served
    to express some impulse of the owner.
    ~ Philip Slater (born: 1927 age: 85)
    The Wayward Gate: Science and the Supernatural
    Roedy Green, Apr 4, 2013
    #2
    1. Advertising

  3. Guest

    On Thursday, April 4, 2013 10:32:15 AM UTC-5, Roedy Green wrote:
    > On Thu, 4 Apr 2013 07:17:33 -0700 (PDT),
    >
    > wrote, quoted or indirectly quoted someone who said :
    >
    >
    >
    > >

    >
    > >Is there a more foolproof way to verify the existence of a domain?

    >
    >
    >
    > there are various WHOIS services you could probe. They will tell you a
    >
    > domain exists if it is registered, even if no server is handling it
    >
    > currently.
    >
    > see http://mindprod.com/jgloss/whois.html
    >
    > --
    >
    > Roedy Green Canadian Mind Products http://mindprod.com
    >
    > Motors make noise, and that tells you about the feelings and attitudes
    >
    > that went into it. Something was more important than sensory pleasure --
    >
    > nobody would invent a chair or dish that smelled bad or that made horrible
    >
    > noises -- why were motors invented noisy? How could they possibly be
    >
    > considered complete or successful inventions with this glaring defect?
    >
    > Unless, of course, the aggressive, hostile, assaultive sound actually served
    >
    > to express some impulse of the owner.
    >
    > ~ Philip Slater (born: 1927 age: 85)
    >
    > The Wayward Gate: Science and the Supernatural


    Are there Java interfaces for these services? Ideally, I'd like something platform independent. - Dave
    , Apr 4, 2013
    #3
  4. Joerg Meier Guest

    On Thu, 4 Apr 2013 07:17:33 -0700 (PDT), wrote:

    > We're using Java 6. We are trying to use the following code to determine if a domain exists:


    > ????????????InetAddress inetHost = InetAddress.getByName(domain);
    > ????????????String hostName = inetHost.getHostName();


    > This usually works fine -- if a domain doesn't exist, an "UnknownHostException" is thrown. However, we notice this isn't true for the Verizon ISP. Instead hostname is equal to the domain (e.g. "locohost") that doesn't exist. Therefore, it is hard to tell what exists and what doesn't.


    > Is there a more foolproof way to verify the existence of a domain?


    My guess would be that Verizon's DNS is faulty and is responding with a
    page filled with ads or some such nonsense. Do try a better DNS such as
    Googles at 8.8.8.8. If you run the following BEFORE doing anything else in
    your code, you might have the platform independent solution you are looking
    for:

    System.setProperty("sun.net.spi.nameservice.nameservers", "8.8.8.8");
    System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun");

    Liebe Gruesse,
    Joerg

    --
    Ich lese meine Emails nicht, replies to Email bleiben also leider
    ungelesen.
    Joerg Meier, Apr 4, 2013
    #4
  5. Arne Vajh?j Guest

    On 4/4/2013 12:21 PM, wrote:
    > On Thursday, April 4, 2013 10:32:15 AM UTC-5, Roedy Green wrote:
    >> On Thu, 4 Apr 2013 07:17:33 -0700 (PDT),
    >> wrote, quoted or indirectly quoted someone who said :
    >>> Is there a more foolproof way to verify the existence of a domain?

    >>
    >> there are various WHOIS services you could probe. They will tell you a
    >> domain exists if it is registered, even if no server is handling it
    >> currently.
    >>
    >> see http://mindprod.com/jgloss/whois.html


    >
    > Are there Java interfaces for these services? Ideally, I'd like something platform independent. - Dave


    http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/whois/WhoisClient.html

    Arne
    Arne Vajh?j, Apr 4, 2013
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Stacy
    Replies:
    2
    Views:
    4,687
    Roedy Green
    Apr 27, 2008
  2. Ulf Meinhardt
    Replies:
    8
    Views:
    6,144
  3. Replies:
    0
    Views:
    313
  4. Chris Rebert
    Replies:
    3
    Views:
    287
    Chris Rebert
    Apr 13, 2010
  5. Paul Mckibbin
    Replies:
    5
    Views:
    164
    Aldric Giacomoni
    Jan 15, 2010
Loading...

Share This Page