KadNode icon indicating copy to clipboard operation
KadNode copied to clipboard

Debian: add KadNode to resolv.conf

Open stokito opened this issue 1 year ago • 9 comments

The openwrt package register redirect of the .p2p domains to a local kadnode dns resolver. But for Debian and Arch only the NSS reolver is added. Should we add the preinst script that will add the same redirect to the resolv.conf?

stokito avatar Nov 23 '24 13:11 stokito

The problem is that the TLD that is intercepted is configurable. So when it is set for the kadnode binary, it would also need to be changed in the /etc/resolv.conf. On OpenWrt I had no other choice because there is no /etc/nsswitch.conf.

mwarning avatar Nov 23 '24 14:11 mwarning

We may add the same p2p TLD by default. Any advanced users may set up own domain if needed.

stokito avatar Nov 23 '24 16:11 stokito

Sure, we can use /etc/resolv.conf on Debian instead of /etc/nsswitch.conf if it is possible.

mwarning avatar Nov 23 '24 17:11 mwarning

I found that Consul redirects DNS for own tld: https://developer.hashicorp.com/consul/docs/services/discovery/dns-forwarding/enable#systemd-resolved

So create /etc/systemd/resolved.conf.d/kadnode.conf

[Resolve]
DNS=127.0.0.1:3535
DNSSEC=false
Domains=~p2p

then

systemctl restart systemd-resolved

add to /etc/kadnode/kadnode.conf the option --dns-port 3535 and systemctl restart kadnode.

I think we should do this by default.

stokito avatar Jan 19 '25 22:01 stokito

Hi, that is what we do on OpenWrt already. If it works, then I would definitely prefer this. Do you like to create an MR?

mwarning avatar Jan 19 '25 23:01 mwarning

I may send a PR later. BTW the Consul article shows that we may add a file into /etc/dnsmasq.d/ so we probably may get rid off the postinst script.

stokito avatar Jan 20 '25 08:01 stokito

hm, dnsmasq does not seem to use /etc/dnsmasq.d by default in OpenWrt

mwarning avatar Jan 20 '25 22:01 mwarning

yes, the ps ax | grep dnsmasq shows /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c so it uses the generated config. The generated config inside has only one conf-dir=/tmp/dnsmasq.d. I don't know why the OpenWrt doesn't look for the the standard folder.

The postinst has:

uci add_list dhcp.@dnsmasq[0].server='/p2p/::1#3535'

The wiki page says:

If it does not work it may mean that KadNode tries to connect to the IPv4 localhost address. Change ::1 by 127.0.0.1 in this case.

Maybe use the IPv4 here? like /p2p/127.0.0.2#3535. If someone built OpenWrt without the IPv6 support then it won't have a trouble.

stokito avatar Jan 20 '25 22:01 stokito

I agree that 127.0.0.1 is the slightly better choice.

mwarning avatar Jan 21 '25 06:01 mwarning