Talk:Dnscrypt-proxy

From ArchWiki
Revision as of 04:54, 25 January 2017 by Quequotion (talk | contribs) (the example is basically just a repeat of the one in #Change_port)
Jump to navigation Jump to search

Refactoring to include dnscrypt-wrapper information & configuration.

Hello, I'm new so bear with me if I get any of this wrong. I would like to refactor the page to reflect the addition of dnscrypt-wrapperAUR to the AUR. dnscrypt-wrapper is the server-side wrapper for dnscrypt-proxy. Any advice on the best way to do this would be appreciated. Would adding sub-headings for both packages below Installation & Configuration be the best approach?

Thanks MeZee (talk) 17:57, 10 January 2016 (UTC)

Just add it to the Installation section and describe what it does. Rdeckard (talk) 17:13, 23 September 2016 (UTC)
Closing -- Rdeckard (talk) 15:04, 24 January 2017 (UTC)

1.8.1 Update: New /etc/dnscrypt-proxy.conf

There's a new configuration file that is not reflected in the article, as well as a new systemd unit. Users should now use that configuration file, but at least for me, the update to 1.8.1 did not break my old units (since I used systemd edit. This is a section for discussing modifications needed for the update. -- Rdeckard (talk) 22:45, 27 December 2016 (UTC)

This may just need to be in an advanced section. [1]. -- Rdeckard (talk) 23:00, 27 December 2016 (UTC)

It seems like the configuration file is not useful if using systemd: [2] -- Rdeckard (talk) 13:18, 28 December 2016 (UTC)

You may be jumping to conclusions. Only the ListenAddress option is discussed there; it cannot be inferred that this means all of the options in the configuration file are ignored if they are already set in the systemd socket/service files. IMHO, if there is an independent configuration file that can set options (and use .pac{new,save}) then it is superior to use it rather than edit the sytemd files which are overwritten by every install and less confusing than putting custom options in places like cat /etc/systemd/system/dnscrypt-proxy.{service,socket}.d/override.conf
If it can be done, I think it would be prudent to ship dnscrypt-proxy with systemd files that don't set options that can be set by its native configuration file, and change the wiki to describe setting it up by its own configuration file. quequotion (talk) 12:23, 23 January 2017 (UTC)
And it appears this cannot be done for the socket. If one intends to use systemd to open the socket, the listen address must be set in the socket file or its override.conf. quequotion (talk) 12:36, 23 January 2017 (UTC)
You will need to file a bug report / feature request if you want to make changes with what files are shipped with the package (possibly with both Arch and upstream). This is a place to discuss what needs to be done on the wiki page to reflect that a configuration file is available. -- Rdeckard (talk) 18:00, 23 January 2017 (UTC)
True, but since they'd need to be done simultaneously--and the bug report / feature request will be dismissed out of hand without a proposal here to back it up (and probably dismissed anyway just because), I'm going to go ahead and get started with a changes proposal here first. quequotion (talk) 07:02, 24 January 2017 (UTC)
I have no idea where you are going, but the current dnscrypt-proxy.service looks like this, i.e. it does not specify any option besides the config file path. -- Lahwaacz (talk) 12:13, 24 January 2017 (UTC)
Oh. Is that what's shipping in arch's package? If so, the changes I'm proposing are ready for debate as a (partially) new page. The point is to avoid making changes to the .service file. This file will be overwritten when dnscrypt-proxy gets upgraded, potentially breaking internet connectivity; it's much safer to configure dnscrypt-proxy outside of this file. Furthermore the config file is quite user-friendly; the included dnscrypt-proxy.conf.example documents the options quite well (in English at least). Only users who want to do something special like instanced services should be editing the .service file. quequotion (talk) 13:26, 24 January 2017 (UTC)
Nobody was suggesting anywhere to make changes to the service file in /usr/lib/systemd/ directly. All instructions use the edit link, which implies using systemctl edit or systemctl edit --full, which create either a drop-in snippet or an overriding service, both placed in /etc/systemd/. Hence the argument about having the changes overwritten on package upgrades does not apply. -- Lahwaacz (talk) 13:42, 24 January 2017 (UTC)
I understand your logic, but I can't be the only impatient person who didn't click there and edited it directly anyway. Regardless, having less to figure out is better. Maybe I'm old-fashioned, but I think it's easier to work with an ordinary config file in the text editor of my choice and not have to interact with systemctl whenever it can be avoided. There's no need to go that far under-the-hood in this case. quequotion (talk) 14:40, 24 January 2017 (UTC)
If you want to use a local DNS cache like unbound you still have to edit the .socket file, even when using the configuration file. Either way, I think the configuration file does need to be mentioned in the page, along with this limitation. -- Rdeckard (talk) 14:50, 24 January 2017 (UTC)
I think it would be best to recommend using the config file for the most obvious, single-instance configuration and spare the details of editing the service file for things like instanced implementations. If we can get FS#49881 resolved, I'd be happy to do away with the whole section about specifying a user. quequotion (talk) 15:38, 24 January 2017 (UTC)

Proposal: Configuration by config file

It seems more sane to me that users should not edit the .service file to change options except for advanced needs like multiple instances. This way users avoid several systemctl daemon-reloads and the package maintainer could use .pac{new,save} to protect user configurations across upgrades. Note, rather than copy and paste the entire page here, I have only posted the specific sections I intend to change; do not take the absence of a particular piece of information to explicitly imply its intended deletion. quequotion (talk) 16:37, 24 January 2017 (UTC)

Configuration

Tip: A thorough example configuration file, /etc/dnscrypt-proxy.conf.example is included, but note that systemd overrides the LocalAddress option with a socket file

To configure dnscrypt-proxy, perform the following steps:

Select resolver

Select a resolver from /usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv and edit /etc/dsncrypt-proxy.conf, using a short name from the csv file's first column, Name. For example, to select dnscrypt.eu-nl as the resolver:

ResolverName dnscrypt.eu-nl
Comment: I think the language change regarding the csv file should go in regardless, but I didn't just go ahead with it in case that only sounds less confusing to me. quequotion (talk) 15:29, 24 January 2017 (UTC)


Comment: Looks good to me. -- Rdeckard (talk) 18:20, 24 January 2017 (UTC)

Redundant DNSCrypt providers

To use additional dnscrypt providers, you may copy /etc/systemd/system/dnscrypt-proxy.service and /etc/systemd/system/dnscrypt-proxy.socket to new files.

Specify a different resolver using the -R flag and a short name from dnscrypt-resolvers.csv in the new service file.

Tip: Any other options you wish to use with this resolver should be specified on this command line; the use of a config file with command line options is unsupported.
[Service]
ExecStart=
ExecStart=/usr/bin/dnscrypt-proxy -R short-name.here

Then specify a different port in the new socket file.

Lastly, update your local DNS cache program to point to new service's port. For example, with unbound the configuration file would look like if using ports 5353 for the original socket and 5354 for the new socket.

Comment: command-line options override the configuration file (when run as a systemd service at least) quequotion (talk) 15:29, 24 January 2017 (UTC)
Comment: If this is the case, it is a bug - the man page says OPTIONS (ignored when a configuration file is provided). -- Lahwaacz (talk) 13:18, 24 January 2017 (UTC)
Comment: That's bad news; this is definetly the case. So users who want redundant / instanced services need to specify all their options on the command line and that's fine with me. quequotion (talk) 13:34, 24 January 2017 (UTC)
Comment: Or simply have multiple config files and an instantiated service similar to this one to select the right config. -- Lahwaacz (talk) 13:45, 24 January 2017 (UTC)
Comment: Sounds good; putting this back into the proposal with some adjustments. quequotion (talk) 14:15, 24 January 2017 (UTC)
Comment: The more I boil down the method above, the more it seems like it would be more sensible to remove it from the page entirely and just recommend the instances method. quequotion (talk) 15:07, 24 January 2017 (UTC)
Add dnscrypt-sockets

To create multiple dnscrypt-proxy sockets, Edit dnscrypt-proxy.socket, change the port and save it as a new file /etc/systemd/system/dnscrypt-proxy@short-name.here.socket, replacing the socket instance name with one of the short names listed in dnscrypt-resolvers.csv. Use a different port for each instance (5353, 5354, and so forth).

Comment: Decided to withdraw proposal for instanced config files; although there might be some edge use-case for the idea it isn't practical considering someone who wants instanced dnscrypt-services probably won't be uncomfortable with editing service files and specifying command line options. quequotion (talk) 16:31, 24 January 2017 (UTC)
Comment: If there are no complaints I might just put this part in--it isn't dependent on the rest of the proposal and is mostly just a streamlining of the two subsections on the page. I intend to keep the example that follows as-is. quequotion (talk) 17:49, 24 January 2017 (UTC)
Comment: Does the DNSCrypt#Change port section not address this? Also, no need to copy files. Just use systemctl edit as shown in Systemd#Drop-in_files. -- Rdeckard (talk) 18:23, 24 January 2017 (UTC)
Comment: This replaces the two sections DNSCrypt#Add_first_dnscrypt-socket and DNSCrypt#Add_additional_dnscrypt-sockets under DNSCrypt#Create_instanced_systemd_service. I've made some changes to recycleDNSCrypt#Change port a bit more and incorporate Edit. I suppose we can even do away with the example that follows this, but we still need this section to explain creating separate socket files for each instance. quequotion (talk) 04:51, 25 January 2017 (UTC)

dnscrypt runs with root privileges

See FS#49881. To work around this, create an unprivileged user manually.

Create the user as follows:

# useradd -r -d /var/dnscrypt -m -s /sbin/nologin dnscrypt

Edit /etc/dnscrypt-proxy.conf, appending the new user:

User dnscrypt
Comment: If you use an unprivileged port (e.g. 5353) you can let systemd handle the user as in the current version of the wiki page. This version above has the systemd unit running as root still and doesn't drop it until dnscrypt runs. By using User= in the systemd unit the entire unit runs without root privileges. -- Rdeckard (talk) 14:58, 24 January 2017 (UTC)
Comment: Which is why I've proposed no changes to that subsection. This is intended only to replace the lines that demontrate specifying the user on the command line in the service file. In fact, I suppose those lines could be removed from the wiki, but that would have users editing service files again (until FS#49881 is resolved; not sure what's holding it back). quequotion (talk) 15:20, 24 January 2017 (UTC)
Comment: Got it. Looks good to me. -- Rdeckard (talk) 18:20, 24 January 2017 (UTC)

Backup DNSCrypt resolver - especially with the new configuration file

Usually when setting a dns resolver you will always have the option to set a second/backup dns resolver (android,windows,networkmanager,router, what ever).

I think the wiki should cover a way on how to achieve the same with dnscrypt. Especially as some if the dnscrypt resolvers like to go offline every now and then (looking at you dnscrypt.eu-nl).

I have a running setup (which caused me some struggles to achieve that setup) but I have no idea how to replicate it. Espcially with the new configuration file which seems like it will only cover one dnscrypt instance?

Right now I have 2x dnscrypt running in systemd and the resolver.conf will choose which ever is online/working.

—This unsigned comment is by Utini2000 (talk) 11:56, 30 December 2016‎. Please sign your posts with ~~~~!

It already describes that: DNSCrypt#Redundant_DNSCrypt_providers -- Lahwaacz (talk) 12:02, 30 December 2016 (UTC)
But this is with the old configuration file, not the new one? Also it seems like this only covers unbound but what about e.g. dnsmasq? —This unsigned comment is by Utini2000 (talk) 16:21, 30 December 2016. Please sign your posts with ~~~~!