# Setting a hostname

## Azerix

Hi,

I stil can't get myhostname right. I use this gentoo PC intern in network. The IP(192.168.0.14) adress is automatic from dhcpd Gentoo router. After bootting  i get this message.

 *Quote:*   

> 
> 
> Azerix.unknown_domain(Linux i686 2.6.11-gentoo-r11)
> 
> 

 

End while booting is says "* You should use /etc/conf.d/hostname and not /etc/hostname".

My hostname /etc/conf.d/hostname looks like this:

Azerix

Can any one explain me how to correct this?

greets,

azerix

----------

## bkunlimited

set /etc/dnsdomainname with correct domain

----------

## alterself.com

/etc/conf.d/hostname should have syntax of:

```
hostname=""
```

same deal with /etc/conf.d/domainname

```
dnsdomain=""
```

OR just configure your dns servers w/ correct reverse dns entries and make sure that this box is using that server as its primary dns host

----------

## Azerix

 *alterself.com wrote:*   

> /etc/conf.d/hostname should have syntax of:
> 
> ```
> hostname=""
> ```
> ...

 

After chanching those files how do i update?

rc-update add domainname default?  :Confused: 

----------

## alterself.com

i started to typea list of things to restart and source , but then i figured, ...restart  :Smile: 

if restart isnt a solution for you right now, restart domainname and hostname, log out and log in. that SHOULD work.

----------

## Azerix

Restarting is not the problem. Whe i use /etc/conf.d/domainname and the restarting he is not listening to /etc/conf.d/domainname. Het automaticly cheking in /etc/hostname and /etc/dnsdomainname. 

Now, my question is how kan i make him to chek /etc/conf.d/domainname?

----------

## alterself.com

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

----------

## Azerix

 *Azerix wrote:*   

> After chanching those files how do i update?
> 
> rc-update add domainname default? 

 

 :Confused:  I did that long time a go, but aint working , he take automaticly /etc/hostname and /etc/dnsdomainname

----------

## alterself.com

i am running the latest ~x86, and "sys-apps/baselayout-1.11.12-r4" removes the need for /etc/hostname and /etc/domainname in favor of entires in /etc/conf.d/hostname and /etc/conf.d/domainname.

my question is are you running ~x86 or just 'regular' x86?

----------

## Azerix

i dont remember wich baselayout it was. How can chek that?

----------

## johntramp

there is /etc/init.d/domainname and /etc/init.d/hostname.  I think you need to 

```
rc-update del domainname

rc-update add hostname boot
```

(or should it be default?)

----------

## Azerix

You meen i have use /etc/init.d/hostname and /etc/init.d/domainname?  :Shocked: 

----------

## statare

Hmm... have you deleted old /etc/hostname and /etc/domainname so you only have those in /etc/conf.d/ ? Thats all I did.

----------

## makenoob

 *Azerix wrote:*   

> i dont remember wich baselayout it was. How can chek that?

 

you can use

```

qpkg -I -v |grep baselayout

```

or, if you don't have gentoolkit installed

```

emerge -s baselayout

```

where the installed und actual version will be displayed (in the latter one).

HTH

marc

----------

## roymaster

try 

etcat -v baselayout

My case: [  I] 1.11.12-r4 (0)

I have 

domainname in default 

hostname in boot

hostname works, domainname not.

Try to add both services to boot runlevel. I will do it too LOL.

----------

## statare

https://forums.gentoo.org/viewtopic-t-350522.html

In short it says add your host- and domainname to /etc/hosts like this

```
127.0.0.1  localhost

192.168.0.1  hostname.domainname hostname

```

This works fine for me with hostname-command.

```
# hostname -f
```

I changed hostname and domainname when I tested and now I have a strange issue.

As I said hostname command returns right hostname and domainname but

```
# echo $HOSTNAME
```

returns an old hostname, not the new one.  :Shocked:   Very strange since hostname-command returns correct name. Any ideas?

[edit]

