I recently installed Ubuntu GNOME on my work computer, replacing Windows 7, because I will be doing a lot of Linux development work.
Many of our configuration and development scripts use shortened URLs for servers on the company network. That is, they use http://server
rather than http://server.location.company.com
. I never had problems with these URLS in Windows, but I have not been able to get them to work correctly in Ubuntu. It is not feasible for me to simply type the entire fully-qualified URL because the shortened form is used all over the place in various scripts, but I am able to access the long-form URLs.
When I connect to the company's VPN using the Dell SonicWall NetExtender VPN Client, the shortened URLS do work correctly.
Based on the research I have done so far, I think that I need to configure location.company.com
as a search domain on Ubuntu, but my attempts at doing this have failed so far. Here is what I have tried:
- In the "Network Connections" app, edit my wireless connection. Under the IPv4 tab, select Automatic (DHCP) addresses only. Then type in
location.company.com
as a search domain, and put our DNS server in as well. This made no noticeable difference. - Modifying dhclient.conf as described here.
- Running
dpkg-reconfigure resolvconf
to make sure that it dynamically updates resolv.conf.
I am also worried that at this point I have tried several different things and they could be interfering with each other. I know that some parts of this configuration changed in the last couple of years with Ubuntu, and it can be hard to find the most current information. It is not completely clear to me how network-manager, resolvconf, dhclient, and other configuration files work together in the newest versions of Ubuntu.
So, my question: How can I configure my computer to make the short-form URLs work correctly in Ubuntu 14.10?
Or, which network configuration programs should I be using to do this, how should I configure them, and how can I verify that they are working correctly?
Thanks for your help! Let me know if I can provide any additional info.
Edit: Here is my /etc/resolv.conf
, which I believe was generated by resolvconf.
# Add Company Nameservers and Domain
nameserver 192.168.200.53
nameserver 192.168.200.65
search location.company.com
nameserver 127.0.1.1
search location.company.com
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search hsd1.co.comcast.net
Search domain means the domain that will be automatically appended when you only use the hostname for a particular host or computer. This is basically used in a local network.
Lets say you have a domain name like
xyz.com
(it may be available globally or may be local only) and you have 100 computers in the LAN. Now you want this domain name to be automatically appended when you look for any computer by just hostname of the computer. If the domain name to be appended isxyz.com
then the search domain should look like:or
Now how do you check if its working properly, just use
ping
or any DNS resolving program likehost
,nslookup
,dig
.For example if a host is
test
having the IP192.168.1.5
then usinghost
:Now as
dig
does not use the search list/domain by default you need to use it likedig +search test
to enable appending search domain.Using
nslookup
:Here
192.168.1.11
is your local DNS server which has the IP address for the hosttest.xyz.com
(notice the full form) that is192.168.1.5
. The DNS server will resolve the hostnametest.xyz.com
to IP192.168.1.5
but will not resolve anything for onlytest
as it does not have any entry like so.So, what search domain is doing in our case is that it is automatically appending a domain name to make it a FQDN when we are just using the hostname to look up a computer.
I'm running Bionic Beaver and my
resolv.conf
says:so my solution was to edit
/etc/systemd/resolved.conf
, optionDomains=
according to docs and then restart systemd-resolved:I was looking for a solution to this issue for Ubuntu Focal 20.04, as my local domain was not appending to hostnames.
On most unix-like OS like Solaris, Debian, etc. the solution is to add a line with '
search domain.name
' to/etc/resolv.conf
but modern Ubuntu releases usesystemd-resolved
now, so I had to figure out what to do.Thankfully, it's still only one line - just using the
resolvectl
command now instead of editing a text file:(you can find your
ifname
by invokingip addr
orresolvectl status
)Note: This change is not permanent, for a permanent solution please see the update below
To verify it's working, make sure domain is listed by
systemd-resolved
by invoking:and that it's in the auto-generated
/etc/resolv.conf
by invoking:And try
ssh
orhttp
using a hostname instead of a FQDN to see if the configured local domain resolves automatically.I think my solution is the easiest and least confusing option - it's probably worth at least trying first in case it works for you before exploring the solutions posed in other answers.
Update 2-20-2020:
I noticed this change is not permanent. As per this question DNS set to systemd's 127.0.0.53 - how to change permanently? I learned that the permanent configuration is stored in
/etc/systemd/resolved.conf
- just uncommentDomains=
and write your domain in there:From 16.04 on, the Advanced Network Configuration tool is only accessible via the command line:
sudo nm-connection-editor
The search domain can be configured on the
IPvX Settings
tab.For further details, see Thomas Ward's excellent answer.
In my case, Adding search domain under /etc/resolvconf/resolv.conf.d/tail And restarting network manager And restarting my VPN worked.
Issue I was facing was, that my Org provided custom DNS that was not accessible.
Solution:
Add
search my.orgdomain.com
in /etc/resolvconf/resolv.conf.d/tailAfter saving run
sudo service network-manager restart
Restart VPN