[CentOS] Set hostname via DHCP ?

Niki Kovacs contact at kikinovak.net
Mon Jun 29 08:00:35 UTC 2009


Rob Townley a écrit :
> # i do NOT have any kind of use-host-decl-names on; entry.  Do you use
> dnsmasq or dhcpd?

I'm using DHCPD. I took two spare machines this morning and played 
around with them to make some tests. Here's what I got.

a) Server-side, static IP configuration of course, here's what 
dhcpd.conf looks like:

# Options globales
ddns-update-style interim;
authoritative;
default-lease-time  86400; # un jour
max-lease-time      86400; # un jour

# Données du réseau local
option broadcast-address    192.168.1.255;
option subnet-mask          255.255.255.0;
option routers              192.168.1.254;
option domain-name-servers  62.4.16.70, 62.4.17.69;
option domain-name          "local";

# Plage d'adresses dynamiques
subnet 192.168.1.0 netmask 255.255.255.0 {
   range 192.168.1.1 192.168.1.240;
}

host raymonde {
   hardware ethernet 00:20:ed:b8:e8:ec;
   fixed-address 192.168.1.2;
   option host-name "raymonde";
}

b) on the client side, just a plain (default) DHCP client configuration. 
Now the client ("raymonde") gets his pre-defined address OK. And even 
the hostname gets transmitted. Now the question is: how do I also assign 
the domain name ("local") to the client?

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?

Cheers,

Niki




More information about the CentOS mailing list