How to Change the mDNS Name on a Debian or Ubuntu Server

Introduction: In the world of network management, particularly on local networks, the ability to resolve hostnames efficiently is crucial. This is where Multicast DNS (mDNS) comes into play. In this post, we’re going to walk through the steps of changing your Debian or Ubuntu server’s hostname to work seamlessly with mDNS.

Prerequisites: Before proceeding, ensure you have administrative rights on your server. Also, a basic understanding of terminal commands will be helpful.

Step 1: Changing the Hostname First, let’s check your current hostname. Open your terminal and type:

hostnamectl status

To change your hostname to something more suitable or memorable, use the following command:

sudo hostnamectl set-hostname new-hostname

Remember, your new hostname should be unique within your network and adhere to hostname naming conventions.

Step 2: Editing the Hosts File Next, we need to update the /etc/hosts file. This file maps IP addresses to hostnames. Edit it by typing:

sudo nano /etc/hosts

In this file, find the line starting with and replace the existing hostname with your new one.

Step 3: Configuring Avahi for mDNS Avahi is a daemon that facilitates network service discovery using mDNS/DNS-SD. It’s essential for the proper functioning of mDNS on your server. First, ensure Avahi is installed:

sudo apt-get install avahi-daemon

Then, edit its configuration file located at /etc/avahi/avahi-daemon.conf to reflect your new hostname.

Step 4: Restarting Services For the changes to take effect, restart the networking service and the Avahi daemon:

sudo systemctl restart networking
sudo systemctl restart avahi-daemon

Verification: To verify your hostname change, again use:

hostnamectl status

You can also use ping or avahi-browse -a to see if the new hostname is visible on the network.

Conclusion: Changing your server’s hostname and configuring it for mDNS is a straightforward process but an important one for efficient network management. Following these steps will ensure your server is easily recognizable and reachable within your local network.