Skip to content

Instantly share code, notes, and snippets.

@mxvin
Created December 4, 2021 13:47
Show Gist options
  • Save mxvin/706a70c7e3f78b5919f987d53dabb699 to your computer and use it in GitHub Desktop.
Save mxvin/706a70c7e3f78b5919f987d53dabb699 to your computer and use it in GitHub Desktop.
How to Getting Started using Adguard dnsproxy (https://github.com/AdguardTeam/dnsproxy) on Windows. Simple and flexible by utilizing vbs script

Quick & Simple Way using Adguard "dnsproxy" on Windows:

  1. Put executable you get from release page, or consider use the custom build one (more on this later) -- on %appdata%\dnsproxy
  2. Put this VBScript on Startup folder:
    • Your user startup at shell:startup OR All Users startup at shell:common startup
  3. Create shortcut of previously saved VBScript on the Startup folder to Desktop for easier access (Useful on the event of dnsproxy may seems to hang)
    • Plus, you can change the shortcut icon as you wish :)
  4. Customize dnsproxy options as you like by changing the L4 of dnsproxy.vbs. For available options, learn more on dnsproxy README file.
    • I put bare config: primary upstream (-u) using Cloudflare DNS and fallback (-f) using Quad9 DNS (both in DNS-over-TLS); with 1MB in-memory cache (--cache --cache-size=<int in Bytes>); listen on localhost (-l 127.0.0.1)
  5. Finish! Now dnsproxy always start on boot, and if needed, restart using shortcut we made on the desktop.

It is better to have dnsproxy.exe exec compiled as windowsgui.

  • This will remove dependency of shell host 'Console Window Host' as we don't need shell and it's daemonized on the background afterall.

  • You may want to use x86 exec, as I notice lower memory footprint on x86 builds. so first set GOARCH to 386

    go env -w GOARCH=386
    
  • Use this go build command after you clone the repo and also you may also need to checkout to stable tags/version:

    go build -mod=vendor -ldflags "-s -w -X main.VersionString=<TYPE VERSION HERE>" -H windowsgui
    
  • Note that this executable will not output anything, so it's not debuggable. Logging in this mode only can be achieved if somehow dnsproxy maintainer adds 'logging to file' function.

Set Shell = CreateObject("WScript.Shell")
Shell.Run "taskkill /F /im dnsproxy.exe", 0, False
WScript.Sleep 1000
Shell.Run "%APPDATA%\dnsproxy\dnsproxy.exe -u tls://1.1.1.1 -f tls://9.9.9.9 -l 127.0.0.1 --cache --cache-size=1000000", 0, False
MsgBox "dnsproxy restarted",64,"Adguard dnsproxy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment