Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] let dhcpcd retrieve hostname from DHCP server ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
anigel
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 1888
Location: Un petit bled pas loin de Limoges ;-)

PostPosted: Wed Aug 29, 2012 10:14 am    Post subject: [solved] let dhcpcd retrieve hostname from DHCP server ? Reply with quote

Hi,

I am using dhcpcd-5.2.12, compiled with zeroconf support, on a fresh amd64 install. I'll have to deploy a tarball of this system on a high number of hosts, so I need network auto-configuration. And more particularly, I need the DHCP client on each host to set the hostname according to whats supplies the DHCP server. It has been working for months with my last install, but I cannot manage to get it working today...

Maybe someone can tell me where is the mistake...

/etc/hosts has not been modified. And here is my dhcpcd.conf

Code:
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Inform the DHCP server of our hostname for DDNS.
hostname
# To share the DHCP lease across OSX and Windows a ClientID is needed.
# Enabling this may get a different lease than the kernel DHCP client.
# Some upstream DHCP servers may also require a ClientID, such as FRITZ!Box.
#clientid

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
env force_hostname=YES


I tried several options, but when I ask for hostname, my build box always tells me "localhost". Strange, since IP configuration from DHCP server is perfect. How can I manage to force dhcpcd to set the hostname according to the DHCP server ?

Thanks,
_________________
Il y a 10 sortes d'individus en ce bas-monde : ceux qui causent binaire, et les autres.


Last edited by anigel on Thu Aug 30, 2012 1:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 2584

PostPosted: Wed Aug 29, 2012 12:59 pm    Post subject: Reply with quote

I'll look at one of my home systems tonight, if you don't have an answer before then. On my normal client machines I'm running centrally-administered "static IP" from my DHCP server. I have the MACs of all of my systems in dhcpd.conf mapped to their hostnames. My clients are set up as dhcp clients, and receive their hostnames from the server. Because of the MAC<->hostname mapping, it all ends up looking static.

The one client that's up at home right now really does have a static IP, because it's my mythbackend server. But tonight I can fire up another client, and check its configuration for you.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
anigel
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 1888
Location: Un petit bled pas loin de Limoges ;-)

PostPosted: Wed Aug 29, 2012 1:38 pm    Post subject: Reply with quote

Hi,

depontius wrote:
I'll look at one of my home systems tonight, if you don't have an answer before then. On my normal client machines I'm running centrally-administered "static IP" from my DHCP server. I have the MACs of all of my systems in dhcpd.conf mapped to their hostnames. My clients are set up as dhcp clients, and receive their hostnames from the server. Because of the MAC<->hostname mapping, it all ends up looking static.

The one client that's up at home right now really does have a static IP, because it's my mythbackend server. But tonight I can fire up another client, and check its configuration for you.


Thanks, that's exactly my network configuration. I used this topoly for ages without problem. But I can't manage to get it working... Probably a small mistake, but I was not able to find what...
_________________
Il y a 10 sortes d'individus en ce bas-monde : ceux qui causent binaire, et les autres.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 2584

PostPosted: Wed Aug 29, 2012 2:14 pm    Post subject: Reply with quote

I'll take a look tonight.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 2584

PostPosted: Thu Aug 30, 2012 12:25 am    Post subject: Reply with quote

Oops, now I don't know why my system is working.

/etc/conf.d/net:
Code:
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).
config_eth0=( "dhcp" )
dhcp_eth0="nodns"
dns_domain_lo="????????.???"
dns_servers_lo="127.0.0.1 ???.???.???.???"
dns_search_lo="????????.???"

/etc/dhcpcd.conf:
Code:
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Inform the DHCP server of our hostname for DDNS.
#hostname
# To share the DHCP lease across OSX and Windows a ClientID is needed.
# Enabling this may get a different lease than the kernel DHCP client.
# Some upstream DHCP servers may also require a ClientID, such as FRITZ!Box.
#clientid

# A list of options to request from the DHCP server.
#option domain_name_servers, domain_name, domain_search, host_name
#option host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

# dhcpcd ebuild requested no zeroconf
noipv4ll

/etc/dhcpcd.exit-hook:
Code:
#!/bin/sh

LOGGER="/usr/bin/logger -t dhcpcd.exit-hook"

new_short_name=`echo ${new_host_name} | /usr/bin/cut -d'.' -f 1`

${LOGGER} "reason           =${reason}"
${LOGGER} "skip_hooks       =${skip_hooks}"
${LOGGER} "interface        =${interface}"
${LOGGER} "state_dir        =${state_dir}"
${LOGGER} "new_ip_address   =${new_ip_address}"
${LOGGER} "old_host_name    =${old_host_name}"
${LOGGER} "new_host_name    =${new_host_name}"
${LOGGER} "old_fqdn_name    =${old_fqdn_name}"
${LOGGER} "new_fqdn_name    =${new_fqdn_name}"
${LOGGER} "new_short_name   =${new_short_name}"

if [ "x${if_up}" = "xtrue" ] ; then
  local_host_name=`/bin/hostname`
  if [ "x${local_host_name:0:5}" = "xlocal" ] ; then
    remote_host_name=`/usr/bin/host ${new_ip_address}`
    remote_short_name=`echo ${remote_host_name} | /usr/bin/cut -d'.' -f 1`
  fi
fi

${LOGGER} "local_host_name  =${local_host_name}"
${LOGGER} "remote_host_name =${remote_host_name}"
${LOGGER} "remote_short_name=${remote_short_name}"


That last one is just a little ditty I added for debug purposes, and never got around to removing. It gives me a bit better view of what dhcpcd has just done, as it exits.

The place where I have a problem is in dhcpcd.conf, "nohook lookup-hostname". With that in place, I don't know how I'm getting my hostname, but somehow I am.

I need to look at this more. I hope this at least helps a little - it's only confusing me, now.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
anigel
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 1888
Location: Un petit bled pas loin de Limoges ;-)

PostPosted: Thu Aug 30, 2012 1:55 pm    Post subject: Reply with quote

Hi,

I finally understood what was causing this behaviour.

You can have a look at this bug.

Thanks for your help ;)
_________________
Il y a 10 sortes d'individus en ce bas-monde : ceux qui causent binaire, et les autres.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 2584

PostPosted: Thu Aug 30, 2012 2:37 pm    Post subject: Reply with quote

I get "not found" on that link or for that bug number. What package is it against, and do you know the title?
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum