You are not logged in.

#1 2009-06-11 03:00:06

beast123
Member
Registered: 2008-09-11
Posts: 20

Hostname changed even though rc.conf untouched

Hello

I have a curious problem. I booted my laptop up this morning and the hostname has changed. I have hostname set to "localhost" in rc.conf. But after this morning's boot, the hostname is the actual domain name. At school it was the domain name of the port I was attached to, and now at home the hostname is "new-host".  I checked my rc.conf, and hostname is still set to "localhost". If I manually change the hostname to "localhost" it stays like that until the next reboot.

The only reason I want it changed back is because I have the hostname in my PS1 for my bash prompt, and root@localhost looks better than root@dhcp-41-5.blah.edu

If you need any files posted, just let me know.

Thanks

Offline

#2 2009-06-11 10:24:13

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: Hostname changed even though rc.conf untouched

beast123,

was it working before ?

Here my 2 cents:

localhost is kind of reserved. If you look at /etc/hosts, localhost has an IP of 127.0.0.1, that is, its the loopback
address. In my opinion you should use another hostname, any name.

If you still want to use it, try putting "hostname localhost" in /etc/rc./local.

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#3 2009-06-11 11:32:03

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Hostname changed even though rc.conf untouched

Using localhost is fine. It will have changed due to the DHCP lease you got. You can change it back using the 'hostname' command, but that will only work untel next reboot and/or DHCP lease renewal.

There's a way to configure your DHCP client to ignore the hostname directive handed to you, but I'm not sure of the syntax since I configure all my hostnames via DHCP and want it to take the hostname given to it smile

Last edited by fukawi2 (2009-06-11 11:32:37)

Offline

#4 2009-06-11 13:16:26

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Hostname changed even though rc.conf untouched

Assuming you're using dhcpcd, you can get it not to do this by running it with "-C lookup-hostname -C hostname". Changing it in .etc/conf.d/dhcpcd will make it permanent.

It's also true that you should pick a "real" hostname, even if it's one you just make up.

Offline

#5 2009-06-11 22:51:34

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Hostname changed even though rc.conf untouched

ataraxia wrote:

It's also true that you should pick a "real" hostname, even if it's one you just make up.

localhost is a real hostname. Just because it's the default and common doesn't make it any less valid wink

Offline

#6 2009-06-12 13:38:28

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Hostname changed even though rc.conf untouched

fukawi2 wrote:
ataraxia wrote:

It's also true that you should pick a "real" hostname, even if it's one you just make up.

localhost is a real hostname. Just because it's the default and common doesn't make it any less valid wink

dhcpcd doesn't think it is, which is part of the trouble. It has special handling in 30-hostname, along with more obviously bogus ones.

Offline

#7 2009-06-12 23:15:26

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Hostname changed even though rc.conf untouched

fukawi2 ~  $ cat /usr/lib/dhcpcd/dhcpcd-hooks/30-hostname

Ah, I see... Well I can't say I agree with that design decision, but OK. I stand corrected, thanks for pointing that out smile

Offline

Board footer

Powered by FluxBB