Skip to content

Instantly share code, notes, and snippets.

@shvchk
Last active October 19, 2021 03:16
Show Gist options
  • Save shvchk/f5cade6e1544eedac27776c2afd674e1 to your computer and use it in GitHub Desktop.
Save shvchk/f5cade6e1544eedac27776c2afd674e1 to your computer and use it in GitHub Desktop.
Configure Stubby on routers with Padavan based firmware
#! /usr/bin/env sh
mkdir /etc/storage/stubby
cat << EOF > /etc/storage/stubby/stubby.yml
resolution_type: GETDNS_RESOLUTION_STUB
round_robin_upstreams: 1
appdata_dir: "/var/lib/stubby"
# tls_authentication: GETDNS_AUTHENTICATION_REQUIRED
tls_query_padding_blocksize: 128
edns_client_subnet_private: 1
idle_timeout: 9000
listen_addresses:
- 127.0.0.1@65053
- 0::1@65053
dns_transport_list:
- GETDNS_TRANSPORT_TLS
upstream_recursive_servers:
- address_data: 1.1.1.1
tls_auth_name: "cloudflare-dns.com"
- address_data: 1.0.0.1
tls_auth_name: "cloudflare-dns.com"
- address_data: 8.8.8.8
tls_auth_name: "dns.google"
- address_data: 8.8.4.4
tls_auth_name: "dns.google"
EOF
chmod -R u=rwX,go=rX /etc/storage/stubby
echo 'server=127.0.0.1#65053' > /etc/storage/dnsmasq/dnsmasq.servers
[ -n "`nvram get ntp_server0`" ] && \
echo "server=/`nvram get ntp_server0`/1.1.1.1" >> /etc/storage/dnsmasq/dnsmasq.servers
[ -n "`nvram get ntp_server1`" ] && \
echo "server=/`nvram get ntp_server1`/1.1.1.1" >> /etc/storage/dnsmasq/dnsmasq.servers
echo -e '\n''no-resolv''\n''proxy-dnssec' >> /etc/storage/dnsmasq/dnsmasq.conf
echo -e '\n''/usr/sbin/stubby_start.sh' >> /etc/storage/started_script.sh
nvram set wan_dnsenable_x=0
nvram set wan_dns1_x=127.0.0.1
nvram set wan_dns2_x=
nvram set wan_dns3_x=
nvram commit
mtd_storage.sh save
stubby_start.sh
echo 'Done!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment