Please help: How to get the alias hostname ??

T

tongyizhou

I don't know how to get all the alias hostname of an IP address. I have
looked through the net but got no answer.
Could somebody help me?? It's very urgent and important to me!!

Thanks!
 
J

James McGill

I don't know how to get all the alias hostname of an IP address. I have
looked through the net but got no answer.
Could somebody help me?? It's very urgent and important to me!!

You can never know all possible aliases. How would your routine ever
know I call 127.0.0.1 "lo" "localhost" and "zero"?

Ok, but seriously, you can do a reverse DNS lookup and then do a forward
lookup and collect CNAME records.

Why do you need to do this?
 
T

tongyizhou

Well, it might sounds funny.
I am just a Chinese student, and that's just a function I must
implement in my homework. Due to the requirements I must print out
all the aliases hostname and the IP addresses of the destnation URL. It
just a funny meaningless requirement right ?^_^? I just have no choice.

I will be very appreciate if U can help me out T_T
 
J

James McGill

Due to the requirements I must print out
all the aliases hostname and the IP addresses of the destnation URL.

Well, getting the IP address is simple enough. For the aliases I would
do a dns lookup for CNAME records, and then pick the CNAMEs that point
to the IP address that the original hostname resolves to. But I might
be misunderstanding the project.
 
R

Ronny Schuetz

Hi,
Ok, but seriously, you can do a reverse DNS lookup and then do a forward
lookup and collect CNAME records.

Might be a dumb question, but how exactly are you going to collect the
CNAME records? I thought it is not possible to look them up based on the
primary name of the machine or its IP address only.

Ronny
 
J

James McGill

Might be a dumb question, but how exactly are you going to collect the
CNAME records? I thought it is not possible to look them up based on
the
primary name of the machine or its IP address only.

It's not necessarily possible! There are many cases where it's not
possible at all. But in the nice cases, especially those where you have
some information about the remote system's DNS, you could.

The way the OP worded the assignment, it sounds like a case of a
clueless teacher sharing his wealth of ignorance with a new
generation.

In the real world, if you've already got a connection, you no longer
care about DNS. It doesn't matter how you addressed the host, once
you've reached it. Maybe there are situations, e.g., security related,
where you want a reverse-lookup to some canonical resolution, but in the
general case, since the mapping is arbitrary and can be private, there's
no really good way to do what the OP wants to do. I would be willing to
give an ear to someone who thinks there's a scenario where this is
necessary, or even workable.

You want *all* the aliases of a host? I doubt your program is able to
discern that I call my workstation "broken piece of crap", or more to
the point, that I have private DNS in my lab for naming hosts that have
totally different names to the public.
 
R

Ronny Schuetz

The question was not really related to the OPs question. I was looking
for a general way to get all _public_ aliases a while ago to check X.509
certificates received during SSL handshakes and ran into this issue. Was
just wondering cause what you wrote looked too easy. Trying to get all
CNAME records and compare them on the client side is of course not an
option.

Ronny
 
Z

Zero

Thank U for all the guys worked on this topic. U are really good and
helpful.
It seems it is necessary for me to talk to my teacher about her foolish
requirement.
Thank U again ^_^
 

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
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top