Where does an ubuntu machine get it's doamin name from

Derek Broughton derek at pointerstop.ca
Fri Sep 18 14:14:59 UTC 2009


Marius Gedminas wrote:

> On Wed, Sep 16, 2009 at 10:53:31AM -0300, Derek Broughton wrote:

>> If you don't have a static IP (and for multiple machines "at work" you
>> normally wouldn't) it's customary to get the domain name from the DHCP
>> server.
> 
> That works fine for /etc/resolv.conf, i.e. looking up other hosts in the
> same domain by using short names, but I don't recal ever seeing hostname
> --fqdn output mylocalhostname.domainreceivedfromDHCPserver.  Are we
> talking about the same thing here?

Absolutely.  My machine "morgen" (/etc/hostname does _not_ contain an fqdn), 
is currently connected to the domain "mar.dfo-mpo.ca", and the DHCP server 
there sent back that domain name in the DHCP request.  So:
  $ hostname --fqdn
  morgen.mar.dfo-mpo.ca

when I'm at home, my own DHCP server sends "pointerstop.ca", and my machine 
- with no special configuration at my end - is "morgen.pointerstop.ca".

/etc/dhcp3/dhclient.conf contains:

request ... domain-name ...

And that's all you need (and should be set by default).

According to "man hostname", the value returned from "hostname --fqdn" IS 
from the resolver (ie, generally based on what's in /etc/resolv.conf).
-- 
derek





More information about the ubuntu-users mailing list