name to ip

L

lallous

Hello,

The docs say that gethostbyaddr() or getnameinfo() are not a reliable way to
get name from the address.

What is a programmatically reliable way to do that?
 
L

lallous

I posted in the wrong newsgroup, sorry.

However this question can be rewritten for Java as:
How can I convert from IP address to name(s) ? for example IP a.b.c.d to
www.somesite.com
 
M

Mark Thornton

lallous said:
I posted in the wrong newsgroup, sorry.

However this question can be rewritten for Java as:
How can I convert from IP address to name(s) ? for example IP a.b.c.d to
www.somesite.com

This operation requires reverse lookup information in the DNS records
--- which doesn't necessarily exist, hence the unreliability.
So if the reverse lookup records have been set up and the relevant DNS
servers are available (and reachable) then subject to timeouts you
should get a name which corresponds to the IP address. Remember too that
the name may not be unique (many names mapping to the same IP address).
On the whole you are better off avoiding this operation.

Mark Thornton
 
S

Sudsy

lallous said:
I found a website that provides reverse lookup.
Ping www.google.com , i get an IP address; I can type this address in the
address bar and surf to google.
Now I type that IP address in the reverse name lookup and it doesn't show
google! Why?

Mark already answered this question. Are you not satisfied?
There are no rules which REQUIRE a PTR record in DNS. In
fact, in some cases it's quite impossible to configure.
Let me provide a concrete example: I have a "fixed" IP
address assigned by my cable operator. While I can create
and serve A records, my cable operator controls the
authoritative nameservers for the IP domain (the reverse
lookup). They are unwilling to create PTR entries in their
control files to point back to my named domain records.
And they're under no obligation to do so!
Please obtain some documentation on how DNS works (O'Reilly's
"DNS and BIND in a Nutshell", ISBN 1-56592-010-4 is a good
choice) and you'll soon be answering questions like this
for yourself.

ps. Try working backwards, i.e. if www.google.com resolves
to 216.239.39.99 then do this:
$ nslookup -type=SOA 99.39.239.216.in-addr.arpa.
$ nslookup -type=SOA 39.239.216.in-addr.arpa
(first one will fail, second [less specific] will succeed)
At least know you know who owns the address range!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top