Setting up dnscrypt-proxy in Artix OpenRC with netifrc

This guide will help you set up dnscrypt-proxy in Artix OpenRC and probably other OpenRC systems using the netifrc service for configurating your network

Your dnscrypt-proxy is probably reporting timeout like so:

Jul 21 23:54:42 artix2 dnscrypt-proxy[1982]: Anonymizing queries for [ams-dnscrypt-nl] via [anon-scaleway]
Jul 21 23:54:43 artix2 dnscrypt-proxy[1982]: [ams-dnscrypt-nl] TIMEOUT

Or DNS leak test is reporting default DNS servers (probably Google).

To fix it, we need to disable DHCP and point the DNS nameserver in /etc/resolv.conf to localhost which is dnscrypt-proxy. Changing it directly doesn't work because netifrc automatically overwrites this file with the configuration from /etc/conf.d/net. Of course, you could chattr it so that netifrc doesn't change it, like was pointed out in Setting up dnscrypt proxy on Gentoo Linux based gateway, but that looks like sketch. So, remove any mention of DHCP in your /etc/conf.d/net and add these lines:

config_eth0="192.168.1.100/24"
routes_eth0="default via 192.168.1.1"
dns_servers_eth0="127.0.0.1"

I'm not sure, but I think you need to change `config_eth0` with your computers LAN IP address and routes_eth0 with your router's IP, and of course, you should change eth0 to match your device.

I also had this line, not sure what it does, but I removed it and everything was still working, maybe it can help if the above doesn't work:

dns_options_eth0="edns0"

Save and restart the netifrc service with something like sudo rc-service net.eth0 restart. It should display:

 * Bringing up interface eth0
 *   192.168.1.100/24 ...
 *   Adding routes
 *     default via 192.168.1.1 ...

After that, you're (probably) all set. As always, test if it's working in DNS leak test.

Note: Sorry if I explained something wrong or couldn't help on something, this netifrc config was in my Artix 1 since I've installed it 4 years ago, and I have no idea how I got it. I'm posting it here so I don't lose it, and perhaps so it helps someone.