Configure a server hostname
A recognizable hostname helps identify which server sent a cPFence notification or appears in an Owl report. For cPFence v4+ on Enhance, make this change locally on the intended Ubuntu 22.04/24.04 server with root or sudo access.
1. Check the current hostname
Section titled “1. Check the current hostname”hostnamectlRecord the current hostname and keep a private copy of /etc/hosts before editing. Choose a unique name, such as server1.example.com; replace this example with your own name.
2. Set the new hostname
Section titled “2. Set the new hostname”sudo hostnamectl set-hostname server1.example.comThis changes the system hostname. Review any mail or monitoring configuration that depends on the old name.
3. Update the hosts file
Section titled “3. Update the hosts file”Open the file:
sudo nano /etc/hostsFind the existing local hostname entry, usually:
127.0.1.1 old-hostnameReplace its old hostname with your chosen name:
127.0.1.1 server1.example.comPreserve the localhost, IPv6, and unrelated entries. Save and close the editor.
4. Confirm the change
Section titled “4. Confirm the change”hostnamectlhostname -fThe static hostname should show the new name, and local hostname resolution should return the intended name. A new login refreshes a shell prompt that still displays the old name. In a Bash terminal you can also refresh the shell with:
exec bashThe hostname change itself takes effect without a reboot. Ubuntu’s server guide documents hostnamectl set-hostname for setting the name at runtime.
Troubleshooting
Section titled “Troubleshooting”- Unable to resolve host: check the spelling and matching local hostname entry in
/etc/hosts. - Name changes back: ask the server administrator to check hostname management in the cloud provisioning or network configuration.
- Need to undo: set the recorded previous hostname with the same command and restore its hosts-file entry from your private copy.
For notification delivery problems, use email and SMTP notifications.
