Page 1 of 1

How can I change the priorities in DNS?

Posted: Tue Feb 18, 2020 12:01 pm
by humanti4200
Hello.

I am totally new to Linux and Raspberry pi (and also network).

I tried to connect raspberry pi SSH with its hostname, which is

Code: Select all

ssh pi@raspberrypi.local
However, it fails. (With IP, 192.168.0.17, it works)

I use command

Code: Select all

dns-sd -q raspberrypi.local
from my Mac and the result is the following.

Code: Select all

MacBook-Pro:~ User$ dns-sd -q raspberrypi.local
DATE: ---Tue 18 Feb 2020---
20:39:36.658  ...STARTING...
Timestamp     A/R    Flags if Name                          Type  Class   Rdata
20:39:36.659  Add 40000002  0 raspberrypi.local.            Addr   IN     218.38.137.27
20:39:37.103  Add        2  4 raspberrypi.local.            Addr   IN     192.168.0.17
It seems that 218.38.137.27 (it is the DNS server of ISP) resolved and prioritised.

How can I change the priority of my internal IP (192.168.0.17) in DNS to use

Code: Select all

ssh pi@raspberrypi.local
successfully?

Best Regards,

Re: How can I change the priorities in DNS?

Posted: Tue Feb 18, 2020 4:06 pm
by topguy
Any reason you don't use the actual name..

Code: Select all

ssh pi@raspberrypi.local

Re: How can I change the priorities in DNS?

Posted: Tue Feb 18, 2020 9:03 pm
by epoch1970
You can’t prioritize results, basically. In case a DNS server sends many A records (IPv4 addresses) the client will pick one, usually the first one received.

In your case you are not using DNS but mDNS (.local) but it works exactly the same; each machine publishes its host name and the IPv4 and IPv6 address of every network interface, and clients get results in no particular order.

As topguy says, the solution under DNS is to specify the domain name (e.g. pi.lan, pi.somedomain.com) in order to get a single address or many addresses, but all identically usable.

Under mDNS you have no such option. What you could do is block the mDNS daemon (avahi, in /etc/avahi/daemon.conf) from using one interface, e.g. eth0. In this case the daemon will neither publish the IP address(es) of eth0; nor will it respond to requests received on that interface.

Re: How can I change the priorities in DNS?

Posted: Wed Feb 19, 2020 12:09 am
by humanti4200
Thank you for all kind replies.

I typed the wrong command.

Code: Select all

ssh pi@raspberrypi.local
I actually used The same as the above.

However, it did not work.

When I try nslookup, dig or ping raspberrypi.local, it always connects to 218.38.137.27. However, I want to connect 192.168.0.17.

I will try to block avahi using one interface.

Best Regards,