Setting Up Avahi-Daemon on Ubuntu for Hostname Resolution

Avahi is an open-source implementation of zero-configuration networking, also known as Bonjour or mDNS, which allows devices to automatically discover and communicate with each other on a local network without requiring any manual configuration. This guide will walk you through the process of setting up avahi-daemon on Ubuntu, enabling you to reach the hostname ubuntu.local from the host OS, Samba, and through network discovery.

Step 1: Install Avahi Packages

Open a terminal and execute the following command to install the required Avahi packages:

1
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan

Step 2: Configure Avahi Daemon

  1. Open the Avahi daemon configuration file using a text editor of your choice. In this example, we’ll use the Nano editor:
1
sudo nano /etc/avahi/avahi-daemon.conf
  1. Locate the line that begins with #domain-name and uncomment it by removing the # at the beginning of the line. Set the domain name to .local:
1
domain-name=.local
  1. Save the changes and exit the text editor (in Nano, press Ctrl + O to save and Ctrl + X to exit).

Step 3: Restart Avahi Daemon

After making the configuration changes, you’ll need to restart the Avahi daemon for the changes to take effect:

1
sudo service avahi-daemon restart

Step 4: Verify Avahi Setup

You can now verify that Avahi is working by using mdns-scan or avahi-discover:

  1. To use mdns-scan, run:
1
mdns-scan ubuntu.local
  1. To use avahi-discover, simply open it from the applications menu or run:
1
avahi-discover

You should see your ubuntu.local hostname listed, along with its IP address, indicating that Avahi is successfully resolving the hostname on the local network.

Step 5: Accessing via Samba

If you’re using Samba for file sharing, you should now be able to access your Ubuntu machine using the ubuntu.local hostname from other devices on the network.

Remember that Avahi only works within the local network. Devices outside your local network won’t be able to resolve the .local hostname.

Conclusion

By setting up avahi-daemon on Ubuntu, you’ve enabled hostname resolution via mDNS. This allows you to conveniently access your Ubuntu machine using the ubuntu.local hostname from the host OS, Samba, and through network discovery. This can be especially useful in local network environments where manual IP configuration might be cumbersome.

0%