# dhcpd -D does not update domainname

## blob2004

Hi -- I only use the dhcp client on my gentoo install.  I set it up like this:

iface_eth0=dhcp

dhcp_eth0="-D"

When the network starts, dhcp gets me an IP and sets the domain name. If I issue the command:

#domainname

I get:

mydomain.com

#

However, various programs that use the domainname can't seem to find it:

#hostname --fqdn

hostname: Host name lookup failure

#dnsdomainname

dnsdomainname: Host name lookup failure

Even the basic tty login can't see it:

This is mypc.unknown_domain ...

mypc login: _

What do I need to change to ensure that the domain name I receive via DHCP is used by other commands?

----------

## aetius

This is probably a combination of problems.  Lets see:

1) are you receiving the domain name "mydomain.com" from your dhcp server?

2) did you configure it that way?

3) if you did, why?

4) What does your "/etc/resolv.conf" file look like on your client after getting an address?

5) does the nameserver configured in your /etc/resolv.conf have a resolution for mydomain.com --  i.e., does this command:

```

host mydomain.com

```

return an ip address?

6) if it doesn't, it's your server, and you are not connected to the internet, then you need to configure your nameserver to be authoritative for the "mydomain.com" domain.

7) if it does, the DNS server isn't yours, and you ARE connected to the internet, then you need to choose another domain name to deliver via dhcp, because that one is taken  -- preferably one that will never exist anywhere on the web, like localdomain.local (or better yet, nothing at all).

The problem you are having is that these other programs are trying to resolve that hostname via a DNS server, a host file, or NIS and are failing -- which makes them very unhappy.  It could be that you aren't configuring /etc/resolv.conf at all ( you might want to let dhcpcd do that if you have the DHCP server configured right).

Further, the "domainname" command is associated with NIS/YP, and is just a setting on your system that happens to be set by dhcpcd -D.  It is only related to DNS in a sideways sort of way.  You want to use the "dnsdomainname" command to check what you are trying to set and check.

In short, you can't force other programs to use the domain name you set *unless* you have a DNS server handy to trick them, or you hard-set the information in /etc/hosts (which only works for your machine and any others you configure in there).  Most programs will follow the standard order and check /etc/hosts first to resolve a name, then go out to you configured nameserver (/etc/resolv.conf).

----------

## blob2004

 *aetius wrote:*   

> This is probably a combination of problems.  Lets see:
> 
> 1) are you receiving the domain name "mydomain.com" from your dhcp server?
> 
>      Yup
> ...

 

----------

## aetius

I *think* what you want dhcpcd to do instead of the "-D" option is the "-H" option, i.e. set the fqdn of the system to the right hostname.  The wierd part is that you are getting lookup failures when you should be getting nothing in return (from 'dnsdomainname", for example).  It looks like -D is associated with NIS/YP entirely (which I didn't realize on my first look at this), and modifies the /etc/yp.conf file, which we don't care about (I'm assuming).  Try -H and see if that clears up the problem.

----------

## blob2004

I tried it again with -H (and also with -D -H) with no change in behaviour.

It seems that these tools are simply broken.

FYI my hostname is not known to the local DNS server, although the DHCP server feeds the domain name just fine.

----------

## aetius

The tools being broken is *highly* unlikely.  DHCP will deliver whatever hostname and domainname it has been set to deliver, it doesn't care.  If nothing is delivered, it will set the hostname to whatever the IP address it was given resolves to.  It's possible that you are confusing the heck out of the resolver by assigning a hostname and a DNS domainname that don't match what's in the DNS server for your IP address.

My suggestion at this point is to put your hostname in DNS, or failing that put your hostname in /etc/hosts.  Until your system is able to resolve your own hostname/domainname, it's very hard to see if something else is going wrong.

Can we see the configuration on the DHCP server that is delivering the address to the client?  Also, can we see the results of the dhcpcd lease-grab from /var/lib/dhcpc/dhcpcd-eth0.info?  Also, if you modify your /etc/hosts, I'd like to see that as well.  Something somewhere isn't set right.

----------

## blob2004

Info from dhcpd.eth0.info

IPADDR=10.18.64.86

NETMASK=255.255.255.0

