Hostname configuration on DHCP/DNS server: /etc/hosts vs. /etc/hostname

Chris G cl at isbd.net
Sun Mar 27 13:49:52 UTC 2011


On Sun, Mar 27, 2011 at 02:56:48PM +0200, Niki Kovacs wrote:
> Hi,
> 
> I have a DHCP/DNS server (Ubuntu 10.04) running on my local network.
> The domain name is the dummy "presbytere.montpezat" for all the
> local machines. Of course the server has a static network
> configuration in /etc/network/interfaces.
> 
> Here's how /etc/hosts is configured:
> 
> 127.0.0.1 localhost.localdomain localhost
> 192.168.1.2 proliant.presbytere.montpezat proliant
> 
> Now I wonder what I should put in /etc/hostname. I think it should
> only be this:
> 
> proliant
> 
> But now I wonder if I should put the FQDN in it, like this :
> 
> proliant.presbytere.montpezat
> 
> If I remember correctly, that's how my Red Hat servers were
> configured. Anybody knows the "right" (or at least the orthodox) way
> to do this?
> 
I have a small home network with a local DNS/DHCP server too (it uses
dnsmasq).   All systems except the DNS server itself have just the
following:-

    /etc/hosts

        127.0.0.1       localhost


    /etc/hostname

        chris


(of course you change the hostname 'chris' according to the host's name!)

If you add all that localhost.localdomain stuff and the IP line then
things beging to break, in particular both apache2 and leafnode complain
that they can't find a FQDN for the host.


The DNS server has the following /etc/hosts:-

    127.0.0.1   localhost

    192.168.1.1 vigor 2820n
    192.168.1.2 dps dps.zbmc.eu
    192.168.1.3 hp7310 HPEDDBB7 HP000D9D068F7D
    192.168.1.4 chris mws boat info
    192.168.13.254 2wire BT2700HGV gateway.2wire.net

... and /etc/resolv.conf:-

    domain zbmc.eu
    search zbmc.eu
    nameserver 127.0.0.1
    nameserver 195.74.113.58
    nameserver 194.72.0.114

The dnsmasq software uses the contents of /etc/hosts to provide DNS
information about the systems with fixed IP addresses from the above
file.  All other systems on the LAN get their IP address from dnsmasq
using DHCP.

This certainly works for me and seems to keep most things (like apache2)
happy.  I recently upgraded to xubuntu 10.10 and Network Manager
insisted on overwriting /etc/hosts so I have removed Network Manager and
use wicd instead now.

(Note: I have not put the IPv6 bits in the above /etc/hosts, it's just the
defaults)

-- 
Chris Green




More information about the ubuntu-users mailing list