Stubby DNS Daemon: DNS-over-TLS (DoT) Client

๐Ÿ’ก Stubby DNS Daemon: DNS-over-TLS (DoT) Client โ€” Executive Summary

Technical architectural analysis, practical configuration manifests, and deployment instructions for Stubby DNS Daemon: DNS-over-TLS (DoT) Client.

๐Ÿ“‘ Table of Contents

Architecture

Architecture & System Flow Diagram
Architecture & System Flow
Pan & Zoom

Installation

Mac

bash
brew install stubby jq yq

Exec

Configuration

bash
vi /opt/homebrew/etc/stubby/stubby.yml

Run as Daemon

bash
sudo brew services start stubby
sudo brew services stop stubby

Run with Cmd

bash
sudo stubby -l &
sudo kill $(pidof stubby)

Features


stubby endpoint: 127.0.0.1:53

bash
sudo lsof -i :53

Specify Stubby DNS at the interface level

  • Setting โ†’ TCP/IP โ†’ DNS โ†’ Register 127.0.0.1
bash
DNS=127.0.0.1
DEFAULT_IFACE=$(route -n get default | awk '/interface: / {print $2}')
INTERFACE=$(networksetup -listnetworkserviceorder | grep -B 1 "Device: $DEFAULT_IFACE" | head -n 1 | sed 's/.*) //')
if [ -z "$INTERFACE" ]; then
    echo "ํ™œ์„ฑ ๋„คํŠธ์›Œํฌ ์„œ๋น„์Šค๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
else
    sudo networksetup -setdnsservers "$INTERFACE" $DNS
    echo "์„ฑ๊ณต: [$INTERFACE]์˜ DNS๋ฅผ ${DNS}๋กœ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค."
fi

Resolver configuration: Specify domain branch Stubby DNS

bash
domain=hanacloudia.com
sudo mkdir -p /etc/resolver
cat <<EOF | sudo tee /etc/resolver/$domain
nameserver 127.0.0.1
EOF
scutil --dns

Enable DoT (v1)

  • DoT verification:
bash
dns_domain=dns.okestro.hanacloudia.com
dns_ip=10.255.57.88
cafile=~/Downloads/ca.crt
cp $cafile /opt/homebrew/etc/stubby/ca.crt

export upstream_recursive_servers=$(cat << EOF | yq -pyaml -ojson | jq '.temps'
temps:
  - address_data: $dns_ip
    tls_auth_name: "$dns_domain"
    tls_port: 853
    tls_ca_file: "./ca.crt"
EOF
)
yq -i ".upstream_recursive_servers = $upstream_recursive_servers" \
  /opt/homebrew/etc/stubby/stubby.yml

sudo brew services restart stubby

Enable DoT (v2)

bash
#dns์†Œ์† k8s์—์„œ
pubkey_sha256=$(kubectl get secret -n management-system dns.okestro.hanacloudia.com-tls -o=jsonpath='{.data.tls\.crt}' | base64 -d | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64)

dns_domain=dns.okestro.hanacloudia.com
dns_ip=10.255.57.88
cafile=~/Downloads/ca.crt
cp $cafile /opt/homebrew/etc/stubby/ca.crt

export upstream_recursive_servers=$(cat << EOF | yq -pyaml -ojson | jq '.temps'
temps:
  - address_data: $dns_ip
    tls_auth_name: "$dns_domain"
    tls_port: 853
    tls_pubkey_pinset:
      - digest: "sha256"
        value: "$pubkey_sha256"
EOF
)
yq -i ".upstream_recursive_servers = $upstream_recursive_servers" \
  /opt/homebrew/etc/stubby/stubby.yml

sudo brew services restart stubby

Delete existing DNS cache

bash
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *