# [SOLVED] Strange DNS problem, Domainname not setting on boot

## humbletech99

I've got a strange DNS problem where the domainname is not set on boot. It's just blank.

I've got the line in my /etc/conf/domainname:

```
DNSDOMAIN="mydomain.com"
```

I've added domainname to the default runlevel so theoretically it should set it at boot time. This is how I've always done it on loads of other machines and it's always worked. My full /etc/conf/domainname is shown below:

```

# /etc/conf.d/domainname

# $Header: /var/cvsroot/gentoo-src/rc-scripts/etc/conf.d/domainname,v 1.1.4.1 2005/02/19 02:13:53 vapier Exp $

# When setting up resolv.conf, what should take precedence?

# If you wish to always override DHCP/whatever, set this to 1.

OVERRIDE=1

# To have a proper FQDN, you need to setup /etc/hosts and /etc/resolv.conf

# properly (domain entry in /etc/resolv.conf, and FQDN in /etc/hosts).

#

DNSDOMAIN="mydomain.com"

# This only set what /bin/hostname returns.  If you need to setup NIS, meaning

# what /bin/domainname returns, please see:

#

#   http://www.linux-nis.org/nis-howto/HOWTO/

#

#NISDOMAIN=""

```

Last edited by humbletech99 on Tue Dec 20, 2005 5:45 pm; edited 1 time in total

----------

## Po0ky

domainname should be added to the boot runlevel

and make sure you have adjusted your /etc/hosts

```

127.0.0.1 localhost machine.domain.com machine

#10.0.0.13 machine.mydomain.com machine

```

----------

## humbletech99

it is in the boot runlevel as well....

----------

## humbletech99

I'm still getting no domainname for some reason. I just rebooted and ran

```
domainname

(none)
```

----------

## UberLord

That's a NIS domain   :Rolling Eyes: 

Try the command 

```
dnsdomainname
```

----------

## Po0ky

domainname -d will give you the domainname set in /etc/conf.d/domainname

domainname on itself is not set by the domainname scripts.

if you need this for some reason, I suggest you either file a bug report for it

or just put 

```
domainname YOURDOMAINNAME.COM
```

 in local.start

----------

## humbletech99

oh yeah   :Embarassed:  , you'd think I hadn't set up loads of these before...

dnsdomainname also returns blank

----------

## humbletech99

The setting in /etc/conf.d/domainname is correctly DNSDOMAIN, however and it does not appear to be working. The OVERRIDE setting only applies to dhcp, but I wonder if this could this be causing a problem...

----------

## m_sqrd

Check the setting in your /etc/nsswitch.conf and see which way your trying to resolv the names.

the line 

```

hosts:       dns files

```

say used dsn first the use local file {/etc/hosts} next

if yours has "hosts: files dns " then your /etc/hosts file dose not have the correct format  ie

IP_Address FQDN Alias 

if it has it the other way hosts: dns files then you some thing wrong in you dns settup.

----------

## humbletech99

did that, rebooted and I still get nothing when I type dnsdomainname. There doesn't seem to be anything wrong with my /etc/conf.d/domainname so I dunno why this is happening. Can you see anything wrong there? The problem must lie elsewhere. But where?

----------

## Po0ky

post `cat /etc/hosts`

post `cat /etc/nsswitch.conf`

tq; )

----------

## humbletech99

cat /etc/hosts

```
# /etc/hosts:  This file describes a number of hostname-to-address

#              mappings for the TCP/IP subsystem.  It is mostly

#              used at boot time, when no name servers are running.

#              On small systems, this file can be used instead of a

#              "named" name server.  Just add the names, addresses

#              and any aliases to this file...

# $Header: /var/cvsroot/gentoo-src/rc-scripts/etc/hosts,v 1.8 2003/08/04 20:12:25 azarah Exp $

#

127.0.0.1       localhost mybox.mydomain.com mybox

# IPV6 versions of localhost and co

::1 ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

```

cat /etc/nsswitch.conf

```
# /etc/nsswitch.conf:

# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/nsswitch.conf,v 1.1 2005/05/17 00:52:41 vapier Exp $

passwd:      compat

shadow:      compat

group:       compat

# passwd:    db files nis

# shadow:    db files nis

# group:     db files nis

hosts:       dns files

networks:    files dns

services:    db files

protocols:   db files

rpc:         db files

ethers:      db files

netmasks:    files

netgroup:    files

bootparams:  files

automount:   files

aliases:     files

```

----------

## Po0ky

did you try out 

```
hosts:       files dns
```

I suspect your dns isn't up yet in your boot-runlevel

----------

## humbletech99

It was originally hosts: files dns, but I changed it on a suggestion above. 

Domainname is already in both the boot and default runlevels. 

I've just looked at another machine and it has the hostname and domainname set up but they are not put in /etc/conf.d/domainname or net or hostname or local.start so I don't know how that machine is doing it!

Managed to get dnsdomainname to return the right thing by editing /etc/hosts and changing it to:

```
127.0.0.1       localhost

192.168.1.8     mybox.mydomain.com mybox
```

instead of having it all on the 127 line.

The weird thing is, when I have just

```
192.168.1.8     mybox
```

then dnsdomainreturns nothing and the next line is a prompt. When I have 

```
192.168.1.8     mybox.mydomain.com
```

and run dnsdomainname I get 

```
dnsdomainname: Unknown host
```

and when I put 

```
192.168.1.8     mybox mybox.mydomain.com
```

I also get nothing from dnsdomainname. It is only when I put 

```
192.168.1.8     mybox.mydomain.com mybox
```

then it works.

Developers? Is this a bug?Last edited by humbletech99 on Tue Dec 20, 2005 2:18 pm; edited 2 times in total

----------

## UberLord

I'm going to hazard a guess here and say that you're using DHCP and your /etc/resolv.conf isn't being written correctly - it has no "domain" or "search" line

----------

## humbletech99

nope, static (the other machine is a server and also static)

/etc/resolv.conf from this machine is as follows:

```
nameserver ipaddress

search mydomain.com

domain mydomain.com
```

----------

## UberLord

OK, ensure that your /etc/hosts is structured like so

```
192.168.0.1     host.domain host
```

replace the ip with your ip address, host with your hostname and domain with your domainname

----------

## humbletech99

yeah, that's what I eventually came to if you read above but it strikes me as stupid to have to be so militant with the order of the hosts file line for this. Is this intentional or just accidental? Is it documented somewhere I missed or is it on a buglist?

Oh now I'm confused, the other server doesn't have this in it's /etc/hosts (there's no reference to itself other than 127 which doesn't even has it's hostname) and still I have now idea where it has set it's hostname domainname (since it's not in /etc/conf.d/hostname or domainname) but all works fine. Why doesn't mine then?

----------

## UberLord

dns domain name has to be resolvable on the machine.

So if it's not resolable by the dns server, it has to be in /etc/hosts - and yes it normally has to be the first entry.

----------

## humbletech99

aha, it've changed the name and called it something else so it can't find itself in dns as no record exists for that machine!

when putting the name back to the old name it works fine...

thanks for that, I didn't realise that it relied on resolving it's own host name via a dns server just to be able to apply it's own domain name label!

next stop adding the new name to the dns server (although everyone will probably use the old name anyway!).

----------

