Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Multicast DNS to find the system in Local area Network

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use multicast DNS to discover systems in a local area network." Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "how to use multicast DNS to discover systems in a local area network"!

Multicast DNS (mDNS) also works at the IP level, it uses port 5353, because it is only an extension of DNS, so it also determines that it is basically the same as DNS. The difference is that it does not request DNS servers, but broadcasts within the local area network, and all devices that support multicast DNS reply with their own domain name (a machine name ending in.local). If they do not specify their own machine name or there is a conflict, the new device will continue broadcasting with a different name until the name is available and accepted by other devices.

This article assumes that you have two systems running a supported version of Fedora (27 or 28). Their host names are castor and flux.

installation package

Ensure that the nss-mdns and avahi packages are installed on your system. You may be a different version, and that's fine:

$ rpm -q nss-mdns avahinss-mdns-0.14.1-1.fc28.x86_64avahi-0.7-13.fc28.x86_64

Fedora Workstation provides these two packages by default. If they do not exist, install them:

$ sudo dnf install nss-mdns avahi

Ensure that the avahi-daemon.service unit is enabled and running. Again, this is the default setting for Fedora Workstation.

$ sudo systemctl enable --now avahi-daemon.service

Although optional, you may also need to install the avahi-tools package. The package includes a number of convenient programs for checking the operation of the zero-configuration service on the system. Use this sudo command:

$ sudo dnf install avahi-tools

/etc/nsswitch.conf controls which services the system uses for parsing and in which order. You should see this line in that file:

hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname

Note the command mdns4_minimal [NOTFOUND=return]. They tell your system to use multicast DNS resolvers to resolve host names to IP addresses. Even if the service is valid, the remaining services are tried if the name cannot be resolved.

If you don't see a configuration like this, you can edit it (as root). However, the nss-mdns package handles this for you. If you feel uncomfortable editing it yourself, remove and reinstall the package to repair the file.

Perform the same steps in both systems.

Set hostname and test

Now that you have done the usual configuration work, set the name of each host using one of the following methods:

If you are using Fedora Workstation, you can use this procedure. If not, use hostnamectl to do it. Do this on the first machine: $ hostnamectl set-hostname castor. You can also edit/etc/avahi/avahi-daemon.conf to remove the comment on the hostname setting line and set the name there. By default, however, Avahi uses a system-supplied hostname, so you shouldn't need this method. Next, restart the Avahi daemon so that it receives changes:

$ sudo systemctl restart avahi-daemon.service

Then set up another machine correctly:

$ hostnamectl set-hostname pollux$ sudo systemctl restart avahi-daemon.service

As long as your router doesn't block mDNS traffic, you should now be able to log in to Castor and ping another machine. You should use the default.local domain name for resolution to work properly:

$ ping pollux.localPING pollux.local (192.168.0.1) 56(84) bytes of data.64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=1 ttl=64 time=3.17 ms64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=2 ttl=64 time=1.24 ms...

If you're in pollux ping castor.local, the same technique applies. It's now easier to access your system from the web!

Also, don't be surprised if your router also supports this service. Modern WiFi and wired routers often offer these services to make life easier for consumers.

This procedure applies to most systems. However, if you run into trouble, use the avahi-browse and other tools in the avahi-tools package to see what services are available.

At this point, I believe we have a deeper understanding of "how to use multicast DNS to discover systems in a local area network," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report