# How change back the hostname/domainname?

## Manymore

On my new Gentoo system I recently did a "#emerge --update --newuse --deep world" after having changed some USE flags.  This resulted in 43 config files in /etc needing to be updated.  I accepted the updated config files but now my hostname and domainname have changed:

```
gary@localhost ~ $ hostname

localhost

```

```
gary@localhost ~ $ domainname

(none)

```

I followed the Gentoo Linux/x86 Handbook exactly when I did the installation and set the hostname to "tux" and domainname to "homenetwork".  To change back the hostname/domainname do I simply follow the same procedure as follows?

```
# echo tux > /etc/hostname
```

```
# echo homenetwork > /etc/dnsdomainname
```

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

----------

## adaptr

The locations where you set these have changed - it clearly told you so when you updated your configs.

Use /etc/conf.d/hostname and /domainname in the future.

----------

## Manymore

adaptr,

Thank you for the reply.

After I make the changes do I need to do the rc-update?

----------

## Manymore

I edited /etc/conf.d/hostname and the change worked:

```
gary@tux / $ hostname

tux

```

I then edited /etc/conf.d/domainname, did a "# rc-update add domainname default" and got the following:

```
tux / # rc-update add domainname default

 * domainname already installed in runlevel default; skipping

```

However, the domainname still comes up as "none":

```
gary@tux ~ $ domainname

(none)

```

My /etc/conf.d/domainname looks as follows:

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

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

# If you wish to always override DHCP/whatever, set this to 1.

OVERRIDE=1

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

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

#

DNSDOMAIN="homenetwork"

# This only set what /bin/hostname returns.  If you need to setup NIS, meaning

# what /bin/domainname returns, please see:

#

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

#

#NISDOMAIN=""

```

Maybe I haven't edited the file correctly. Do I need to change other config files?

I would appreciate any help.  Thanks.

----------

## adaptr

The domainname command does not echo your DNS domain.

Use

```
hostname --fqdn
```

for that.

----------

## Manymore

My domainname comes up as "localhost".

```
gary@tux ~ $ hostname --fqdn

localhost

```

I have already edited /etc/conf.d/domainname to change my domainname to "homenetwork" as in my post above but the domainname is "localhost".

How can I change my domainname to "homenetwork"?

----------

## Delphi

I am having this exact same problem. I have set my domainname in /etc/conf.d/domainname and added domainname to the default runlevel.

When I boot my computer to linux, it displays that it is changing my domainname. My network is then brought up by dhcp, and then my log in looks like:

Delphi.(none) (i686 Linux blah blah blah)

Instead of what I chose or what is listed in /etc/resolv.conf (which is furthermore different from what I have listed in /etc/conf.d/domainname)

----------

## PaulBredbury

 *Delphi wrote:*   

> Delphi.(none) (i686 Linux blah blah blah)

 

This is not actually a problem, even though it looks weird. The "(none)" is caused by NIS rather than DNS being used to determine the "domain name".

----------

## Delphi

Is there any way that I can work around this and get it to display what I would like?

----------

## lghman

 *Delphi wrote:*   

> Is there any way that I can work around this and get it to display what I would like?

 

Yes there is. Follow this article here.  http://gentoo-wiki.com/TIP_Setup_Your_FQDN

--sonik

----------

## PaulBredbury

 *sonikntails wrote:*   

> Yes there is. Follow this article here.  http://gentoo-wiki.com/TIP_Setup_Your_FQDN

 

That solves the cosmetic "(None)", but creates its own problems with programs that expect to be contacted by "localhost" rather than "your.domainname.com". So I recommend that you leave /etc/hosts as it should be, i.e. beginning with:

```
127.0.0.1       localhost blah...
```

----------

## lghman

 *PaulBredbury wrote:*   

>  *sonikntails wrote:*   Yes there is. Follow this article here.  http://gentoo-wiki.com/TIP_Setup_Your_FQDN 
> 
> That solves the cosmetic "(None)", but creates its own problems with programs that expect to be contacted by "localhost" rather than "your.domainname.com". So I recommend that you leave /etc/hosts as it should be, i.e. beginning with:
> 
> ```
> ...

 

I have yet to use a program that bitched to me about being able to find localhost.  Which I would assume is due to the fact that you dont take the localhost out of that line, just move it backward.  

--sonik

----------

## PaulBredbury

 *sonikntails wrote:*   

> I have yet to use a program that bitched to me about being able to find localhost.  Which I would assume is due to the fact that you dont take the localhost out of that line, just move it backward.

 

It's true that there's not very many programs that rely on 127.0.0.1 being localhost - it's not a big problem.  However, moving "localhost" back in the list in /etc/hosts does not help - either 127.0.0.1 is "localhost" or it's not - "your.company.com" is not "localhost".

Since the Linux standard for /etc/hosts seems to be to have "localhost" first in the list, I'm reluctant to change that, just to solve the cosmetic "(None)".  The proper solution I think should be to calculate the "(None)" string more sensibly (although I lack the skill currently to come up with a patch for that).

Here's a newsgroup  thread where this exact same problem is discussed.

----------

## lghman

 *PaulBredbury wrote:*   

>  *sonikntails wrote:*   I have yet to use a program that bitched to me about being able to find localhost.  Which I would assume is due to the fact that you dont take the localhost out of that line, just move it backward. 
> 
> It's true that there's not very many programs that rely on 127.0.0.1 being localhost - it's not a big problem.  However, moving "localhost" back in the list in /etc/hosts does not help - either 127.0.0.1 is "localhost" or it's not - "your.company.com" is not "localhost".
> 
> Since the Linux standard for /etc/hosts seems to be to have "localhost" first in the list, I'm reluctant to change that, just to solve the cosmetic "(None)".  The proper solution I think should be to calculate the "(None)" string more sensibly (although I lack the skill currently to come up with a patch for that).
> ...

 

I agree with you completely, and my laptop isnt set up that way as I use that box mostly for business (which in my case is consulting).  My home box is set up different, but then again I actually own a domain that goes to my network.  This could also be why I havent seen any of those problems.  I dont believe it would cause enough issues though for the "common" user not doing anything hella fancy .... then again I could be wrong too.   :Smile: 

--sonik

----------

## daywalkerNT

What about this line from the HandBook (Section # :Cool: 

/etc/conf.d/net

dhcp_eth0="nodns nontp nonis"

I'm going to try it too to see what happens.

----------

## IronWolve

Thanks for the thread, also had this issue. Just added 

127.0.0.1  sexy.dyn-dns-domain sexy localhost

and that fixed it.  Sounds like a bug though if dnsdomain isnt working on login.

----------

