# [solved] dhcpcd will not configure hostname from dhcp/dns

## venom2099

I have a host configured eth0 for dhcp using dhcpcd.  I get an ip, dns works etc, but the hostname always remains localhost.  I can't for the life of me get the dhcp dns name to auto set on the host.  This used to work great with dhcpcd 3.2.3, but not with 4 or 5, and 3 is no longer available.  Any ideas?Last edited by venom2099 on Fri Oct 16, 2009 5:06 pm; edited 1 time in total

----------

## DONAHUE

Trying 

```
dhcpcd -HD eth0
```

???

----------

## venom2099

 *DONAHUE wrote:*   

> Trying 
> 
> ```
> dhcpcd -HD eth0
> ```
> ...

 

```

dhcpcd: invalid option -- 'H'

usage: dhcpcd [-dgknpqxyADEGHKLOTV] [-c script] [-f file] [-e var=val]

              [-h hostname] [-i classID ] [-l leasetime] [-m metric] [-o option]

              [-r ipaddr] [-s ipaddr] [-t timeout] [-u userclass]

              [-F none|ptr|both] [-I clientID] [-C hookscript] [-Q option]

              [-X ipaddr] <interface>

```

-H is not a valid option even though it appears in the usage, it does not appear in the man page.

----------

## DONAHUE

I saw that. Apparently dhcpcd gave up on using the server to provide a hostname. dhclient does not either according to http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=3#doc_chap3 . nor does pump per its man page.

----------

## venom2099

the dhcpcd man page says this:

```

If the hostname is currently blank, (null) or localhost, or force_hostname is YES or TRUE or 1 then dhcpcd sets the hostname

     to the one supplied by the DHCP server.  dhcpcd then daemonises and waits for the lease renewal time to lapse.  It will then attempt to renew its lease and reconfig-

     ure if the new lease changes.

```

so it claims that if force_hostname is YES it will use the dhcp server name.... Where and how does one set this?  I have already left the hostname as blank, (null) and localhost and in all cases it stays that way.

----------

## UberLord

Older dhcpcd versions used to lookup the hostname in DNS if not supplied by the DHCP server.

dhcpcd-5 can still do this, just not by default. There's a setting in /etc/dhcpcd.conf you can comment out to enable it.

----------

## venom2099

 *UberLord wrote:*   

> Older dhcpcd versions used to lookup the hostname in DNS if not supplied by the DHCP server.
> 
> dhcpcd-5 can still do this, just not by default. There's a setting in /etc/dhcpcd.conf you can comment out to enable it.

 

I swear I tried that and it didn't work but perhaps I didn't restart when I thought I did.  At any rate this appears to be working.  Thanks for the tip.

----------

## anigel

Hi, same problem here, a few months later.

I just upgraded my workstations to dhcpcd-5.2.12, and setting hostname from DHCP does not work anymore.

My conf is as follows :

```
# nohook lookup-hostname

env force_hostname=YES
```

It was sufficient a few months ago, but it seems it does not work anymore ? Or maybe I made something wrong... But couldn't find what !

Thanks,

----------

## anigel

Hi,

I finally understood what was causing this behaviour.

You can have a look at this bug.

----------