In /etc/profile.env the wrong hostname was set. Had to manually set the new hostname. Anyway to get your hostname and domainname right you have to edit

```
/etc/conf.d/hostname

/etc/conf.d/domainname

/etc/hosts
```

If you change hostname, as I did, check /etc/profile.env

[/edit]

----------

## Massimo B.

After the previous update, I deleted /etc/hostname and set up /etc/conf.d/hostname with the new syntax  hostname="Ma1".

But after rebooting the hostname is set to (none). With the old /etc/hostname the hostname is set correct, with the hint that I should stop using this file.

But if I do /etc/init.d/hostname restart, a lot of services are restarted with and the hostname is set correct afterwards. I don't use a domainname.

/etc/hosts has just localhost, but this worked before.

I fear every update with gentoo and etc-update  :Smile: 

----------

## randolph

To Azerix

have you found a solution to 

"You should stop using /etc/hostname and use /etc/cnf.d/hostname" and

"You should stop using /etc/domainname and use /etc/cnf.d/domainname"?

I have got the same "problem". In fact its not a real problem. It just makes me wonder.

Isn't there a file anywhere which points to the "/etc/conf.d/..." location at boot?

So if there is shouldn't it be easy to just set it right. And if not how can i stop using "/etc/..." and start using "/etc/conf.d/..."?

(these little yellow stars at boot... :Evil or Very Mad:  )

----------

## GentooMik

You will need to  delete those files   in  etc . You should backup first all the settings!

cp   /etc/hostname     <wherever backup>

cp   etc/domainname    <whereever backup>

rm    /etc/hostname

rm  /etc/domainname

it will start to use the new ones when  you configured or   copied  the contents from old files.

 *Quote:*   

> 
> 
> "You should stop using /etc/hostname and use /etc/cnf.d/hostname" and 
> 
>  "You should stop using /etc/domainname and use /etc/cnf.d/domainname"?

 

----------

## randolph

easy peasy

thx alot it works perfect  :Smile: 

just out of curiosity do you know where the system looks at boot?

----------

## Massimo B.

do I need to use both? hostname and domainname?

What should the hostname look like? I just have an entry with hostname="Ma..". This doesn't work with boot up.

----------

## GentooMik

 :Smile: 

 I am not sure for that one,  believe it  looks  into  some scripts.  Someone who knows more  in this area may be more of  a help.  It is like a  rc.something bunch of scripts. " Most likely /etc/init.d  "   :Idea:  actually if you look at it  /etc  has few  locations that seem to be initialized in  during boot.

 *Quote:*   

> 
> 
> easy peasy 
> 
>  thx alot it works perfect 
> ...

 

Yes indeed you do need  to have both of them .

 *Quote:*   

> 
> 
> do I need to use both? hostname and domainname? 
> 
>  What should the hostname look like? I just have an entry with hostname="Ma..". This doesn't work with boot up.
> ...

 

----------

## Massimo B.

ok, I got the original file by a reemerge of baselayout.

So using both /etc/conf.d/hostname and domainname works now.

----------

## meltie

Hi folks,

sorry to recycle this thread, but I still cannot convince my machine to look up my hostname and domainname in /etc/conf.d/hostname and /etc/conf.d/domainname. 

The old files, /etc/hostname and /etc/dnsdomainname, are removed and my hostname is set correctly in /etc/hosts, as suggested as solution. With the old files, it works perfectly, but I don't want to have these annoying yellow stars at boot. I've modified my runlevels several times to convice my machine that I'm serious about the change  :Smile: 

When I restart the init-scripts /etc/init.d/hostname resp. domainname, it works. Just not automatically at boot. This is a small problem, but it's annoying.

Any help appreciated.

meltie

----------

## Hunter555

I found with using the new files I had to have an /etc/nsswitch.conf to get the dnsdomainname to work. This wasn't included in the base stage3 or baselayout. Fresh install as of yesterday. Without nsswitch I couldn't even resolve my own hostname.

----------

