View Full Version : Setting the hostname on startup
PompeyBlue
2004-07-07, 02:05 AM CDT
Every time FC2 starts up it complains because my hostname has changed (I'm on dhcp and given a different IP each time)
It complains about GNOME not being happy, and maybe not working.
I know I can set the name using the hostname command, but whenever I reboot, I'm given a different name again. How can I set my host name to localhost.localdomain and have it stay that way every time I boot up ?
ghaefb
2004-07-07, 02:23 AM CDT
Run: system-config-network -> DNS -> Hostname to change your hostname :)
PompeyBlue
2004-07-07, 02:42 AM CDT
Hello,
Thanks for the advice, and I had it set up like that, but still when I log in, GNOME complains. If I open up a terminal, and just type 'set' then I get the following:
HOSTNAME=cpc4-*-3-0-cust2.cable.ntl.com
even though in system-config-network -> DNS -> Hostname, I've set it to localhost.localdomain
ghaefb
2004-07-07, 03:02 AM CDT
What about Edit -> Ethernet Device od you have "Automatically obtain DNS information from provider" checked?
just a guess..
fjleal
2004-07-07, 03:04 AM CDT
Open /etc/hosts (as root, or "su") and add your machine name to it, like in "127.0.0.1 <machine-name> localhost.localdomain localhost".
And never trust a GUI. ;)
PompeyBlue
2004-07-07, 01:50 PM CDT
Hello,
I'm now, very, very confused.
If I look at /etc/hosts, I can see the following:
127.0.0.1 localhost.localdomain localhost
When I boot up my machine decides it's called "cpc4-*-3-0-cust2.cable.ntl.com"
If I go to "system-config-network -> DNS -> Hostname " there is nothing there, so I put in localhost. Shutting down and rebooting makes it decide it's called "cpc4-*-3-0-cust2.cable.ntl.com" again.
If I go to "Edit -> Ethernet Device" I do have "Automatically obtain DNS information from provider" checked. If I then put in a hostname there (localhost.localdomain) it seems to accept it and boots up but now decides that it's called localhostlocaldomain (no .) and so GNOME still complains when I log in. If I put in "localhost" there it still decides it's called "cpc4-*-3-0-cust2.cable.ntl.com". If I put in 127.0.0.1 there, then it fails to start sendmail on booting up.
I must be doing something very stupid. I'm tempted to let it decide it's called "cpc4-*-3-0-cust2.cable.ntl.com" and just have that in /etc/hosts. Of course, that could get problematic if I ever wanted to use that "ip address" to message someone. And as I've said before, I always want things to be perfect.
Strangely though, if I su and then use "hostname" I can set it to what ever I want, and it seems to respect it. It's just that on reboot it changes it's mind. There HAS to be some .conf somewhere which stores what my local host name is, and uses that at startup ?
deuch
2004-07-07, 02:29 PM CDT
try to put a name for the machine ... not localhost : for example : myLinuxPc.
deuch
ghaefb
2004-07-07, 04:14 PM CDT
Maybe "Automatically obtain DNS information from provider" is the cause of this cpc4-*-3-0-cust2.cable.ntl.com hostname. Uncheck this option..
PompeyBlue
2004-07-07, 05:10 PM CDT
Guys,
I really appreciate all of the help I'm getting here, I'd be kind of screwed without it ^_^ I'm probably talking a load of rubbish too, as I'm almost brand new newbie.
but, wouldn't unticking "Automatically obtain DNS information from provider" mean that if the provider ever changed DNS server IP, then my system wouldn't automatically pick that up ? Or do you think that this is actually resolving my own IP to an address ?
I notice that DNS servers have been filled in automatically. I suppose I can give it a whirl and see what happens ^_^
PompeyBlue
2004-07-08, 01:18 AM CDT
Ok, just a quick addendum.
1. I guess that "Automatically obtain DNS information from provider" means, set my host name to whatever it resolves to
2. If I set the host manually there to "LocalHost" everything boots up fine. If I set it to "localhost" it gets the hump and starts resolving back to "cpc4-*-3-0-cust2.cable.ntl.com"
I can understand why people who understand this system get paid such vast sums of cash, god it's perplexing!
thanks guys though, everything is happy again.
JonR
2004-07-08, 01:22 AM CDT
Is this any help?
http://www.fedoraforum.org/forum/showthread.php?t=1889
PompeyBlue
2004-07-08, 02:00 PM CDT
I've just checked and it appears one of my posts went missing. I also mentioned that I have to uncheck "automatically obtain DNS information from provider" to get things to work!
PompeyBlue
2004-07-08, 02:03 PM CDT
Is this any help?
http://www.fedoraforum.org/forum/showthread.php?t=1889
Yes,
This is quite helpful. My problem is though, I'm on a dynamic IP address from my ISP and so my hostname changes every few days. This means that I'd have to constantly update my /etc/hosts file.
Hence I've gone for the Fix my hostname to LocalHost option, which now works fine!
fjleal
2004-07-08, 03:40 PM CDT
You can keep the "automatically obtain DNS information..." setting checked. Simply add your machine name to /etc/hosts, and it won't change. Your DHCP client will only get you an IP and the DNS settings, not the machine name.
PompeyBlue
2004-07-08, 04:11 PM CDT
Ok, I'll give it a whirl. As a complete aside, have you any idea why "LocalHost" works but "localhost" does not ? Crazy!
JonR
2004-07-08, 04:22 PM CDT
case sensitivity?
PompeyBlue
2004-07-09, 05:23 AM CDT
Ok,
Switching on DNS again is OK
The gotcha is that it must be LocalHost, not locahost. Quite why or how, I don't know. As JonR said, there's something case sensitive, I guess I'll never find out what though ^_^
Somebody is using a stricmp instead of a strcmp somewhere though!
cray
2004-07-09, 08:25 AM CDT
vi /etc/sysconfig/network
set the below:
NETWORKING=yes
HOSTNAME=localhost.localdomain
HOSTNAME is where RH based Linux reads the hostname from during boot. You can set it to any hostname you want.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.