This question already has an answer here:

At my company, many of our configuration scripts, etc use just the server name. For example, http://server rather than http://server.company.com. I have configured the search domain in the GUI Network Connections tool. I have also configured it in /etc/resolvconf/resolv.conf.d/head, but it is not working correctly.

The strange thing is certain tools like nslookup or host resolve to the correct IP, but other tools like ssh, ping, git, and web browsers do not. I can connect if I use the FQDN. What could be preventing the search domain from resolving correctly?

Below, find the relevant output from some commands.


$ nslookup server

server.company.com  canonical name = server001.company.com.
Name:   server001.company.com


$ host server
server.company.com is an alias for server001.company.com.
server001.company.com has address


$ ping server
ping: unknown host server

$ ping server.company.com
PING server001.company.com ( 56(84) bytes of data.
64 bytes from server001.company.com ( icmp_seq=1 ttl=64 time=4.61 ms

I use ping as an example because it's simple, but most of the other tools I need to use show the same results as ping.

Let me know if you need any more config files or info.

/etc/hosts has no info related to the server I'm trying to connect to.

Here is /etc/resolv.conf, which was generated by resolvconf.

# Add Company Nameservers and Domain
search company.com
search company.com
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
search hsd1.co.comcast.net

And /etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

marked as duplicate by Eric Carvalho, Fabby, mikewhatever, Elder Geek, Seth Feb 15 '15 at 16:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Only the last search line is supposed to take effect, so either merge the comcast line and yours or nuke the comcast line. – muru Feb 12 '15 at 21:51

Your resolv.conf file is a mess. There should be at most one search line in the file, for example. It appears that something other than resolvconf is writing to the file. Resolvconf always writes a resolv.conf file with the following format:

base + dynamic content

where head, base and tail are the files in /etc/resolvconf/resolv.conf.d/. The file head normally just contains the comment # Dynamic resolv.conf(5) file... OVERWRITTEN. You say you have added a search line to the file, but your resolv.conf file contains other stuff above the aforementioned comment.

I'm guessing that /etc/resolv.conf is no longer a symbolic link to /run/resolvconf/resolv.conf and/or that you are running some third party network configuration software that futzes with /etc/resolv.conf in a way that is not compatible with Ubuntu.

Solution: Stop using that software, or fix it, and then run sudo dpkg-reconfigure resolvconf to restore the symbolic link at /etc/resolv.conf.

  • head was empty when I edited it. The # Dynamic resolv.conf(5) file... was in original and tail was a symlink to original. You're right, it is a mess. I'm cleaning it up now. – mkasberg Feb 13 '15 at 16:33


echo "        dns-search company.com" >> /etc/network/interfaces

Followed by a reboot (unless you know how to reset all your DNS caches, in-browser and system, a network restart is not enough).

  • 1
    I added my /etc/network/interfaces file above. It does not appear that my network connection (wlan0) is configured in that file. (I believe this is because it is managed by network-manager?) Do you still think I should try this solution? – mkasberg Feb 12 '15 at 20:23
  • 1
    So I tried this with eth0. auto eth0 iface eth0 inet dhcp search-domain company.com. It works! But I would really like this to work with network-manager since it handles wireless configuration easily. My understanding is that network-manager won't touch interfaces configured in /etc/network/interfaces. The fact that it works in /etc/network/interfaces makes me think it could be a problem related to network-manager. – mkasberg Feb 12 '15 at 23:41

I'm pretty sure ping, ssh and possibly others use the /etc/host file. You might want to try defining your server names there as well server Then either source the file or log out and in again. This time when you ping server Or ssh user@server It should work. As far as webserver, you would have to add an A record to your dns server ipaddress Then you should be able to access via http://server


Is any part of this setup using Samba or wins server, or did I completely misunderstand something.

  • This would absolutely work (I'm using it now as a workaround), but it seems like more of a workaround than a solution. If the IP changes, I'd have to manually update the file. If we add a new server to the network, I'd have to put that in /etc/hosts as well. There should be a way to configure the search domain correctly so that an entry in /etc/hosts is not required. None of this is using samba or wins. – mkasberg Feb 12 '15 at 20:50
  • I will look into this. Can't guarantee I will figure it out, but I enjoy the research/challenge – geoffmcc Feb 12 '15 at 21:10

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