# hostname, dnsdomainname, ndisdomainname and domainname!?

## zepto

How does a Linux workstation determine it's hostname, dnsdomainname, ndisdomainname and domainname in the following scenario?

Picture?

```
<[           Internet - WWW etc.        ]>

                     ^

                     |

                     |

                     v

/[      FW/Router - External facing     ]\

\[ FW/Router/DHCP svr - Internal facing ]/

                     ^

                     |

                     |

                     V

<[             Linux workstation        ]>
```

Description?

```
The Firewall/Router/DHCP server is an all in one device. (not that it matters) The DHCP svr allocates an IP Address, subnet mask etc to to the Linix Workstation, but as far as I can tell it doesn't have a 'domain' name setting, i.e. there is no name information provided by the DHCP server.
```

Some specifics?

```
I've set the hostname in /etc/hostname and the domainname in /etc/dnsdomainname and 127.0.0.1 etc in /etc/hosts as the only entry.
```

The reason I am asking is that both my hostname and domainname is picked-up during the boot process, yet when the login prompt apears the displays that "horrible" UNKNOWN_DOMAIN string. Once logged in and typing domainname it reports that it hasn't been set?

Thanks

fractoon

----------

## hds

i think i know exactly what you mean.

you have to put your dns domanname in /etc/hosts as well like this:

```

127.0.0.1 localhost

192.168.0.2 hds.soltaus.de  hds

```

i dont know if this is a bug or what, but to me it looks that as soon as all services are started, and my workstation gets its IP from the dhcp server, then /etc/dnsdomainname is of no interest anymore.

----------

## zepto

Thanks for the suggestion, it doesn't seem to make any difference  :Sad: 

It is really strange, because during to default initialisation it actually states "Setting DNS domainname to xxxxx ...", yet it is 'forgotten' a couple of seconds later?

fractoon

----------

## hds

 *fractoon wrote:*   

> Thanks for the suggestion, it doesn't seem to make any difference 
> 
> 

 

did you restart the net after putting it in?

/etc/init.d/net.eth0 stop

/etc/init.d/net.eth0 start

----------

## zepto

Yep, definately! Did that at first, had no luck so then actually shutdown, restarted.

----------

## hds

well, i just reread your post and saw that you enterd "domainname" - this gives nothing in my bash as well, just "dnsdomainname" does.

```

bash-2.05b$ domainname

(none)

bash-2.05b$ dnsdomainname

soltaus.de

bash-2.05b$

```

btw.. domainname is in your runlevel? eg /etc/runlevels/default/@domainname?

does your /etc/resolv.conf contain it as well?

----------

## zepto

This is what I get:

dnsdomainname

dnsdomainname: Host name lookup failure

/etc/resolv.conf

nameserver 192.168.0.1

domain xxxxxx

I've tried putting domain xxxxxx on the first line (from other posts?), but 'dhcp' seems to update this file and re-sets it to that order?

----------

## hds

yes, resolv.conf is rewitten every time.

anyway, this is strange:

dnsdomainname: Host name lookup failure

your /etc/conf.d/net should look something like this:

iface_eth0="dhcp"

gateway="eth0/192.168.0.254"

is the gateway listed (well, yours of course <g>)?

otherwise, i'm running out of ideas - sorry   :Shocked: 

----------

## zepto

hds,

My /etc/conf.d/net file is completely blank.

Looks like this is where I need to 'play', but I have to go and sleep now as I'm struggling to concentrate. (yes I'm a lightweight   :Wink:  )

Thank you for spending so much time on this, it has helped a lot.

fractoon

----------

## hds

thats all you have to put in there:

```

iface_eth0="dhcp" 

gateway="eth0/192.168.0.254" 

```

good luck!

btw.. off to sleep as well, 2am over here   :Embarassed: 

----------

## zepto

Woohoo   :Very Happy:  I think I've 'cracked it'

Although hds' suggestion to modify the /etc/conf.d/net may have worked, something he said suggested before then puzzled me. So I took the drastic step of reading the manual for hosts, i.e. /etc/hosts. hds's suggestion didn't include 4 columns as it does in the gentoo installation document, his only had 3.

Here is what the manual says: *Quote:*   

> For each host a single line should be present with the following information: *Quote:*   IP_address canonical_hostname aliases  The Berkeley Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems. It augments or replaces the /etc/hosts file or host name lookup, and frees a host from relying on /etc/hosts being up to date and complete. 
> 
> In modern systems, even though the host table has been superseded by DNS, it is still widely used for: *Quote:*   bootstrapping 
> 
> Most systems have a small host table containing the name and address information for important hosts on the local network. This is useful when DNS is not running, for example during system bootup.  

 So I've edited my /etc/hosts to read  *Quote:*   

> 127.0.0.1  hostname.dnsdomainname  localhost  hostname

  and this fixed the "unknown_domain" at the login prompt.

This is different from the 2004.3 Installation Handbook (Code Listing 20) that says to have  *Quote:*   

> 127.0.0.1  tux.homenetwork  tux  localhost

  which I think is technically a valid format, but seems to make the difference between picking up the dnsdomainname or not.

fractoon

----------

## hds

interessting, thx! never heard of that sofar. it always worked here like this

```

192.168.0.2 hds.soltaus.de  hds

```

i guess you must have forgotten to edit /etc/conf.d.net, because yours was empty, and thats why the problem arised?

in the quickinstall, this is in step 1.10

anyway - just curious, could you check if it works if you edit /etc/conf.d/net accordingly and set the /etc/hosts back to your prior state? just a few lines..

----------

## zepto

Sure, the only problem is that now that the dnsdomainname is set  and found it doesn't matter if I swap them around the boot process still picks up the right domainname. I'm saying I can't put the system back into the state is was before?

Just some more information. When the domainname wasn't resolved the command hostname -v -d returned gethostname()=`'

Resolving `' ...

hostname: Unknown server error now it is returning gethostname()='hostname'

Resolving 'hostname'

Result: h_name='hostname.domainname'

Result: h_aliases='hostname'

Result: h_aliases='localhost'

Result: h_addr_list='127.0.0.1'

domainname I can recreate the first situation by changing the /etc/hosts to read 127.0.0.1  hostname.domainname hostname localhost and then 

```
hostname -F /etc/hosts
```

but I can't make it bring back the unknown_domain 'error'

This means I can't check if it makes any difference? Any suggestions?

fractoon

----------

## hds

ah, i understand. well, never mind. i was just curious why such a behaviour didnt happen to me sofar.   :Very Happy: 

anyway, great that you sorted it out.

TTYL, maybe in a different thread  :Wink: 

----------

## zepto

I'm pretty sure we will... time for me to move onto the next 'problem' area. I'm busy trying to maximise battery life on the laptop so am working through the power management guide.

till later

frac

----------

## nomorecoolnames

 *fractoon wrote:*   

> 127.0.0.1  tux.homenetwork  tux  localhost

 

Following the above format for /etc/hosts solved this problem for me as well. Thanks!

----------

## BDickson

" man dnsdomainname" has lots of good info on what is a very confusing issue with LOTS of posts.

Britt Dickson

----------

