[CentOS] Re: hostname setting

Scott Silva ssilva at sgvwater.com
Wed Nov 29 22:02:06 UTC 2006

MrKiwi spake the following on 11/29/2006 1:34 PM:
> Can someone with far more knowledge than me help here?
> I have a co-worker with a question;
> "
> Where should i set the server's hostname?
> There seems to be multiple places and i don't understand the differences.
> 1. # hostname mailserver.mydomain.com
> 2. # echo " mailserver mailserver.mydomain.com">>/etc/hosts
> 3. # vi /etc/sysconfig/network, add "HOSTNAME=mailserver.mydomain.com"
> So far i think i understand that postfix likes to see the hostname in
> the hosts file, but things i have read imply that postfix is pretty
> clever at working it out from multiple places.
> Apache also seems to be clever, but the conf file recommends that you
> hard code the server name into the config. If you don't, where does
> apache look?
> If you set the hostname during an install, where is that written?
> If i use method 1 above ("hostname mailserver.mydomain.com") i seem to
> have to do that at every boot (or script it of course) whereas the edit
> to /etc/hosts or /etc/sysconfig/network would survive restarts.
> I have read the information in "man hostname" and understand that
> "hostname -f" gets its info from the hosts file, but where does the
> function "gethostname" get its info from?
> Finally - which method do you all use to set you hostname?
> "
> Thanks all,
> MrKiwi
I have my hostname in both /etc/sysconfig/network and /etc/hosts.


MailScanner is like deodorant...
You hope everybody uses it, and
you notice quickly if they don't!!!!

More information about the CentOS mailing list