# fqdn dnsdomainname issues [solved]

## njcwotx

I changed my dnsdomainname settings to rid myself of the warning about not using conf.d/hostname conf.d/domainname.  However, I notice several errors now...

apache2 complains it cant find my fqdn (this is my biggest annoyance)

my hostname at boot is box.(unknown)

hostname -fqdn shows "box" not "box.mydomain.com"

hostname -d shows nothing

I see an error when starting X sessions about no domain name

Here is my configs.  I have no NIS domain, We use DNS in a windows AD domain, and its working.  I removed /etc/hostname and /etc/dnsdomainname files.  All other configs that I know of are shown. 

```

=========== 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: /home/cvsroot/gentoo-src/rc-scripts/etc/hosts,v 1.8 2003/08/04 20:12:25 azarah Exp $

#

127.0.0.1   localhost

192.168.110.8   box box.mydomain.com

192.168.1.49   email.mydomain.com email

192.168.110.2   win2kdc.mydomain.com win2kdc

192.168.110.6   box2.mydomain.com box2

# 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

=========== host.conf =================================

=======================================================

# /etc/host.conf:

# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/2.3.4/host.conf,v 1.2 2004/11/24 05:31:58 vapier Exp $

# The  file /etc/host.conf contains configuration information specific to

# the resolver library.  It should contain one configuration keyword  per

# line,  followed by appropriate configuration information.  The keywords

# recognized are order, trim, mdns, multi, nospoof, spoof, and reorder.

# This keyword specifies how host lookups are to be performed. It

# should be followed by one or more lookup methods, separated by

# commas.  Valid methods are bind, hosts, and nis.

#

order hosts, bind

# Valid values are on and off. If set to on, the resolv+ library treats

# the .local top level domain as link-local domain and sends multicast

# DNS requests to the multicast address 224.0.0.251 port 5353 instead

# of normal DNS requests. If you already use the .local domain in your

# nameserver configuration you will have to switch this option off.

#

mdns off

# Valid  values are on and off.  If set to on, the resolv+ library

# will return all valid addresses for a host that appears  in  the

# /etc/hosts  file,  instead  of  only  the first.  This is off by

# default, as it may cause a substantial performance loss at sites

# with large hosts files.

#

multi off

============ 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 winbind

shadow:      compat

group:       compat winbind

# passwd:    db files nis

# shadow:    db files nis

# group:     db files nis

hosts:       files dns

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

============= conf.d/domanname ========================

=======================================================

# /etc/conf.d/domainname

# 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, meanin

# what /bin/domainname returns, please see:

#

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

# 

#NISDOMAIN=""

========   conf.d/hostname ===============================

==========================================================

HOSTNAME="box"

======== resolv.conf =========================================

==============================================================

nameserver 192.168.110.2

nameserver 192.168.1.2

nameserver 64.89.100.2

nameserver 64.89.100.3

search mydomain.com

domain mydomain.com

```

here is the /etc/init.d/domainname script

```

#!/sbin/runscript

# Copyright 1999-2005 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

depend() {

   need checkroot hostname

   before bootmisc

}

checkconfig_nis() {

   if [[ -f /etc/nisdomainname ]] ; then

      ewarn "You should stop using /etc/nisdomainname and use /etc/conf.d/domainname"

      export NISDOMAIN=$(</etc/nisdomainname)

      return 0

   fi

   [[ -n ${NISDOMAIN} ]]

}

checkconfig_dns() {

   if [[ -f /etc/dnsdomainname ]] ; then

      ewarn "You should stop using /etc/dnsdomainname and use /etc/conf.d/domainname"

      export DNSDOMAIN=$(</etc/dnsdomainname)

   fi

   [[ -z ${DNSDOMAIN} ]] && return 1

   if ! touch /etc/resolv.conf 2> /dev/null ; then

      ewarn "Unable to set domain in resolv.conf (ro root?)"

      return 1

   else

      return 0

   fi

}

start() {

   local retval=0

   local retval2=0

   if checkconfig_nis ; then

      ebegin "Setting NIS domainname to ${NISDOMAIN}"

      /bin/domainname "${NISDOMAIN}"

      retval=$?

      eend ${retval} "Failed to set the NIS domainname"

   fi

   if checkconfig_dns ; then

      ebegin "Setting DNS domainname to ${DNSDOMAIN}"

      resolv=$(grep -v '^[[:space:]]*domain' /etc/resolv.conf)

      [[ ${OVERRIDE} == "1" ]] \

         && resolv="${resolv}"$'\n'"domain ${DNSDOMAIN}" \

         || resolv="domain ${DNSDOMAIN}"$'\n'"${resolv}"

      echo "${resolv}" > /etc/resolv.conf

      retval2=$?

      eend ${retval2} "Failed to set the DNS domainname"

   fi

   return $((retval + retval2))

}

# vim:ts=4

```

----------

## trickypicky75

Take a look at the Gentoo handbook (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8), Chapter 8b (Networking Information)

There's been some changes to baselayout

just edit /etc/conf.d/domainname and /etc/conf.d/hostname

then run

etc-update add domainname default

----------

## m_sqrd

or maybe this 

< 192.168.110.8   box box.mydomain.com

> 192.168.110.8   box.mydomain.com box

----------

## njcwotx

 *trickypicky75 wrote:*   

> Take a look at the Gentoo handbook (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8), Chapter 8b (Networking Information)
> 
> There's been some changes to baselayout
> 
> just edit /etc/conf.d/domainname and /etc/conf.d/hostname
> ...

 

Where do you think I got the instructions for this change in the first place?  I have already done this.

----------

## njcwotx

 *m_sqrd wrote:*   

> or maybe this 
> 
> < 192.168.110.8   box box.mydomain.com
> 
> > 192.168.110.8   box.mydomain.com box

 

Wins the cookie...

fqdn should go first...

This solved all the issues.

----------

## humbletech99

err, trickypicky75 wrote

 *Quote:*   

> etc-update add domainname default

 

don't you mean

```
rc-update add domainname default
```

Although I've had this problem as well and this solution does work for what you're saying, it's kindof a patch over instead of the full solution because the reason you can't get the fqdn properly is that the dns server that resolves for you domain doesn't have a record for this hostname. I've been round and round testing with this and yes, if you put 

```
ipaddress fqdn hostname
```

 (although not the other way around) in /etc/hosts its a successful workaround, it's better to fix your dns. If you don't have your own network dns server for whatever reason, you're at home using your isp's dns servers or you netadmin just doesn't do it then you have to rely on this host file thing for it to work. There are some other issues when doing this instead, I've found one when using mailx but that's another thread... https://forums.gentoo.org/viewtopic-t-414199-highlight-.html

----------

## DumbAss

Great! I had this same problem. By simply changing the order it worked!

----------

