shrewdns

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: GPL-3.0

README

    ______                  ___  _  ______
   / __/ /  _______ _    __/ _ \/ |/ / __/
  _\ \/ _ \/ __/ -_) |/|/ / // /    /\ \  
 /___/_//_/_/  \__/|__,__/____/_/|_/___/  

Shrews are mole-like creatures that burrow tunnels. ShrewDNS tunnels UDP over DNS (with shrewdness).

ShrewDNS – Use case

It tunnels UDP over DNS. This is useful to escape from restricted networks that allow DNS queries but little else, such as WiFi captive portals, which you might find at hotels or, increasingly common nowadays, miles high on commercial passenger airliners.

On top of the UDP channel relayed through the shrewdns-server, you can run a VPN (Wireguard, for instance). Or, to keep things nimble, you can run quicmux, another gadget of mine, to tunnel TCP and Unix sockets over that UDP channel. And then you can SSH out, or browse the web using a SOCKS5 server. Over DNS.

But why

A not so terse writeup, but 100% human written, with leadup, historical context, YES I KNOW ABOUT IODINE, technical background, justifications for calling this "fun", and even a screenshot is to be found here.

Documentation

Find it in the docs.

Warp 9 quickstart

# Build and install the server. You need the go compiler
# (from the Golang programming language, https://go.dev)
# to build it.
GOBIN=/where/you/wanted/the/binary/ \
CGO_ENABLED=0 \
go install -v \
-ldflags="-s -w" -trimpath \
nontrivialpursuit.org/shrewdns/cmd/shrewdns-server@latest

# Run it and reach a state of enhanced bewilderment
/where/you/wanted/the/binary/shrewdns-server --help

For the client, it's the same, just replace server with client in the above two commands.

Maybe now is a good moment to mention the docs again.

What, no CI release builds?

No, not right now. But Golang makes it so easy to compile (see above), and even cross-compile, that providing prebuilt binaries would just mean that instead of running go install, you run curl.

Perhaps in the future, just the client, for select targets (android/arm64, ios/arm64, maybe windows/amd64). A simple wrapper for Android that passes a captive portal's DNS resolver to shrewdns-client would be handy!

Contributing / Discussing

Licensing

Pico CSS

Pico CSS v2.1.1 and Pico Colors v2.1.1 are vendored under the MIT License.

ShrewDNS itself

ShrewDNS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ShrewDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ShrewDNS. If not, see https://www.gnu.org/licenses/. The full text is in LICENSE.

Directories

