# The string ".nknown_domain" appended to my hostnam

## nick_downing

dear fellow Gentooists,

Some help with my network setup would be greatly appreciated.  It's not a catastrophic problem, just an annoyance at this stage...  the problem is that before logging in, the "login" program prints a banner like this:

This is note.known_domain (Linux i686 2.4.20-gentoo-r5) 05:16:39

This is with a file "/etc/hostname" containing the following single line:

note

I also tried putting a file "/etc/dnsdomainname" containing the following:

intranet

but the dnsdomainname file doesn't seem to have any effect.  I tried a hostname of "note." which resulted in "note..nknown_domain" being printed.  Trying "note.intranet" gives "note.intranet.nknown_domain", how frustrating!  I also tried a file "/etc/domainname" but that was only a guess.  It doesn't seem to have any effect, anyway.

I did wonder if this might be connected with another problem I'm having:  When I try to start "postfix", it fails with a message like this:

/sbin/gethostbyname: No such file or directory

Do I need to install some kind of network tools package?  Trying a command like "qpkg --find-file gethostbyname" didn't get me anywhere.

Help!  (I still love gentoo... by the way, a gentoo 1.4rc4 install didn't seem to have this problem, but this recent gentoo 1.4 install, does...??!)

cheers,

Nick

----------

## pilla

According to /etc/init.d/hostname,  the dns domain name should be set in /etc/resolv.conf 

 *Quote:*   

> 
> 
>         # We use whatever is in /etc/hostname here.  That means:
> 
>         #
> ...

 

Anyway, it does not matter that much.

----------

## nick_downing

dear Pila,

Firstly, a belated thankyou, I have been quite busy but I recently found time to experiment with this annoying domainname issue.

I'm afraid your suggestion didn't work though, there are a few issues, for one thing, I'm using DHCP and so any changes I make in resolv.conf get renamed to resolv.conf.sv and have no effect.  I haven't figured out how to make DHCP put a hostname in resolv.conf (the recommended switch doesn't do anything, so I guess this probably needs to be changed at the server end).  Anyway, I edited the file manually and disabled DHCP and... no dice.  The ".nknown_domain" is still appended to my hostname, despite several reboots, et cetera.

So then I decided to look further.  Firstly I found a mistake in the portage file "/usr/portage/sys-apps/util-linux/files/util-linux-2.11z-agetty-domainname-option.patch" ... This is responsible for the message, which should be ".unknown_domain" rather than ".nknown_domain".  To fix it, we would need to edit the patch and insert a single "dot" at the start of this 'C' text string.  I'll report this on the bugtracker soon, but it's only a cosmetic fix, so it's probably not too important (though it annoys me!!).

Some careful investigation with a testprogram that I wrote, which calls gethostname(), and then gethostbyname(), testing the return values of each call, revealed that my configuration is wrong because.. trala.. the file "/etc/host.conf" isn't there.  If I "touch /etc/host.conf" to make a null file, I start to get a different error message from my testprogram.  I also get the same error message when I try to run postfix, so it's obviously an important part of the configuration!!  I really want postfix working!!

Now some questions, any help with this would be greatly appreciated.

1.  Does this happen to every Gentoo user installing from a LiveCD?  If not, where did I go wrong?  Is there a default version of the host.conf file that I could install?  Is it missing because I installed an earlier Gentoo and then upgraded things later using a command like "emerge --update world" ??  I certainly noticed some big changes to the rc scripts, etc.  I would have expected any new or revised configuration files to show up as "/etc/._cfg0000_host.conf" or similar, but there's no such file!

2.  Is this "host.conf" file needed in addition to the old "nsswitch.conf" file ??  I noticed I also have the "nsswitch.conf" file, which has a line saying "hosts: files dns" so it looks like I'll have to create a "host.conf" file with a line saying "order hosts bind" to get the same effect.  Would I be right in thinking that some applications use the latter (via the resolv+ library) and sone applications use the former (via some other resolver library) ??  Can I recompile things to use the same resolver everywhere?

3.  How can I set my local hostname in an environment where my local IP address changes each session?  (I'm using DHCP).  In "/etc/hosts" or in my "bind" configuration, I can set hostnames for static IP addresses, but this is no good, because I don't know my IP address ahead of time.  Does the DHCP server need to create a dynamic DNS entry, with a correct hostname for my notebook, each time an IP address is leased to me?  Does the gethostbyname() function then need to query my own IP address via DNS in order to return the local hostname??  This seems terribly roundabout, and I'm not "root" on DHCP server, so I can't fix it.

Help!!  I just want postfix working!!  Oh sigh!!  Surely someone else has encountered this problem too??  Or am I missing something really, really obvious?  (It has happened in the past...... grin......  :Wink: 

cheers,

Nick

----------

## kallamej

The .nknown_domain problem is discussed in this thread. Does it solve any of your problems?

----------

## nick_downing

thanx Kallamej, I checked out that thread (plus another linked thread), although, I tried everything suggested in both threads, and it didn't seem to fix my specific problem.  Most people seem to have solved it by changing /etc/issue to use "\o" rather than "\O" but I am more concerned about the internals, specifically the fact that gethostbyname() is returning NULL... after this, calling herror() gives a message of "Unknown host".

The NULL return value from gethostbyname() seems to be the reason for my postfix problem.  Anyway, I proceeded a bit further by executing this:

echo "order hosts bind" > /etc/host.conf

and inserting the following line into /etc/hosts:

10.0.0.156 note.intranet

however this still raises a few issues, firstly, I don't know my IP address ahead of time because of DHCP, and secondly, I have to set a FQDN in /etc/hostname, against the instructions in /etc/init.d/hostname ... hmm.  Even if I do this, the login banner is still wrong, I've seen a few possibilities "note.(none)" and "note.intranet.intranet" but even this is a big improvement over "note.nknown_domain".  I think I can now get postfix to work.  But a proper solution would be better.  Anyway I think postfix might get a little confused by "note.intranet.intranet" ...??

Reading the other threads there seemed to be some confusion over whether the scripts "/etc/init.d/hostname" and "/etc/init.d/domainname" should be added to runlevel "boot" or "default".  It looks like "boot" is a more popular selection, but I am currently trying putting them both in "default".  I've added the word "net" in the dependencies inside the "/etc/init.d/domainname" file, because this causes "dhcpcd" to run before "/etc/init.d/domainname".  Therefore when the script edits the "resolv.conf" file, it builds upon the information already placed there by "dhcpcd".  Although, it looks like the line "domain intranet" at the start of my "resolv.conf" does absolutely nada.... one of the threads suggested that it should be "search intranet" rather than "domain intranet"... ideas?

In desperation I'll attach my testprogram, it allows you to set a hostname with a command line parameter, which I think is equivalent to setting it in /etc/hostname and rebooting.  Then, regardless of command line parameters, it attempts to find the current machine name, using the same logic that's used in the login program when \O is encountered in the file /etc/issue.  Error messages are printed if errors are encountered.

Using the testprogram you can see that if you set the hostname to "note" then the file /etc/hosts must have an entry such as "10.0.0.224 note" whereas, if you set the hostname to "note.intranet" then /etc/hosts must have an entry such as "10.0.0.224 note.intranet" ... Neither of these are compatible with the algorithm used in the login program (specifically the file "util-linux-2.11z-agetty-domainname-option.patch") ... so I am guessing there is a balls-up somewhere.  Either the initscript maintainers should remove their recommendation about not putting a FQDN in /etc/hostname, or else the util-linux maintainers should change their patch so it doesn't expect an FQDN returned by gethostname() ...???

If someone more knowledgeable than myself, could step in, I would be quite pleased...  I'm capable of troubleshooting technical issues.... but this is more of an issue of convention and I don't know what the usual conventions are.... (though I guess gentoo is not your conventional Os  :Wink: 

cheers,

Nick

ps. the testprogram is at:

http://www.hytechscales.com/gentoo_linux_files/dom.c

----------

## kallamej

Well, it seems like noone more knowledgable bites ... I'm not that, by the way. Anyway, if you think that there is some mismatch between different packages, or an outright bug, it's time for a bug report, if there isn't one there already. That way it is more likely to be spotted by a developer.

----------

## Slaine_UK

FWIW I am getting a similar problem with the login banner.  Except in my case it is printing:

This is hoth.(none) (Linux i686 2.4.20-gentoo-r6) 20:10:14

I've not investigated it in any depth yet, but I'm looking to see what I can dig up.

----------

## Slaine_UK

I assume that when you do hostname - d or hostname -f you're getting nothing returned.  ie null string. That is what I was getting.

Anyhow I searched through some of the posts on here and finally found one from someone who sounded like they knew what they were talking about  :Smile: 

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

The outcome is that you do not have to use '/etc/dnsdomainname' or '/etc/nisdomainname' or have to start '/etc/init.d/domainname' at startup.

It's simply a case of altering yout /etc/hosts files as follows (this is for DHCP and copied direct from baelbouga's post)

```
127.0.0.1   <hostname>.<domainname>   <hostname>   localhost
```

I did this and rebooted, then hostname, hostname -f and hostname -d were reporting the correct details.

I then changed the /o in /etc/issue to /O and the login prompt was fixed too.

If it works thanks to baelbouga not me  :Very Happy: 

----------

## nick_downing

Thanx people, looks like that's probably the solution.  I can't try it just yet, but I will do so.  Does everyone agree that this piece of knowledge should be transferred into the installation guide?  It would probably save a lot of trouble (so far I think this problem is mentioned in 4 threads!!).

cheers,

Nick

 :Very Happy: 

----------

## baelbouga

Section 20 of the install guide (http://www.gentoo.org/doc/en/gentoo-x86-install.xml#doc_chap20) sort of says it. Just not very well. It would be better to have an example of both DHCP and non-DHCP '/etc/hosts' files. This would, I feel, eliminate most of the problems that people have with this particular issue.

----------

## nick_downing

dear all,

The DHCP example works!  I tried it last night.  Having looked at the installation guide (chap20 via the link posted by Baelbouga) I think the need for a change is pretty minor.  So I'm not going crazy posting bug reports (the guys have enough to do already!!).  I should have RTFM in the first place ...  :Wink:   still, I guess this is what forumz are for.

cheers,

Nick

----------

## wyrickre

You might also want to check my solution in this thread.

----------

## Chris W

DHCP can serve up a domain name to your clients.  Just add something like the following to your /etc/dhcp/dhcpd.conf file:

```
option domain-name "my.wonderful.domain.com";
```

 This domain name will be written to the resolv.conf file along with any nameservers the DHCP server tells the client about: 

```
option domain-name-servers 192.168.1.1;
```

----------

## nick_downing

Thanx Chris, very timely.  One of the very next things I'm going to do is set up a DHCP server.  I must say I haven't had any trouble with the hostname lately, the posted solution works fine.

cheers,

Nick

----------

