# How to set the domain for a Gentoo box?

## Dee-ehn

I installed Gentoo linux (stage 2) and it works quite allright. Just one problem, I can't set the domain of my linux box. Although I did everything according to the guides (set up the domain in the correct file and do a rc-update) it still reports as my_gentoo.unknown_domain.

So there's my question: can anybody enlight me a little?

TIA!

----------

## adaptr

What does

```
hostname -f
```

report ?

Which file did you put the domainname in, and what rc script did you run?

----------

## Doc7

- check /etc/dnsdomainname

```
yourdomain.org

```

- check /etc/init.d/domainname status

```
* status:  started

```

- check /etc/hosts

```
...

127.0.0.1   yourhost.yourdomain.org   yourhost   localhost

...

```

----------

## adaptr

 *Doc7 wrote:*   

> - check /etc/hosts
> 
> ```
> ...
> 
> ...

 

No. Nonononononono.

NEVER alter the localhost definition - for any reason.

And even IF - never put two aliases for one IP in hosts.

```
127.0.0.1   localhost.localdomain localhost

ip.ad.dr.ess  hostname
```

----------

## Doc7

pllz give a hint why

i always used this and never had any problems.

EDIT:

man hosts:

```
...

192.168.1.10  foo.mydomain.org   foo

...
```

----------

## gabe-kai

The Gentoo Handbook says to do exactly this in the case of being an isolated machine or using nameservers for name resolution:

 *Gentoo Handbook wrote:*   

> If your system is the only system (or the nameservers handle all name resolution) a single line is sufficient. For instance, if you want to call your system tux.homenetwork:
> 
> ```
> Code Listing 19: /etc/hosts for lonely or fully integrated PCs
> 
> ...

 

I have always done this, if my hosts file reads:

```
127.0.0.1          localhost

192.169.1.4        narcissus.home.net        narcissus
```

My login prompt will be: narcissus.unknown_domain etc...

But if it reads:

```
127.0.0.1          narcissus.home.net        narcissus        localhost

192.168.1.4        narcissus.home.net        narcissus
```

Then my login prompt will be: narcissus.home.net etc...

A "right" way would be much appreciated.

----------

## adaptr

If you have DNS entries for your machine in a nameserver somewhere then that is the right way.

If you don't, then you may need to tweak the /etc/hosts entries to give you the correct responses.

And - running Gentoo on a stand-alone machine ?

How would you use Portage and everything ?

----------

## gabe-kai

 *adaptr wrote:*   

> And - running Gentoo on a stand-alone machine ?
> 
> How would you use Portage and everything ?

 

Good point, that never even dawned on me, I just remembered it from the Installation Handbook.

So my network is not using a nameserver; if I set 127.0.0.1 back to simply localhost, my system sets the domain to homenetwork when I boot, and echos narcissus.homenetwork when I type "domainname -f". However, my login prompts all look like:

```
This is narcissus.unknown_domain (Linux i686 2.6.8-r3) <time>

narcissus login:
```

How can I make it say narcissus.homenetwork again?

----------

## Doc7

i got the same thing...

if i set 127.0.0.1 in /etc/hosts to "localhost" only "domainname -f" seems right.. but my prompt shows a wrong domain and i get a message about unknown domain as i "startx".

would be nice to know how this should be done "right"

i probably will try with a DNS-server sometime, but i seriously doubt that this would change the above behaviour.

----------

## nobspangle

For a box called server on the domain domain.tld

make sure you've got

domain domain.tld

at the top of your /etc/resolv.conf

If your computer has a static IP address then you should have

```
127.0.0.1      localhost

static.ip.address     server.domain.tld   server
```

If your computer has a dynamic IP address you should have

```
127.0.0.1      server.domain.tld    server    localhost
```

/etc/dnsdomainname should contain domain.tld and /etc/hostname should contain server /etc/init.d/domainname should be added to the default runlevel.

----------

## chemical chris

i appologise in advance if i have missed anything blatentally obyouse.. however im haveing the same problem

```

bash-2.05b# cat /etc/dnsdomainname

coreline.local

```

/etc/hosts looks like this

127.0.0.1       rollright.coreline.local rollright localhost

also, when recompiling my kernel (to fix scsi) i ran into this

```

bash-2.05b# make

make[1]: `arch/i386/kernel/asm-offsets.s' is up to date.

  CHK     include/linux/compile.h

dnsdomainname: Unknown host

Kernel: arch/i386/boot/bzImage is ready

  Building modules, stage 2.

  MODPOST

bash-2.05b#

```

any help is much appriceated

----------

## chemical chris

update:

boath domainname and hostname resolve corectally when the macghene is starting... but still... at login i get newgrange.unknowen_domain

----------

## nobspangle

have you got

domain domain.tld

at the top of your resolv.conf as I said above?

----------

