Skip to content

Building from source

Frank Denis edited this page Mar 27, 2025 · 9 revisions

How to build dnscrypt-proxy

1. Build tools and starting up

Windows: Install git and go. Or use chocolatey:

choco install git golang

Now open a Powershell window (Win+X > Windows Powershell).

Linux: Open a terminal window, install git and go:

<pkg-install-command> git golang

Android: Install Termux and start it. Then install git and go:

pkg install git golang

2. Create your working directory

mkdir dnscrypt-proxy-src
cd dnscrypt-proxy-src

3. Clone this repo

Must be cloned into a folder called src.

git clone --depth=1 https://github.com/DNSCrypt/dnscrypt-proxy src

4. Set environment variables

GOOS and GOARCH don't need to be set if you're only building for your current OS install, they're already set to the right values (see go env GOOS GOARCH). Otherwise, possible values can be found here. You may also want to set GOARM when using GOARCH=arm, see GoArm wiki.

# Windows
$env:GOOS='windows'
$env:GOARCH='amd64'

# Linux
export GOOS=linux
export GOARCH=amd64

# Android
export GOOS=android
export GOARCH=arm64

### 5. Build dnscrypt-proxy

Change the output path as appropriate for your OS/arch.

```sh
cd src/dnscrypt-proxy

go build -ldflags="-s -w" -mod vendor

The binary should be inside in the current directory.

go: ../go.mod requires go >= ...

If the build command returns an error similar to go: ../go.mod requires go >= ..., it means your Go toolchain is older than the version dnscrypt-proxy was developed and tested with.

dnscrypt-proxy generally uses the latest stable Go version as it is released.

You can download a more recent version of Go from the official Go website. The downloaded files can be installed anywhere and can be removed afterwards.

Alternatively, you can use goenv, a convenient tool for installing (even temporarily) multiple versions of Go.

Building for Android

  • Building on a non-Android OS: You cannot build the Android version without following this guide first.
  • Building on Android: You cannot build for an android/arch different to your device's, nor can you build for Linux/any arch. Windows with any arch seems to work however.

You will need root to use dnscrypt-proxy. Otherwise, you can try copying it to internal storage.

Clone this wiki locally