FreeBSD: How to rename your server

When you install FreeBSD, you may not think about the server name. Later, you ask yourself: Do I need to reinstall? How do I rename the server?  The answer is no. You can rename the server with a few simple steps, and you can do it safely.

First, check the current name by running:
hostname

This shows what the system is using right now. In order to change the name, please follow the steps below.

Steps to correctly rename a FreeBSD server
Temporary change (until reboot):
hostname newname.example.com

This updates the hostname for the current session. Here is how to confirm by using the uname command.

What uname Does

The uname command shows system information. By default, it prints the kernel name. With options, it can show more details like the hostname (-n), the operating system (-o), or the hardware (-m). For example:

uname -n

This displays the current hostname of your FreeBSD server.

Permanent change (survives reboot):

Edit /etc/rc.conf and set:

hostname="newname.example.com"

This line tells FreeBSD to set the hostname every time the system starts.
In addition, you may want to update /etc/hosts.
This step is optional, but it helps with local name resolution. For example:

127.0.0.1   localhost newname
192.168.1.10 newname.example.com newname

This is not what sets the hostname; it just ensures that name resolution works.
Think of it as two layers:

    • Identity → set in /etc/rc.conf (hostname=).
    • Resolution → mapped in /etc/hosts.

Changing only /etc/hosts won’t rename the box; it just changes how names resolve. The true rename is in rc.conf.

Once all the changes are done, it’s time to reboot

reboot
Verification
hostname
uname -n

Now your server shows the new name.

In short, remember this: /etc/rc.conf sets the identity, while /etc/hosts only helps with resolution. By following these steps, you can rename your FreeBSD server without reinstalling, and you can do it safely and quickly.

Well, I hope this saved you from rebuilding the server. If you like this, you can check some of my other posts like this one on setting up ZFS (Zettabyte File System)