[CentOS] Set hostname via DHCP ?

Mon Jun 29 08:56:05 UTC 2009
Tsai Li Ming <ltsai at osgdc.org>


Niki Kovacs wrote:
> Niki Kovacs a écrit :
>> If I take a look at /var/lib/dhclient/dhclient-eth0.leases (on the 
>> client), here's a summary of the lease:
>>
>> lease {
>>    interface "eth0";
>>    fixed-address 192.168.1.2;
>>    option subnet-mask 255.255.255.0;
>>    option routers 192.168.1.254;
>>    option dhcp-lease-time 86400;
>>    option dhcp-message-type 5;
>>    option domain-name-servers 62.4.16.70,62.4.17.69;
>>    option dhcp-server-identifier 192.168.1.252;
>>    option broadcast-address 192.168.1.255;
>>    option host-name "raymonde";
>>    option domain-name "local";
>>    renew 1 2009/6/29 17:04:30;
>>    rebind 2 2009/6/30 04:47:44;
>>    expire 2 2009/6/30 07:47:44;
>> }
>>
>> Here's what 'hostname' returns:
>>
>> # hostname
>> raymonde
>>
>> But when I go for the domain name, I get this:
>>
>> # hostname -d
>> hostname: Hôte inconnu --> means 'Unknown host' in french :o)
>>
>> Any idea what I'm doing wrong here?
> 
> OK, I think I got my mistake. When I specify a domain name (with 'option 
> domain-name'), this is in fact what gets written to the client's 
> /etc/resolv.conf in the 'search' line. But to handle the fully qualified 
> domain name centrally, I have to use DNS.
> 
> Correct me if I'm wrong.
> 

In our environment, our dhcp client machines (rhel or centos) gets their 
hostname by dns lookups (Not sure why).

Our dhcp server generally just provides the usual configurations like 
dns/search optionse/etc. The ip addresses for our dhcp range have both 
forward and reverse mappings on our dns server and the clients obtain 
the proper fully qualified host name upon dhcp request.


HTH,
Liming