A
A
alexander sm1ly2014-04-21 22:23:03
DHCP
alexander sm1ly, 2014-04-21 22:23:03

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";
}

dhclient-eth0.leases:
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;
}

and, accordingly,
dhclient-eth0.conf:
send vendor-class-identifier "anaconda-Linux 2.6.32-431.el6.x86_64 x86_64";
timeout 45;
request host-name;
[[email protected] dhclient]# hostname
tmpcentos65
[[email protected] dhclient]# hostname -s
tmpcentos65
How can I make this miracle eat hostname from dhcpd?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
Y
Yuriy Andamasov, 2014-04-21
@sm1ly

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 question

Ask a Question

731 491 924 answers to any question