File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ - name : Ensure Cloudflare DNS is used
2+ query : SELECT 1 FROM dns_resolvers WHERE type='nameserver' AND address = '1.1.1.1'
3+ critical : true
4+ description : This device is not using Cloudflare DNS, which may lead to slower DNS resolution times and potential security risks.
5+ resolution : Change the DNS resolver to Cloudflare at 1.1.1.1
6+ platform : darwin
7+ run_script :
8+ path : ../lib/update_dns.sh
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ PRIMARY_DNS=" 1.1.1.1"
4+ SECONDARY_DNS=" 1.0.0.1"
5+
6+ # Get the name of the current active network interface
7+ ACTIVE_INTERFACE=$( networksetup -listallnetworkservices | grep -v " An asterisk" | sed -n ' 2p' )
8+
9+ # Check if we got a valid interface
10+ if [ -z " $ACTIVE_INTERFACE " ]; then
11+ echo " Error: Could not determine active network interface."
12+ echo " Available interfaces:"
13+ networksetup -listallnetworkservices | grep -v " An asterisk"
14+ exit 1
15+ fi
16+
17+ echo " Setting DNS servers for $ACTIVE_INTERFACE to $PRIMARY_DNS and $SECONDARY_DNS ..."
18+
19+ # Set the DNS servers for the active interface
20+ sudo networksetup -setdnsservers " $ACTIVE_INTERFACE " $PRIMARY_DNS $SECONDARY_DNS
21+
22+ # Flush the DNS cache
23+ sudo dscacheutil -flushcache
24+ sudo killall -HUP mDNSResponder
25+
26+ echo " DNS servers updated successfully!"
27+ echo " Current DNS settings:"
28+ networksetup -getdnsservers " $ACTIVE_INTERFACE "
You can’t perform that action at this time.
0 commit comments