Operating System - HP-UX
1826373 Members
4543 Online
109692 Solutions
New Discussion

Re: Return Short Names in DNS

 
Ralph Burnette
Occasional Advisor

Return Short Names in DNS

Is there anyway to configure
named so that when a
query is resolved, only the
short name and the IP are
returned?

Example:

nslookup hpserver

Returns:

hpserver.mycompany.com
192.168.1.225

What I would like to see
is it returning:

hpserver
192.168.1.225

Thanks
6 REPLIES 6
Sean OB_1
Honored Contributor

Re: Return Short Names in DNS

I don't know of anyway to do this.
Rajeev  Shukla
Honored Contributor

Re: Return Short Names in DNS

There is no way. It will always rerurn you the full name with domain.
Only query you can specify with short names by specifying search in /etc/resolv.conf.

But when it returns it returns a full name only.
I see only one possibility to trim this is by using your won c program which uses gethostbyaddr() and gethostbyname() library. Using these you can definately return a short name.

Cheers
Rajeev
Steven Gillard_2
Honored Contributor

Re: Return Short Names in DNS

Would the 'getip' command help? It uses gethostbyname() and returns the IP address only:

$ getip localhost
127.0.0.1
$

Regards,
Steve
Fred Martin_1
Valued Contributor

Re: Return Short Names in DNS

You could create a shell alias in a user's .profile

alias nslookup=/usr/local/bin/my-nslookup

Then my-nslookup could be a script that would perform an nslookup, then use sed or awk, etc, to make the output appear as you like.

If you only wanted your own domain to go away but display others, a simple sed could do it:

nslookup $1 | sed 's/\.mycompany\.com//'

That's a crude example but it could be done.
fmartin@applicatorssales.com
Trever Furnish
Regular Advisor

Re: Return Short Names in DNS

I think all the previous posts are correct - that's not the way it works, ever. But...

It's simple to get just the first word:
nsquery hosts hpserver | grep "^Hostname" | cut -f2 -d" " | cut -f1 -d"."

(Note that the commands above are meant to be a one-liner - your browser may wrap them.)
Hockey PUX?
Shannon Petry
Honored Contributor

Re: Return Short Names in DNS

Or append awk to nslookup ;

nslookup 3.1.3.1 | awk -F. '{print $1}' would omit domain/sub-domain information.

Regards,
Shannon
Microsoft. When do you want a virus today?