NETWORK=10.18.64.0

BROADCAST=10.18.64.255

GATEWAY=10.18.64.1

DOMAIN='att-intra.com'

DNS=10.1.163.18,10.1.1.13

DHCPSID=10.1.163.18

DHCPGIADDR=10.18.64.3

DHCPSIADDR=0.0.0.0

DHCPCHADDR=00:50:DA:CA:92:D3

DHCPSHADDR=00:0E:84:6D:01:BF

DHCPSNAME=''

LEASETIME=691200

RENEWALTIME=345600

REBINDTIME=604800

INTERFACE='eth0'

CLASSID='Linux 2.6.7-gentoo-r8 i686'

CLIENTID=00:50:DA:CA:92:D3

Note that DOMAIN is returned successfully,  Nevertheless, the commands domainname and dnsdomainname continue to fail

FYI my hostname is NOT in our local DNS, although it is in WINS. 

Since my IP changes from time to time, putting my fqdn in /etc/hosts is probably not a good option long term.  However, I did it for a test, putting my current ip and my fqdn.  The results were the same.  The commands still fail as before

----------

## addicha

Just a quick newbie question:

When my computer strats is says myhostname.unknown_domain.com 

How cha i change the unknown_domain.com to which ever name i want?

Thanks

----------

## aetius

 *blob2004 wrote:*   

> Note that DOMAIN is returned successfully,  Nevertheless, the commands domainname and dnsdomainname continue to fail
> 
> FYI my hostname is NOT in our local DNS, although it is in WINS. 
> 
> Since my IP changes from time to time, putting my fqdn in /etc/hosts is probably not a good option long term.  However, I did it for a test, putting my current ip and my fqdn.  The results were the same.  The commands still fail as before

 

If your hostname does not exist in DNS (or, worst case, in /etc/hosts), you have no fqdn attached to your IP address, which is the root of your problems.

I fiddled with the DOMAIN setting in dhcpd and examined its interaction with dhcpcd in Gentoo -- all it seems to do is set the 'search" parameter in /etc/resolv.conf -- not what you need.

WINS does you zero good.  WINS deals only with NetBIOS name resolution, and that's not what we're talking about -- that's Samba land.  Base Linux doesn't know anything about WINS.

If all you do is change /etc/hosts, tools like ping will start working but hostname, dnsdomainname, etc will continue to return whatever they were set to at boot.  In order to reset it, I think you'll need to assign it in /etc/hostname, and then reboot (you can re-run /etc/init.d/hostname, but all kinds of things depend on it and it could cause problems).  Judging from what /etc/init.d/hostname says, you might need to set the "domain" option in /etc/resolv.conf in order to get a response from dnsdomainname that makes sense -- that part I don't know about, it doesn't sound right to me.

There are three ways to fix this:

1) assign yourself a static IP from the DHCP server via MAC reservation, modify /etc/hostname (and/or /etc/resolv.conf), and then set /etc/hosts to reflect the name you want.  This is not a good option, since you and only you will be able to resolve that name as belonging to your machine.

2) Make sure your DNS is configured properly to perform both forward and reverse name resolution for dynamic IP addresses assigned by the DHCP server, and let dhcpcd -H handle setting the DNS domainname and hostname after it gets an address.

3) Set /etc/hostname to localhost, don't set a domain setting in /etc/resolv.conf, and leave the system with no name.  This is the safest route if your DNS server is not configured to resolve dynamic IP addresses to names.

----------

## aetius

 *addicha wrote:*   

> Just a quick newbie question:
> 
> When my computer strats is says myhostname.unknown_domain.com 
> 
> How cha i change the unknown_domain.com to which ever name i want?
> ...

 

according to /etc/init.d/hostname you need to set the "domain" entry in /etc/resolv.conf -- I'm not sure if that's "correct" or not.  You can probably get away with assigning the entire fqdn to /etc/hostname (assuming that you HAVE an fdqn in the first place).  You can also use the -H option for dhcpcd to have it assign the hostname for the IP address DHCP gave it.

----------

## aetius

https://forums.gentoo.org/viewtopic.php?t=192326

This thread might prove more useful than my explanations.

----------

