Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 resolve.conf.

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)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.0.1
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

3 Answers 3

up vote 4 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 the lo interface is taken down, which generally means until you restart your computer.

You can make this more permanent by editing your /etc/network/interfaces file:

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

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
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.0.1
    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

 
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.