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:
|
|
Step 2: Configure Avahi Daemon
- Open the Avahi daemon configuration file using a text editor of your choice. In this example, we’ll use the Nano editor:
|
|
- 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
:
|
|
- Save the changes and exit the text editor (in Nano, press
Ctrl + O
to save andCtrl + 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:
|
|
Step 4: Verify Avahi Setup
You can now verify that Avahi is working by using mdns-scan
or avahi-discover
:
- To use
mdns-scan
, run:
|
|
- To use
avahi-discover
, simply open it from the applications menu or run:
|
|
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.