aspose file tools*
The moose likes Linux / UNIX and the fly likes how to find dns name or server name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to find dns name or server name" Watch "how to find dns name or server name" New topic
Author

how to find dns name or server name

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I am trying to get the dns name of a linux sever. I tried with which prints as below:

I can use perl regexx to get the server name/dns name from the above command. Is there any other easy way to grab the dns name? Thanks.
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
uname -n?
Otherwise 'uname -n|sed -e "s/\..*//g"'


SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="http://www.enthuware.com" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

"hostname" is what's usually used, but that isn't necessarily "the" DNS name or even "a" DNS name, since the hostname is often set from a config file before network services boot up.

I put "the" in quotes, since a server can and often does have multiple DNS names. For example www2.mousetech.com is also ftp.mousetech.com and once was cvs.mousetech.com as well.

Most commonly for remote users, reverse DNS lookup is used. That is, if you do a DNS lookup on, say, 192.168.100.7, a properly configured DNS system will return the preferred DNS name for the machine with that IP address.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Thanks for the suggestions.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Tim's right, a reverse DNS may get you the DNS binding, but not always.
For example, big sites often have something like a BigIP or ServIron that does load balancing. So there are lots of computers that DNS claims are www.google.com, but its unlikely that any computer really has that as its name.

Why do you want this? In most production environments, the DNS naming is completely independent of the box, the box's internal names, etc. And of course, NAT makes IP address of questionable value as well
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to find dns name or server name