# Domainname not being set.

## welp

I've set the domainname in /etc/conf.d/domainname, /etc/hosts and /etc/resolv.conf, yet when I boot my computer, the login screen says ""This is welpServer1.unknown_domain".

This is a fresh install (finished this morning) and I'm pretty sure i did it properly. The domainname is supposed to be 01welp.co.uk.

The output of hostname --fqdn is "hostname: No address associated with name" Don't know if that's going to be of any use to anyone, but still...

welp

----------

## didymos

What specifically did you put into each file?

----------

## toralf

For some cases it's enough to set NISDOMAIN in /etc/conf.d/domainname and change the "\O" to "\o" in /etc/issue.

----------

## welp

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

#

127.0.0.1       localhost       welpServer1.01welp.co.uk

```

/etc/conf.d/domainname:

```

# /etc/conf.d/domainname

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

#  0 = let dhcp/whatever override DNSDOMAIN

#  1 = override dhcp/whatever with DNSDOMAIN

OVERRIDE=1

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

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

#

# DNSDOMAIN merely sets the domain entry in /etc/resolv.conf, see

# the resolv.conf(5) manpage for more info.

DNSDOMAIN="01welp.co.uk"

# For information on setting up NIS, please see:

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

NISDOMAIN=""

```

/etc/resolv.conf:

```

# Generated by dhcpcd for interface eth0

nameserver xxx.xxx.xxx.xxx

nameserver xxx.xxx.xxx.xxx

domain 01welp.co.uk

```

(I replaced the IPs of the nameservers for security reasons   :Wink: )

If you want me to paste anymore info (hostnames and so on), let me know

----------

## runningwithscissors

 *Welp wrote:*   

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

 

Try this line

```

127.0.0.1 welpServer1.01welp.co.uk welpServer1  localhost.localdomain  localhost

```

Log out. And check.

----------

## welp

Bingo! It works, thanks - how come that happened?

----------

## runningwithscissors

 *Welp wrote:*   

> Bingo! It works, thanks - how come that happened?

 

Credit where credit is due:

http://gentoo-wiki.com/FAQ_Setting_up_your_FQDN

 :Wink: 

----------

## troymc

 *Welp wrote:*   

> Bingo! It works, thanks - how come that happened?

 

Because in /etc/hosts, the 1st entry is the address, the 2nd is the hostname, and everything else are just aliases.

The system looks at the 2nd entry to determine the domainname.  Yours was simply: localhost.

So it could not determine a domainname.

troymc

----------

## runningwithscissors

 *troymc wrote:*   

>  *Welp wrote:*   Bingo! It works, thanks - how come that happened? 
> 
> Because in /etc/hosts, the 1st entry is the address, the 2nd is the hostname, and everything else are just aliases.
> 
> The system looks at the 2nd entry to determine the domainname.  Yours was simply: localhost.
> ...

 

Then this should work too, I suppose

```

127.0.0.1        welpServer1.01welp.co.uk      localhost

```

----------

## TrevorCampbell

I have just followed this guide and the tip at http://gentoo-wiki.com/FAQ_Setting_up_your_FQDN, but still end up with an empty domainname in resolve.conf.

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

127.0.0.1       kelpie5.priv.kelpie.org kelpie5 localhost.localdomain localhost

```

My /etc/conf.d/domainname

```
# /etc/conf.d/domainname

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

#  0 = let dhcp/whatever override DNSDOMAIN

#  1 = override dhcp/whatever with DNSDOMAIN

OVERRIDE=1

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

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

#

# DNSDOMAIN merely sets the domain entry in /etc/resolv.conf, see

# the resolv.conf(5) manpage for more info.

DNSDOMAIN="priv.kelpie.org"

# For information on setting up NIS, please see:

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

NISDOMAIN=""

```

But resolve.conf is only

```
# Generated by dhcpcd for interface eth1

domain

nameserver 192.168.0.253

```

I am using an ADSL router as my DNS and DHCP server.  Everything works OK for the internet but if I try to use dig or nslookup I get error:

```
kelpie5 ~ # dig www.google.com

dig: parse of /etc/resolv.conf failed

```

----------

## UberLord

Try upgrading to dhcpcd-2.0.5 as your resolv.conf was created by an earlier version.

----------

## troymc

 *TrevorCampbell wrote:*   

> 
> 
> ```
> # Generated by dhcpcd for interface eth1
> 
> ...

 

The blank domain line is the problem.

Hopefully Uberlord's suggestion will fix it, as it definitely appears to be a DHCP issue.

Or maybe you have DHCP mis-configured to send out a blank domain name. (never tried that myself, I would hope that dhcpd would complain though.)

troymc

----------

## UberLord

 *troymc wrote:*   

> Or maybe you have DHCP mis-configured to send out a blank domain name. (never tried that myself, I would hope that dhcpd would complain though

 

Sending a space in a DNS domain name is invalid.

Some people do it to have multiple search domains, but it is still invalid.

However, no dhcp client in portage checks if the supplied DNS name is valid or not - we just use what the DNS server tells us too assuming that the server is correct.

----------

