1) running 'hostname' returns the short name (i.e. myhost)
2) running 'hostname -f' returns the FQDN (i.e. myhost.prod.example.com)
3) running 'hostname -d' returns the domain name (i.e prod.example.com)
After experimenting a bit and also finding this helpful Server Fault post, here's what we did to achieve this (we did it via Chef recipes, but it amounts to the same thing):
- make sure we have the short name in /etc/hostname:
(also run 'hostname myhost' at the command line)
- make sure we have the FQDN as the first entry associated with the IP of the server in /etc/hosts:
- make sure we have the domain name set up as the search domain in /etc/resolv.conf:
Reboot the box when you're done to make sure all of this survives reboots.
No comments:
Post a Comment