Skip to content

Instantly share code, notes, and snippets.

@jjb
Last active January 8, 2021 14:16
Show Gist options
  • Save jjb/e87b40a99ee12e7c1eda15ac35e30023 to your computer and use it in GitHub Desktop.
Save jjb/e87b40a99ee12e7c1eda15ac35e30023 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# save in ~/bin/dns and chmod 755
unless ARGV[0]
print `networksetup -getdnsservers Wi-Fi`
exit
end
servers = case ARGV[0]
when 'adblock'
'176.103.130.130 2a00:5a60::ad1:0ff'
when 'fast'
'1.1.1.1 2606:4700:4700::1111'
when 'default'
'empty'
else
raise ArgumentError, <<~DOCS
usage:
dns [adblock|fast|default] # change dns of Wi-Fi
dns # show current Wi-Fi dns settings
DOCS
end
print `networksetup -setdnsservers Wi-Fi #{servers}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment