humanti4200
Posts: 2
Joined: Tue Feb 18, 2020 11:49 am

How can I change the priorities in DNS?

Tue Feb 18, 2020 12:01 pm

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,
Last edited by humanti4200 on Tue Feb 18, 2020 10:28 pm, edited 1 time in total.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can I change the priorities in DNS?

Tue Feb 18, 2020 4:06 pm

Any reason you don't use the actual name..

Code: Select all

ssh pi@raspberrypi.local

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How can I change the priorities in DNS?

Tue Feb 18, 2020 9:03 pm

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.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

humanti4200
Posts: 2
Joined: Tue Feb 18, 2020 11:49 am

Re: How can I change the priorities in DNS?

Wed Feb 19, 2020 12:09 am

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,

Return to “Troubleshooting”