mDNS - Multicast Domain Name System ==================================== .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is mDNS?** mDNS stands for Multicast Domain Name System. It’s a protocol that allows devices on the same local network to discover each other and resolve hostnames (like printer.local) to IP addresses without needing a central DNS server. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is mDNS useful?** Without mDNS, devices would need to be manually configured with IP addresses or rely on a DNS server to resolve names. mDNS makes it easy for devices to automatically find and connect to each other on local networks—especially useful in home or small office environments. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works (in simple steps):** * Device wants to find another device – For example, your laptop wants to find a printer named printer.local. * Sends a multicast query – It sends a request to all devices on the local network asking, “Who is printer.local?” * Device responds – The printer replies with its IP address. * Connection is made – Your laptop now knows how to reach the printer and can start printing. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is mDNS used?** * Home networks – For discovering smart devices like printers, speakers, or smart TVs. * Small offices – Where devices need to find each other without a dedicated DNS server. * IoT environments – Where many small devices need to communicate easily. * Apple’s Bonjour – A well-known implementation of mDNS used in macOS and iOS for device discovery. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does this protocol belong to?** * It provides services directly to applications and users. * It uses standard DNS message formats over multicast UDP. * It enables name resolution and service discovery, which are high-level functions typical of Layer 7. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is mDNS Windows specific?** * No. * mDNS is not Windows specific. * It is widely used on various operating systems including macOS, Linux, and Windows. * macOS and Linux often use mDNS for zero-configuration networking (e.g., Bonjour). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is mDNS Linux specific?** * No. * mDNS is not Linux specific. * It is supported across multiple platforms like Windows, macOS, and Linux. * Linux uses implementations like Avahi to support mDNS. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Transport Protocol is used by mDNS?** mDNS uses UDP (User Datagram Protocol). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Port is used by mDNS?** * UDP port 5353. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is mDNS using Client-Server model?** * No. * mDNS uses a peer-to-peer model. * Devices multicast queries on the local network. * Any device can respond directly without a centralized server. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`mDNS Version&RFC Details ` * :ref:`mDNS Basic Setup on Ubuntu using IPv4 ` * :ref:`mDNS Basic Setup on Ubuntu using IPv6 ` * :ref:`mDNS Protocol Packet Details ` * :ref:`mDNS Usecases ` * :ref:`mDNS Basic Features ` * :ref:`mDNS Feature : Local Name Resolution ` * :ref:`mDNS Feature : Zero Configuration ` * :ref:`mDNS Feature : Multicast Communication ` * :ref:`mDNS Feature : .local Domain Usage ` * :ref:`mDNS Feature : Service Discovery (via DNS-SD) ` * :ref:`mDNS Feature : Cross-Platform Support ` * :ref:`mDNS Feature : No Central Server Needed ` * :ref:`mDNS Feature : Automatic Conflict Resolution ` * :ref:`mDNS Feature : Lightweight Protocol ` * :ref:`Reference links ` .. _mDNS_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _mDNS_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _mDNS_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _mDNS_step5: .. tab-set:: .. tab-item:: mDNS Version&RFC Details .. csv-table:: :file: ./mDNS/mDNS_Version_and_RFC_Details.csv :widths: 10,10,10,30 :header-rows: 1 .. _mDNS_step19: .. tab-set:: .. tab-item:: Test Case 1: Hostname Resolution via mDNS **verify that the hostname of Laptop A can be resolved by Laptop B using mDNS.** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-3 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-4 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-3 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up * Step-4 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-5 : Test hostname resolution From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping laptopA.local PING laptopA.local (192.168.1.10) 56(84) bytes of data. 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=2.77 ms 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=1.05 ms 64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=1.08 ms 64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=0.985 ms 64 bytes from 192.168.1.10: icmp_seq=5 ttl=64 time=1.62 ms 64 bytes from 192.168.1.10: icmp_seq=6 ttl=64 time=1.23 ms 64 bytes from 192.168.1.10: icmp_seq=7 ttl=64 time=1.59 ms 64 bytes from 192.168.1.10: icmp_seq=8 ttl=64 time=1.99 ms 64 bytes from 192.168.1.10: icmp_seq=9 ttl=64 time=0.967 ms 64 bytes from 192.168.1.10: icmp_seq=10 ttl=64 time=8.22 ms 64 bytes from 192.168.1.10: icmp_seq=11 ttl=64 time=1.43 ms 64 bytes from 192.168.1.10: icmp_seq=12 ttl=64 time=1.16 ms 64 bytes from 192.168.1.10: icmp_seq=13 ttl=64 time=1.40 ms 64 bytes from 192.168.1.10: icmp_seq=14 ttl=64 time=1.18 ms 64 bytes from 192.168.1.10: icmp_seq=15 ttl=64 time=1.18 ms 64 bytes from 192.168.1.10: icmp_seq=16 ttl=64 time=8.70 ms 64 bytes from 192.168.1.10: icmp_seq=17 ttl=64 time=0.967 ms 64 bytes from 192.168.1.10: icmp_seq=18 ttl=64 time=1.56 ms 64 bytes from 192.168.1.10: icmp_seq=19 ttl=64 time=1.21 ms 64 bytes from 192.168.1.10: icmp_seq=20 ttl=64 time=0.763 ms 64 bytes from 192.168.1.10: icmp_seq=21 ttl=64 time=1.52 ms 64 bytes from 192.168.1.10: icmp_seq=22 ttl=64 time=1.40 ms 64 bytes from 192.168.1.10: icmp_seq=23 ttl=64 time=1.18 ms 64 bytes from 192.168.1.10: icmp_seq=24 ttl=64 time=1.17 ms --- laptopA.local ping statistics --- 23 packets transmitted, 23 received, 0% packet loss, time 22022ms rtt min/avg/max/mdev = 0.763/1.898/8.704/2.062 ms * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 2: IP to Hostname Resolution **verify that avahi-resolve can resolve a hostname to its corresponding IP address.** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up * Step-5 : Test hostname resolution From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping laptopA.local PING laptopA.local (192.168.1.10) 56(84) bytes of data. 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=2.77 ms 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=1.05 ms 64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=1.08 ms 64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=0.985 ms 64 bytes from 192.168.1.10: icmp_seq=5 ttl=64 time=1.62 ms 64 bytes from 192.168.1.10: icmp_seq=6 ttl=64 time=1.23 ms 64 bytes from 192.168.1.10: icmp_seq=7 ttl=64 time=1.59 ms 64 bytes from 192.168.1.10: icmp_seq=8 ttl=64 time=1.99 ms 64 bytes from 192.168.1.10: icmp_seq=9 ttl=64 time=0.967 ms 64 bytes from 192.168.1.10: icmp_seq=10 ttl=64 time=8.22 ms 64 bytes from 192.168.1.10: icmp_seq=11 ttl=64 time=1.43 ms 64 bytes from 192.168.1.10: icmp_seq=12 ttl=64 time=1.16 ms 64 bytes from 192.168.1.10: icmp_seq=13 ttl=64 time=1.40 ms 64 bytes from 192.168.1.10: icmp_seq=14 ttl=64 time=1.18 ms 64 bytes from 192.168.1.10: icmp_seq=15 ttl=64 time=1.18 ms 64 bytes from 192.168.1.10: icmp_seq=16 ttl=64 time=8.70 ms 64 bytes from 192.168.1.10: icmp_seq=17 ttl=64 time=0.967 ms 64 bytes from 192.168.1.10: icmp_seq=18 ttl=64 time=1.56 ms 64 bytes from 192.168.1.10: icmp_seq=19 ttl=64 time=1.21 ms 64 bytes from 192.168.1.10: icmp_seq=20 ttl=64 time=0.763 ms 64 bytes from 192.168.1.10: icmp_seq=21 ttl=64 time=1.52 ms 64 bytes from 192.168.1.10: icmp_seq=22 ttl=64 time=1.40 ms 64 bytes from 192.168.1.10: icmp_seq=23 ttl=64 time=1.18 ms 64 bytes from 192.168.1.10: icmp_seq=24 ttl=64 time=1.17 ms --- laptopA.local ping statistics --- 23 packets transmitted, 23 received, 0% packet loss, time 22022ms rtt min/avg/max/mdev = 0.763/1.898/8.704/2.062 ms * Step-6 : Resolve hostname to IP with avahi-resolve .. code-block:: shell test:~$ avahi-resolve -n laptopA.local laptopA.local 192.168.1.10 * Step-7 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 3: Reverse Hostname Resolution **verify that avahi-resolve can perform a reverse resolution of an IP address to a hostname via mDNS.** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up * Step-5 : Test hostname resolution From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping laptopA.local PING laptopA.local (192.168.1.10) 56(84) bytes of data. 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=1.39 ms 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=1.00 ms 64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=1.45 ms 64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=1.33 ms --- laptopA.local ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3005ms rtt min/avg/max/mdev = 1.000/1.290/1.490/0.173 ms * Step-6 : Perform reverse hostname resolution From Laptop B, use avahi-resolve to reverse-resolve Laptop A's IP address (e.g., 192.168.1.10) into its hostname. .. code-block:: shell test:~$ avahi-resolve -a 192.168.1.10 192.168.1.10 laptopA.local * Step-7 : Wireshark Capture :download:`Download wireshark capture ` .. note:: * Analyze the network traffic to confirm that mDNS query from Laptop B for reverse resolution,mDNS response from Laptop A with hostname and ICMP packets were sent and received as part of the ping test. .. tab-item:: Test Case 4: Service Discovery with avahi-browse **verify that avahi-browse -a can list the services announced via mDNS** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA * Step-6 : Publish a service * Use avahi-publish to announce a fake SSH service on the network. This command should be run after the avahi-browse -a command is given on the client device. .. code-block:: shell test:~$ sudo avahi-publish -s testssh _ssh._tcp 22 **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up * Step-5 : Discover services Run the avahi-browse -a command from Laptop B to discover all services on the network. .. code-block:: shell test:~$ avahi-browse -a * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. note:: * mDNS query for _ssh._tcp.local, mDNS response from Laptop A advertising testssh .. tab-item:: Test Case 5: Hostname Unavailability on Avahi Stop **verify that when the Avahi daemon is stopped, the device can no longer announce its hostname on the network** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.100 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.105 up * Step-5 : Test hostname resolution From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping laptopA.local Stop the Avahi daemon on the server-From Laptop A, stop the Avahi daemon service. .. code-block:: shell test:~$ sudo systemctl disable avahi-daemon test:~$ sudo systemctl stop avahi-daemon From Laptop B, try to ping the server's hostname again. .. code-block:: shell test:~$ ping laptopA.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 6: mDNS over Ethernet **verify the mDNS connection works correctly over an Ethernet cable between two devices** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Test hostname resolution From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 7: avahi-resolve and avahi-browse over Ethernet **verify that avahi-resolve and avahi-browse work correctly over an Ethernet connection** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and publish a service .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up Publish a fake SSH service on the network for discovery. test:~$ avahi-publish -s testssh _ssh._tcp 22 * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Test hostname resolution and reverse resolution From Laptop B, ping the server's hostname and then use avahi-resolve to get the hostname from the server's IP. .. code-block:: shell test:~$ ping shilpa.local test:~$ avahi-resolve -a 192.168.1.15 * Step-7 : Discover services Run avahi-browse -a from laptopB to list all discovered services on the network .. code-block:: shell test:~$ avahi-browse -a * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 8: Concurrent mDNS Requests **verify that mDNS can handle multiple concurrent hostname resolution requests** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Perform concurrent requests Open multiple terminals on Laptop B and run the ping command to Laptop A's hostname in each terminal concurrently. .. code-block:: shell test:~$ ping shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. note:: * Multiple ICMP (ping) packets were found, indicating successful communication. .. tab-item:: Test Case 9: Latency Measurement **verify that a device can measure the network latency to another mDNS-enabled device** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Measure latency From Laptop B, use the time ping command to measure the latency to laptopA's hostname. .. code-block:: shell test:~$ time ping shilpa.local -c 1 PING shilpa.local (192.168.1.10) 56(84) bytes of data. 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=2.66 ms --- shilpa.local ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 2.660/2.660/2.660/0.000 ms real 0m0.018s user 0m0.000s sys 0m0.014s * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 10: Service Removal on SSH Stop **verify that stopping an announced service will remove its entry from mDNS discovery** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and publish a service .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up Publish a fake SSH service on the network for discovery. This command will be stopped later. test:~$ avahi-publish -s testssh _ssh._tcp 22 established under name 'testssh' .. * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Discover services * From Laptop B, run avahi-browse -a to list all discovered services. .. code-block:: shell test:~$ avahi-browse -a +enp0s8 IPV4 testssh SSH Remote Terminal local * Stop the service on the server From laptopA, stop the avahi-publish command by pressing Ctrl+C. * Re-discover services Run avahi-browse -a again on laptopB to verify the service has been removed from the list. test:~$ avahi-browse -a +enp0s8 IPV4 testssh SSH Remote Terminal local -enp0s8 IPV4 testssh SSH Remote Terminal local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 11: Multiple Service Advertisement **verify that a single host can advertise multiple mDNS services simultaneously** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and publish multiple services .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up Publish two services, one for SSH and one for HTTP on 2 different terminals, on the same host. .. code-block:: shell test:~$ avahi-publish-service "MySSH" _ssh._tcp 22 test:~$ avahi-publish-service "MyWebServer" _http._tcp 80 * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Discover services * From Laptop B, run avahi-browse -a -r to list all discovered services and their records. .. code-block:: shell test:~$ avahi-browse -a -r + enp0s8 IPV4 myssh SSH Remote Terminal local = enp0s8 IPV4 myssh SSH Remote Terminal local hostname = [laptopA.local] address = [192.168.1.10] port = [22] txt = [] + enp0s8 IPV4 myweb Web Site local = enp0s8 IPV4 myweb Web Site local hostname = [laptopA.local] address = [192.168.1.10] port = [80] txt = [] * Stop services on the server From laptopA, stop the avahi-publish commands by pressing Ctrl+C in both terminals. * Observe output The avahi-browse output on DUT2 should show the advertised services appearing and then being removed, .. code-block:: shell test:~$ avahi-browse -a -r + enp0s8 IPV4 myssh SSH Remote Terminal local = enp0s8 IPV4 myssh SSH Remote Terminal local hostname = [laptopA.local] address = [192.168.1.10] port = [22] txt = [] + enp0s8 IPV4 myweb Web Site local = enp0s8 IPV4 myweb Web Site local hostname = [laptopA.local] address = [192.168.1.10] port = [80] txt = [] - enp0s8 IPV4 myweb Web Site local - enp0s8 IPV4 myssh SSH Remote Terminal local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 12: mDNS Record Expiry **verify that an mDNS service record will expire and be removed from discovery after a certain period of time** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and publish a service .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up Publish a fake service with a default TTL (Time-To-Live). .. code-block:: shell test:~$ avahi-publish -s "TestService" _http._tcp 8080 * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname laptopA **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Verification and Results * Discover service and stop it From laptopB, run avahi-browse to discover the service. Then, on laptopA, stop the avahi-publish command by pressing Ctrl+C. * Wait and check for removal Wait for a few minutes (e.g., 120 seconds) and then check if the service is still visible in the discovery list on laptopB. * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 13: mDNS Reannouncement **verify that a device can reannounce its mDNS services after a network interruption** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address and publish a service .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.15 up Publish a fake SSH service on the network for discovery. .. code-block:: shell test:~$ avahi-publish -s testssh _ssh._tcp 22 * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.12 up * Step-5 : Verification and Results * Discover service and simulate interruption From laptopB, verify that the SSH service is discoverable by using avahi-browse -a. Simulate a network interruption on laptopA by stopping the service and restarting it after some time. * Verify reannouncement After the service is restarted, verify that laptopB can once again discover the service. * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 14: Goodbye Packet on Avahi Stop **verify that gracefully stopping the Avahi daemon sends an mDNS "Goodbye" packet, which informs other devices to remove the host from their cache** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns Enable publishing of hostname and addresses in Avahi's configuration. .. code-block:: shell test:~$ sudo nano /etc/avahi/avahi-daemon.conf publish-workstation=yes publish-addresses=yes * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-5 : Set the hostname of the server to vm1 .. code-block:: shell test:~$ sudo hostnamectl set-hostname vm1 **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns Enable publishing of hostname and addresses in Avahi's configuration. .. code-block:: shell test:~$ sudo nano /etc/avahi/avahi-daemon.conf publish-workstation=yes publish-addresses=yes * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.11 up * Step-5 : Verification and Results * Initial connectivity check From VM1, ping VM2's mDNS hostname (vm2.local) to ensure initial discovery and resolution. .. code-block:: shell test:~$ ping vm2.local * Stop the Avahi service On VM2, gracefully stop the Avahi daemon. .. code-block:: shell test:~$ sudo systemctl stop avahi-daemon * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. note:: * On the network, observe the Wireshark capture for mDNS and ip.src == 192.168.1.11. * Look for a series of response packets (where the QR bit is 1) originating from VM2, with a Time to Live (TTL) of 0. * These packets will be sent to the mDNS multicast address (224.0.0.251 for IPv4). .. tab-item:: Test Case 15: Hostname Claim on Avahi Restart **verify that upon restarting the Avahi daemon, a device sends mDNS probe packets to claim its hostname before announcing its services** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns Enable publishing of hostname and addresses in Avahi's configuration. .. code-block:: shell test:~$ sudo nano /etc/avahi/avahi-daemon.conf publish-workstation=yes publish-addresses=yes * Step-4 : Assign IP address and set hostname .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.10 up * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname vm1 **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns Enable publishing of hostname and addresses in Avahi's configuration. .. code-block:: shell test:~$ sudo nano /etc/avahi/avahi-daemon.conf publish-workstation=yes publish-addresses=yes * Step-4 : Assign IP address .. code-block:: shell test:~$ sudo ifconfig enp0s8 192.168.1.11 up * Step-5 : Verification and Results * Stop and restart Avahi with Wireshark capture On VM2, stop the Avahi daemon. On VM1, start a Wireshark capture on the network link between the two VMs. On VM2, restart the Avahi daemon. * Observe Wireshark packets Look for a burst of mDNS query packets originating from VM2 for vm2.local. These packets should be queries (the QR bit is 0) and contain the hostname in the question section for A and AAAA records. These queries are sent to the mDNS multicast address (224.0.0.251 or ff02::fb). * Verify subsequent announcements If no hostname conflict is detected, VM2 should then send mDNS response packets with a TTL greater than 0, announcing its presence. * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. _mDNS_step20: .. tab-set:: .. tab-item:: Test Case 1: IPv6 Address Resolution via mDNS **verify that a client can resolve an IPv6 address using mDNS** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::1/64 dev wlp0s20f3 * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Client (Laptop B) Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::10/64 dev wlp0s20f3 * Step-5 : Test hostname resolution From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping6 shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 2: Hostname Resolution using avahi-resolve **verify that a client can resolve a hostname and its IPv6 address using the avahi-resolve-hostname command** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::1/64 dev wlp0s20f3 * Step-5 : Set the hostname of the server to laptopA .. code-block:: shell test:~$ sudo hostnamectl set-hostname shilpa **Client (Laptop B) Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::10/64 dev wlp0s20f3 * Step-5 : Resolve hostname From Laptop B, run avahi-resolve-hostname with the server's hostname to verify resolution. .. code-block:: shell test:~$ avahi-resolve-hostname shilpa.local Ping the server .. code-block:: shell test:~$ ping6 shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 3: Service Browsing via mDNS **verify that a client can browse available services using mDNS** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::1/64 dev wlp0s20f3 * Step-5 : Publish a service .. code-block:: shell test:~$ avahi-publish -s "my service" _http._tcp 8080 **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::10/64 dev wlp0s20f3 * Step-5 : Verification and Results * Browse for services From the laptopB, use avahi-browse -a -v -r to browse for all available services on the network. * Ping the server From Laptop B, ping Laptop A using its hostname with the .local suffix. .. code-block:: shell test:~$ ping6 shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 4: Reverse IPv6 Resolution **verify that a client can perform a reverse lookup to resolve an IPv6 address to a hostname using mDNS** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::1/64 dev wlp0s20f3 * Step-5 : Check hostname .. code-block:: shell test:~$ hostname **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::10/64 dev wlp0s20f3 * Step-5 : Verification and Results * Resolve the IPv6 address to a hostname From the laptopB, run avahi-resolve-address with the server's IPv6 address to perform a reverse lookup. .. code-block:: shell test:~$ avahi-resolve-address f8d8:7bbc:1295::1 * Ping the server's hostname .. code-block:: shell test:~$ ping6 shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 5: Manual mDNS Service Publishing **verify that a server can manually publish a custom mDNS service and a client can browse it** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::1/64 dev wlp0s20f3 * Step-5 : Publish a custom service Publish a custom service on the network using avahi-publish. The & symbol runs the command in the background. .. code-block:: shell test:~$ avahi-publish -s testprinter _ipp._tcp 631 "txtvers=1" & **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::10/64 dev wlp0s20f3 * Step-5 : Verification and Results * Browse for the custom service From the laptopB, use avahi-browse _ipp._tcp -r to browse for the specific _ipp._tcp service. .. code-block:: shell test:~$ avahi-browse _ipp._tcp -r * Ping the server's hostname .. code-block:: shell test:~$ ping6 shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. tab-item:: Test Case 6: Dynamic Service Discovery **verify that a client can dynamically discover a service that is published after the client begins browsing** **Laptop A Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon .. note:: * Enable and start the Avahi daemon service to allow it to run on boot and begin resolving hostnames. * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file and update the hosts line to include mDNS resolution. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::1/64 dev wlp0s20f3 * Step-5 : Check hostname .. code-block:: shell test:~$ hostname **Laptop B Setup** * Step-1 : Install Avahi and required tools .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install avahi-daemon avahi-utils libnss-mdns -y * Step-2 : Enable and start Avahi .. code-block:: shell test:~$ sudo systemctl enable avahi-daemon test:~$ sudo systemctl start avahi-daemon test:~$ sudo systemctl status avahi-daemon * Step-3 : Configure mDNS in Name Service Switch Edit the /etc/nsswitch.conf file to configure mDNS resolution on the client. .. code-block:: shell test:~$ sudo nano /etc/nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns * Step-4 : Assign IPv6 address .. code-block:: shell test:~$ sudo ip -6 addr add f8d8:7bbc:1295::10/64 dev wlp0s20f3 * Step-5 : Verification and Results * Start browsing on the client From the laptopB, use avahi-browse to look for the _sftp-ssh._tcp service. At this point, no services should be displayed. .. code-block:: shell test:~$ avahi-browse _sftp-ssh._tcp -r * Publish the service on the server While the laptopB is still browsing, publish the _sftp-ssh._tcp service on the laptopA. .. code-block:: shell test:~$ avahi-publish -s testprinter _sftp-ssh._tcp 631 "txtvers=1" & * Observe client output The laptopB's avahi-browse command should immediately display the newly published service. * Ping the server .. code-block:: shell test:~$ ping6 shilpa.local * Step-6 : Wireshark Capture :download:`Download wireshark capture ` .. _mDNS_step6: .. tab-set:: .. tab-item:: mDNS Protocol Packet Details **Query Packet** .. csv-table:: :file: ./mDNS/mDNS_packetdetails1.csv :widths: 10,20,30,10 :header-rows: 1 **Response Packet** .. csv-table:: :file: ./mDNS/mDNS_packetdetails2.csv :widths: 10,20,30,10 :header-rows: 1 **Service Announcement** .. csv-table:: :file: ./mDNS/mDNS_packetdetails3.csv :widths: 10,20,30,10 :header-rows: 1 **Goodbye Packet** .. csv-table:: :file: ./mDNS/mDNS_packetdetails4.csv :widths: 10,20,30,10 :header-rows: 1 **Probe Packet** .. csv-table:: :file: ./mDNS/mDNS_packetdetails5.csv :widths: 10,20,30,10 :header-rows: 1 .. _mDNS_step7: .. tab-set:: .. tab-item:: mDNS Usecases .. csv-table:: :file: ./mDNS/mDNS_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _mDNS_step8: .. tab-set:: .. tab-item:: mDNS Basic Features .. csv-table:: :file: ./mDNS/mDNS_Basic_Features.csv :widths: 10,10,30 :header-rows: 1 .. _mDNS_step9: .. tab-set:: .. tab-item:: mDNS Feature : Local Name Resolution **Local Name Resolution - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature1_Local_Name_Resolution_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step10: .. tab-set:: .. tab-item:: mDNS Feature : Zero Configuration **Zero Configuration - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature2_Zero_Configuration_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step11: .. tab-set:: .. tab-item:: mDNS Feature : Multicast Communication **Multicast Communication - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature3_Multicast_Communication_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step12: .. tab-set:: .. tab-item:: mDNS Feature : .local Domain Usage **.local Domain Usage - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature4_.local_Domain_Usage_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step13: .. tab-set:: .. tab-item:: mDNS Feature : Service Discovery (via DNS-SD) **Service Discovery (via DNS-SD) - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature5_Service_Discovery_via_DNS_SD_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step14: .. tab-set:: .. tab-item:: mDNS Feature : Cross-Platform Support **Cross-Platform Support - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature6_Cross_Platform_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step15: .. tab-set:: .. tab-item:: mDNS Feature : No Central Server Needed **No Central Server Needed - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature7_No_Central_Server_Needed_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step16: .. tab-set:: .. tab-item:: mDNS Feature : Automatic Conflict Resolution **Automatic Conflict Resolution - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature8_Automatic_Conflict_Resolution_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step17: .. tab-set:: .. tab-item:: mDNS Feature : Lightweight Protocol **Lightweight Protocol - Testcases** .. csv-table:: :file: ./mDNS/mDNS_Feature9_Lightweight_Protocol_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _mDNS_step18: .. tab-set:: .. tab-item:: Reference links * Reference links