Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to make a script that will ping an IP address and tell you the name of the server it is pinging.

It works....mostly

I cannot seem to figure out how to make Linux (Ubuntu more specifically) to display the dns domain suffix that is set inside of the "resolv.conf" file.

if I type "hostname" at a command prompt all I get is "ubuntu01"

I tried typing domainname and all I get is the output "(none)" which is confusing me considering I can type the hsotname of any computer on my network and it will append the DNS suffix of "solignis.local" to it just like it is supposed to.

Any ideas?

share|improve this question
    
The command hostname -f should return the FQDN for the local host if the /etc/hostname and /etc/hosts is setup properly. –  Zoredache Dec 17 '10 at 2:14
add comment

3 Answers

up vote 0 down vote accepted

hostname provides this functionality:

$ hostname -d

If you are getting (none) then the domain may not be set, there is also the -y switch for the NIS/YP domain name.

share|improve this answer
    
hostname -y, displays "domainname: Local domain name not set", sounds like I got some debugging to do. problem is I am pretty new to linux. –  Solignis Dec 17 '10 at 1:47
    
Solignis: Sounds to me like the domain is just not set on the machine, if it has one, that needs to be sorted out. –  Orbling Dec 17 '10 at 2:03
1  
@Solignis, Look at your /etc/hosts. There should be a entry for your system with the FQDN. –  Zoredache Dec 17 '10 at 2:15
    
that was the problem, it works now. I looked at another server I had and I used that as an example. I had uninstalled the Ubuntu desktop network manager and there was still a commented line in there about it making the change, works now. Thanks a bunch! –  Solignis Dec 17 '10 at 2:26
add comment

The "search" and "domain" settings in resolv.conf are only for converting host names with no domain to IP addresses.

You are trying to convert a host name with no domain to a host name with a domain.

I would usually set the hostname to a host name with a domain, e.g. in /etc/hostname and /etc/hosts.

The other option would be to set up a DNS server.

share|improve this answer
    
I have a DNS server running its BIND9. It runs forward and reverse. You saying if I add and entry for this machine it will be good? –  Solignis Dec 17 '10 at 2:02
    
Yes, I think so. Worst case, you have to run "host ubuntu01", then grab the IP address that that prints, and then run "host <IP address>". –  Mikel Dec 17 '10 at 2:04
    
that works...sorta. it gives me this output "21.0.0.10.in-addr.arpa domain name pointer ubuntu01.solignis.local." But if I run "dnsdomainname" it says dnsdomainname: Name or service not known. –  Solignis Dec 17 '10 at 2:13
    
What do you have in /etc/hosts? /etc/hosts will be used in preference to DNS by default. –  Mikel Dec 17 '10 at 2:58
add comment

Sounds like the computer doesn't have the domain properly configured. If there's a search domain in the resolv.conf file that you want, you can grep it out (grep search /etc/resolv.conf)

share|improve this answer
    
I just tired it and I get just the hostname, no domain suffix. I found a site that told me to try type "dnsdomainname" but it does not work for me it just makes another command prompt and moves on. –  Solignis Dec 17 '10 at 1:35
    
I know I set it in the resolv.conf. would "grep"ing it be the easiest I assume? I am trying do it for a perl script I starting to wonder if perl has a way to find the domain suffix, hmm well thanks for the help. –  Solignis Dec 17 '10 at 1:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.