Skip to main content
 

Faster rendering through a Local DNS Proxy

Unless you're using DNS over HTTP (DoH), you can speed up general DNS requests by running a local DNS proxy, and increase the expiry time of DNS queries. I'll go into this further once I've updated this post for DNSMASQ to do DoH.

The following configuration will speed up browsing in Safari for example.

Install DNSMASQ:

brew install dnsmasq

Load all configs from /etc/local/etc/dnsmasq.d/:

echo "conf-dir=/usr/local/etc/dnsmasq.d,*.conf" | sudo tee —append /usr/local/etc/dnsmasq.conf
mkdir -p /usr/local/etc/dnsmasq.d


Edit /usr/local/etc/dnsmasq.d/proxy.conf:

# Tell dnsmasq to get its DNS servers from this config file only.
no-resolv
# Add router dns
server=192.168.1.1

# cache for 1h
min-cache-ttl = 3600

Start DNSMASQ on boot and launch it:

sudo brew services start dnsmasq

Test:

dig cnn.com @127.0.0.1

Query time should be 0 the second time and an ANSWER SECTION should be returned. If that is the case open System Preferences > Network > Advanced > DNS > +

Enter: 127.0.0.1 and hit OK > Apply.