# hostname won;t change from localhost

## LittleSpy

I can't seem to get my hostname to change from localhost.  When I frist start my computer it says matt-laptop as it should.  As soon as I log into gnome my hostname is changed to localhost.  I have HOSTNAME="matt-laptop" set in /etc/conf.d/hostname and I don't even have localhost in /etc/hosts just 127.0.0.1 matt-laptop.  Has anyone else had this problem or know of what might be happening?  I guess it has to be some program that is starting when X/gnome starts.

----------

## booleandomain

is the hostname script in your boot runlevel? you can check with eselect rc list boot | grep hostname. also, what version of openrc do you have?

----------

## tgR10

what about those 2 commands

```
rc-update show |grep hostname

rc-status -a|grep hostname
```

imo rc-update > eselect in this case :P

----------

## cach0rr0

possible dhcp is overwriting this? 

be a strange change to make for dhcp, but well...possible

----------

## wdsci

Just an update in case this is useful for anyone in the future: I was having the same problem.  It turned out that NetworkManager was setting the hostname to "localhost" as indicated by these lines in the system log:

```
Aug 26 11:49:03 laptop07 NetworkManager: <info>  Retrieved the following IP4 configuration from the DHCP daemon:

Aug 26 11:49:03 laptop07 NetworkManager: <info>    address 192.168.4.107

Aug 26 11:49:03 laptop07 NetworkManager: <info>    netmask 255.255.255.0

Aug 26 11:49:03 laptop07 NetworkManager: <info>    broadcast 192.168.4.255

Aug 26 11:49:03 laptop07 NetworkManager: <info>    gateway 192.168.4.1

Aug 26 11:49:03 laptop07 NetworkManager: <info>    nameserver 127.0.0.1

Aug 26 11:49:03 laptop07 NetworkManager: <info>    nameserver 208.67.222.222

Aug 26 11:49:03 laptop07 NetworkManager: <info>    nameserver 208.67.220.220

Aug 26 11:49:03 laptop07 NetworkManager: <info>    hostname 'localhost'

Aug 26 11:49:03 laptop07 dhcdbd: message_handler: message handler not found under /com/redhat/dhcp/eth0 for sub-path eth0.dbus.get.interface_mtu

Aug 26 11:49:03 laptop07 NetworkManager: <info>  Activation (eth0) Stage 5 of 5 (IP Configure Commit) scheduled...

Aug 26 11:49:03 laptop07 NetworkManager: <info>  Activation (eth0) Stage 4 of 5 (IP Configure Get) complete.

Aug 26 11:49:03 laptop07 NetworkManager: <info>  Activation (eth0) Stage 5 of 5 (IP Configure Commit) started...

Aug 26 11:49:03 laptop07 NetworkManager: <info>  Old device 'eth0' activating, won't change.

Aug 26 11:49:04 laptop07 NetworkManager: <info>  Setting hostname to 'localhost'
```

After some trial and error, I found out that I could fix the problem by commenting out two lines in the file /etc/dhcp/dhclient.conf:

```
#send host-name "localhost";

#supersede host-name "localhost";
```

Now my hostname stays as what I set it to in /etc/conf.d/net.

I got a few error messages from BIND in the system log, like this

```
Aug 26 14:22:59 laptop07 named[5847]: network unreachable resolving 'c3.nstld.com/A/IN': 2001:503:ba3e::2:30#53
```

but they don't seem to indicate a problem with the networking.

----------