Path Synopsis
cmd
shrewdns-client command
shrewdns-client/handler
Package handler holds the client tunnel handlers (DNS and, later, raw) and the fragment state the send loop owns.
Package handler holds the client tunnel handlers (DNS and, later, raw) and the fragment state the send loop owns.
shrewdns-codec command
shrewdns-qname command
Command shrewdns-qname encodes and decodes authenticated ShrewDNS data and probe QNAMEs offline.
Command shrewdns-qname encodes and decodes authenticated ShrewDNS data and probe QNAMEs offline.
shrewdns-server command
lib
abuse
Package abuse tracks per-source admission outcomes for shrewdns-server and temp-bans source networks whose traffic is mostly not admitted: invalid, unauthenticated, or replayed requests all count as not admitted, and a network whose not-admitted count exceeds its admitted count (past a small floor) is banned for a configured duration.
Package abuse tracks per-source admission outcomes for shrewdns-server and temp-bans source networks whose traffic is mostly not admitted: invalid, unauthenticated, or replayed requests all count as not admitted, and a network whose not-admitted count exceeds its admitted count (past a small floor) is banned for a configured duration.
capture
Package capture keeps a bounded in-memory history of DNS-leg packets and exports them as synthetic pcapng files with reconstructed IPv4/IPv6+UDP headers.
Package capture keeps a bounded in-memory history of DNS-leg packets and exports them as synthetic pcapng files with reconstructed IPv4/IPv6+UDP headers.
carrier
Package carrier binds ShrewDNS payloads to DNS answer carriers.
Package carrier binds ShrewDNS payloads to DNS answer carriers.
cli
Package cli provides the command-line conventions shared by the ShrewDNS tools: flag sets that open with the project banner, help and version handling, usage-error classification, and process exit statuses.
Package cli provides the command-line conventions shared by the ShrewDNS tools: flag sets that open with the project banner, help and version handling, usage-error classification, and process exit statuses.
codecs
Package codecs implements integer-safe radix and byte-stream encodings.
Package codecs implements integer-safe radix and byte-stream encodings.
colofon
Package colofon reports the build version embedded by the Go toolchain and the project banner built from it.
Package colofon reports the build version embedded by the Go toolchain and the project banner built from it.
datagramqueue
Package datagramqueue provides bounded FIFO queues for opaque datagrams.
Package datagramqueue provides bounded FIFO queues for opaque datagrams.
dnsclient
Package dnsclient performs matched DNS exchanges with a configured resolver.
Package dnsclient performs matched DNS exchanges with a configured resolver.
dnsname
Package dnsname parses and formats DNS presentation names used by ShrewDNS.
Package dnsname parses and formats DNS presentation names used by ShrewDNS.
dnswire
Package dnswire composes and parses complete DNS messages for the ShrewDNS TXT, A, and DNSKEY bindings.
Package dnswire composes and parses complete DNS messages for the ShrewDNS TXT, A, and DNSKEY bindings.
env
Package env is the single point of access to the process environment.
Package env is the single point of access to the process environment.
eventbus
Package eventbus is the process-wide event bus registry: every topic emitted on a go-bus event bus is declared here together with the event name it carries on the wire.
Package eventbus is the process-wide event bus registry: every topic emitted on a go-bus event bus is declared here together with the event name it carries on the wire.
header
Package header encodes and decodes the fixed-width ShrewDNS request headers.
Package header encodes and decodes the fixed-width ShrewDNS request headers.
logging
Package logging configures the daemons' structured logger and lets a running process change its verbosity without a restart.
Package logging configures the daemons' structured logger and lets a running process change its verbosity without a restart.
net
Package net owns long-lived sockets and queues used by the UDP tunnel.
Package net owns long-lived sockets and queues used by the UDP tunnel.
pathprobe
Package pathprobe orchestrates bounded DNS path characterization probes.
Package pathprobe orchestrates bounded DNS path characterization probes.
pcapng
Package pcapng writes minimal pcapng capture files: one section header block, one interface description block per interface, and one enhanced packet block per packet.
Package pcapng writes minimal pcapng capture files: one section header block, one interface description block per interface, and one enhanced packet block per packet.
probe
Package probe implements the authenticated ShrewDNS probe request and response protocol.
Package probe implements the authenticated ShrewDNS probe request and response protocol.
rawmode
Package rawmode implements raw-mode packet framing and control probes.
Package rawmode implements raw-mode packet framing and control probes.
reassembly
Package reassembly assembles ShrewDNS fragment records without depending on DNS names, carriers, authentication, or the qname package.
Package reassembly assembles ShrewDNS fragment records without depending on DNS names, carriers, authentication, or the qname package.
relayparams
Package relayparams defines the parameter set the advice function hands to RelayManager: the complete recipe for exactly one handler.
Package relayparams defines the parameter set the advice function hands to RelayManager: the complete recipe for exactly one handler.
replay
Package replay provides a bounded two-generation registry for replay denial state.
Package replay provides a bounded two-generation registry for replay denial state.
semaphore
Package semaphore provides a counting semaphore with a dynamically resizable capacity.
Package semaphore provides a counting semaphore with a dynamically resizable capacity.
server
Package server owns the shrewdns-server sockets and dispatch: the relay manager that binds the DNS listeners, dispatches to handlers, and owns the per-slot relay sockets and downstream queues.
Package server owns the shrewdns-server sockets and dispatch: the relay manager that binds the DNS listeners, dispatches to handlers, and owns the per-slot relay sockets and downstream queues.
statsledger
Package statsledger provides a bounded, sliding-window ledger of events.
Package statsledger provides a bounded, sliding-window ledger of events.
timeouttune
Package timeouttune adapts a request or probe timeout to the round-trip times a handler actually observes.
Package timeouttune adapts a request or probe timeout to the round-trip times a handler actually observes.
util
Package slotkey parses the canonical ShrewDNS slot-key syntax shared by the slot-key environment variables (SHREWDNS_KEY_SLOTN) and the local tools' --key flags.
Package slotkey parses the canonical ShrewDNS slot-key syntax shared by the slot-key environment variables (SHREWDNS_KEY_SLOTN) and the local tools' --key flags.
webcontrol
Package control provides the shared HTTP control interface.
Package control provides the shared HTTP control interface.
Package wireshark holds the ShrewDNS Wireshark Lua postdissector.
Package wireshark holds the ShrewDNS Wireshark Lua postdissector.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL