/etc/sysconfig/network file is source from which the startup scripts take the arguments for 'hostname' command. And this should be just the machine name, not fully qualified. The domain part is usually defined in the /etc/resolv.conf file.
Assuming the fully qualified host name is 'lemon.example.com' ('www' doesn't look like a good host name to me), then:
- /etc/sysconfig/network:
HOSTNAME=lemon
- /etc/resolv.conf (along right 'nameserver' entires):
search example.com
- /etc/hosts (should not be needed if DNS works properly):
XXX.XXX.XXX.XXX lemon.example.com lemon
If everything is properly configured, then hostname
command will return "lemon" and hostname -f
will return "lemon.example.com".
In your case it would seem the hostname is 'www' in domain 'myserver.com'… I don't think that is exactly what you want. 'www' may be an alias (DNS CNAME)… if you want it in your /etc/hosts file, then just append it to the line with your IP:
XXX.XXX.XXX.XXX lemon.example.com lemon www.myserver.com
The settings from /etc/sysconfig/network will be applied after network is restarted. You may set the hostname immediately with the hostname
command. /etc/hosts and /etc/resolv.conf changes are active immediately (except for applications that keep old data cached).