I know that changing my DNS records to point to my IP address is how I get my server accessible, so that a request for myDomain.com points to my IP address. With that said, why does a machine need to have a hostname? Why does it care what it's hostname is if the DNS system will route requests to it anyway?
Also, if I'm running a simple personal webserver, is it okay to just leave my hostname "local"? Should I change it to the FQDN?
EDIT
I just found an excellent answer on another SO site here: https://unix.stackexchange.com/a/50529/32623
Best Answer
Best practices dictate that you set your hostname to something meaningful - usually the FQDN of the server (if the system has a role where it's associated with multiple FQDNs -- like a shared web hosting server -- you would typically set a hostname like
webhosting001.provider.com
for its local hostname, with a corresponding DNS entry).This is done for a number of reasons, but there are two main ones:
As Nathan mentioned, some programs use the hostname for various purposes.
Having an unresolvable hostname can cause unpredictable behavior.
When you are logged in to a machine its local hostname provides a convenient way to identify it.
This is a good way to sanity check yourself before rebooting a host.
It is also important in an environment with multiple machines -- 100 systems all called
local
will get very confusing, but 100 machines namedweb##
,mail##
, etc. (or some other naming scheme you select and stick to) makes them easy to tell apart.