• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to find dns name or server name

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
uname -n?
Otherwise 'uname -n|sed -e "s/\..*//g"'
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the suggestions.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic