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.
# Add router dns

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

Start DNSMASQ on boot and launch it:

sudo brew services start dnsmasq


dig @

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: and hit OK > Apply.