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?
hostname
provides this functionality:If you are getting
(none)
then the domain may not be set, there is also the-y
switch for the NIS/YP domain name.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.
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
)