[CentOS] Changing hostname?
Bob Hoffman
bob at bobhoffman.com
Sun Sep 14 01:11:23 UTC 2008
> [kikinovak at calimero ~]$ cat /etc/hosts
> 127.0.0.1 calimero.local calimero localhost.localdomain
> localhost
>
> [kikinovak at calimero ~]$ hostname
> calimero.local
> [kikinovak at calimero ~]$ hostname --fqdn
> calimero.local
>
> Wouldn't this be more correct?
I would suggest not making 'local' part of your server name.
Although localhost.localdomain, in a non network setting, can work
absolutely fine, there is an issue with your email headers. The use of
locahost, local, and stuff like that is a big red flag.
I changed, in my centos 5 server, where the host name was
localhost.locadomain...
/etc/sysconfig/network
Hostname=server1.mydomain.com
(where the domain is one of my websites on the server, actually my name
server too)
Change, for sendmail to work with it, the file local-hosts-names
Add the new name to it
Server1.mydomain.com
Change /etc/hosts
First of all, leave all the original stuff and do not alter.
Underneath the original stuff, just add
<ipaddress> server1.mydomain.com
REBOOT
Then do this...
shell prompt> uname -n
server1.mydomain.com
shell prompt> hostname -s
Server1
shell prompt> hostname -d
Mydomain.com
shell prompt> hostname -f
server1.mydomain.com
shell prompt> hostname
server1.mydomain.com
All of these steps allows the mail headers, at least in sendmail, to
function properly. Other than that, unless you are in a network, or if you
are not sending mail, it is usually not a biggie if you miss some steps.
This is what I did to resolve a new hostname.
More information about the CentOS
mailing list