Centos – How to set hostname.domainname from dhcp

centosdhcpdomainhostnameredhat

Running Centos 6.x using dhcp, we want to set the hostname to be FQDN that's obtained from a combination of dhcp options.
As an example if I have two dhcp options
option host-name "foobar";
option domain-name "mydomain.com";

When a client obtains those options via dhcp I would like the hostname to show "foobar.mydomain.com".
Any idea on how to accomplish this?

Best Answer

For that you need to define this "ddns-hostname"

Like this:

host foobar {
  hardware ethernet c0:18:85:e3:13:31;
  fixed-address 10.1.1.129;
  option domain-name "example.org";
  option host-name "foobar";
  ddns-hostname "foobar.mydomain.com";
}