Subject: Re: hostname?
To: None <netbsd-help@NetBSD.org>
From: George Georgalis <george@galis.org>
List: netbsd-help
Date: 02/02/2007 21:48:24
On Fri, Feb 02, 2007 at 06:34:01PM -0500, James K. Lowden wrote:
>Jan Danielsson wrote:
>>    I always thought that the first part of a FQDN is the hostname. i.e.
>> 
>>    c98hr92hr8.d934ryhn982.zorg.com
>> 
>>    ...means that the FQDN is c98hr92hr8.d934ryhn982.zorg.com and the
>> hostname is merely "c98hr92hr8".
>> 
>>    Is this correct? I have seen people claim that "hostname" should be
>> set to (in this case) c98hr92hr8.d934ryhn982.zorg.com.
>
>You're right and they're right.  :-)
>
>The hostname is the first element in the FQDN; in a.b.c.d, "a" is the host
>and "b.c.d" is the domain.  
>
>But you have to tell the machine, somehow, what its hostname is and what
>domain it's in.  In NetBSD, that's done in one fell swoop by setting the
>hostname to the FQDN.  

not necessarily. I've been setting hostnames without the domain
for a while, and it works very well. I think the only reason you
need to tell the host it's domain is for mail and the MTA can be
configured other ways than by setting hostname.

At most sites short hostname will require three additional steps,
vs FQDN style hostname:

1) put a proper search domain in resolv.conf
2) configure your MTA to add a FQDN (not hostname) for local messages
3) configure lan (and/or wan) dns with proper records

The practice ends up being really useful when you
have multiple networks and/or interfaces. eg the
host "acorn" has 3 interfaces each with their own
/24 network.

acorn.masq (192.168.1.50)
acorn.pvt  (192.168.70.50)
acorn.work (10.0.0.50)

acorn has has a gateway of 192.168.1.1 (which is on .masq) and
acorn is a gateway for .pvt and .work networks.

acorn runs a smtp relay and a dhcpd (which hands out an appropriate
resolv.conf search field for the respective network) for .pvt and
.work.

the nameserver runs on 192.168.1.50, so all networks can use
it. With a little firewall magic, from host.pvt I can ping
host.work, acorn.work, acorn.pvt, acorn.masq or the internet.

getting pf.conf, dhcpd.conf, MTA and DNS setup the first time
takes a lot of steps, but once that's worked out, it's easy to add
or remove hosts and having A and PTR records that correspond to the
networks they are on, works real nice too. (I typically set CNAME
records on .pvt for .work hosts so I can reach .work hosts from
.pvt without specifying the FQDN.)

so... I always use short hostname when I set the hostname, it
especially makes sense when the host is connected to more than one
network, or the host gets moved or otherwise doesn't know the name
of the network it's on (eg masq).

// George


-- 
George Georgalis, systems architect, administrator <IXOYE><