Answer the question
In order to leave comments, you need to log in
How to set system hostname by getting it from dhcpd?
Everything is done on centos 6.5.
A piece of dhcdp settings
host mon1 {
hardware ethernet 00:50:56:b4:5a:39;
fixed-address 10.60.0.110;
option domain-name "abboom.world";
option host-name "mon1";
ddns-hostname "mon1.abboom.world";
}
lease {
interface "eth0";
fixed-address 10.60.0.110;
option subnet-mask 255.255.255.0;
option dhcp-lease-time 300;
option dhcp-message-type 5;
option dhcp-server-identifier 10.60.0.3;
option host-name "mon1";
renew 1 2014/04/21 19:21:21;
rebind 1 2014/04/21 19:23:30;
expire 1 2014/04/21 19:24:08;
}
lease {
interface "eth0";
fixed-address 10.60.0.110;
option subnet-mask 255.255.255.0;
option dhcp-lease-time 300;
option dhcp-message-type 5;
option dhcp-server-identifier 10.60.0.3;
option host-name "mon1";
renew 1 2014/04/21 19:22:09;
rebind 1 2014/04/21 19:24:21;
expire 1 2014/04/21 19:24:59;
}
lease {
interface "eth0";
fixed-address 10.60.0.110;
option subnet-mask 255.255.255.0;
option dhcp-lease-time 300;
option dhcp-message-type 5;
option dhcp-server-identifier 10.60.0.3;
option host-name "mon1";
renew 1 2014/04/21 19:24:10;
rebind 1 2014/04/21 19:26:31;
expire 1 2014/04/21 19:27:09;
}
Answer the question
In order to leave comments, you need to log in
If your trying to make CentOS/Fedora boxes to get hostname remember you need
to have localhost.localdomain in /etc/sysconfig/network.
HOSTNAME=localhost.localdomain
see around line 252-261
/etc/sysconfig/network-scripts/network-functions
need_hostname ()
{
CHECK_HOSTNAME=`hostname`
if [ "$CHECK_HOSTNAME" = "(none)" -o "$CHECK_HOSTNAME" = "localhost" -o
\
"$CHECK_HOSTNAME" = "localhost.localdomain" ]; then
return 0
else
return 1
fi
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question