Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Ubuntu12 server VM is receiving its IP address from an DHCP server (actually my WLAN router called Fritz Box). Hence all domain names are resolved to machinename.fritz.box. The reason seems to be the resolv.conf file under /etc.

But how can I change this search name to an arbitrary name such as xyz.mydomain? It clearly says not to edit the file. The machine itself is set as ubuntu.xyz.mydomain in hostname. What I want is that machine1 is assumed to be machine1.xyz.mydomain and NOT(!) machine1.fritz.box.

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
search fritz.box # shall be xyz.mydomain
share|improve this question
Just as a remark, there seems to be no way to set it in the router. – Horst Walter Feb 7 '13 at 22:14
That's right. You can't set the local domain name on a Fritz!Box. Alas. – jdthood May 30 '15 at 18:53
up vote 7 down vote accepted

resolvconf is a program to manage the resolv.conf file so that multiple sources can add and remove entries without tripping over each other. The manager of each network interface feeds it a resolv.conf file for that interface, and it merges them all together.

resolvconf is meant to be run by network scripts or DHCP clients, but you can also run it yourself. Entries you make have to be associated with an interface; the "lo" interface is nice to use for locally administered entries because it's always up, it isn't dynamically managed, and its entries take priority over other interfaces. So:

echo 'search xyz.mydomain' | resolvconf -a lo

will add xyz.mydomain to the beginning of the search list. This will persist until you run resolvconf -d lo. (The network scripts may also run this if you use them to bring the lo interface down.)

You can make this more permanent by having the networks scripts handle it for you. On Ubuntu or other Debian-family distros, edit your /etc/network/interfaces file as follows:

iface lo inet loopback         # This line already present
    dns-search xyz.mydomain    # Add this line beneath it

For more info:

share|improve this answer
yep, gives me xyz.mydomain first and fritz.box second - seems to be OK for the moment. Thanks – Horst Walter Feb 8 '13 at 17:24

The best way to do this is to configure your WLAN router correctly, so that is is giving out proper fully qualified domain names (FQDN) to your hosts.

If the WLAN router serves hosts in the myhome.org domain then configure it as wlan-router.myhome.org. It likely uses it's own domain name as the value to hand out to clients.

A full DHCP has an option for setting this value for client systems:

option domain-search "example.com", "sales.example.com", "eng.example.com";

but it is unlikely, although possible, that you can set these dhcp options in your WLAN router.

If you are really stuck, you can edit resolv.conf, it will simply get clobbered every time you run the dhcp client. You can write a script to update it every time, but this is less than ideal, and will likely cause you grief if this is a mobile system, like a laptop.

share|improve this answer
The Fritz!Box doesn't allow you to change the local domain name. It's always fritz.box. – jdthood May 30 '15 at 18:51

Without knowing how to change that in the router, one way is to setup static IP in the VM.

Modify /etc/network/interfaces as follow.

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 192.168.0.X
    # dns-* options are implemented by the resolvconf package, if installed
    dns-search xyz.mydomain

Change 192.168.0.X to IP address you want to assign to VM. It should be outside of the dhcp range.

The dns-nameservers and dns-search will setup your /etc/resolv.conf.

share|improve this answer

Your Answer


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.