Skip to content

Jim Christian

Thoughts on tech, tools, and life.

Menu
  • Home
  • About
  • Newsletter
  • Code
  • Notion
Menu

DNS Switcheroo Macro for Keyboard Maestro

Posted on January 29, 2014 by Jim

Occasionally I need to switch out from using DHCP-assigned DNS servers to something else, like Google’s public DNS. To do this normally, I’d have to navigate into my System Preferences, find my Wi-Fi connection, authenticate, type in Google’s public DNS server addresses manually….etc etc.

But why do all that when you can automate it with Keyboard Maestro? This macro is designed to switch to Google’s DNS when invoked, notify you of the change through OS X’s Notification Center, or swap you back to DHCP-assigned DNS if you’re already using Google’s.

km-dns-switcheroo

You may notice that I’m not using a trigger. This is because I’ve recently begun using Ian Sinnot’s Alfred Maestro workflow to invoke my macros directly from Alfred.

km-invoke

Here’s how it works in detail:

  • The first action runs a shell script that gets the current DNS servers being used on the wireless interface and saves the results to a variable called ‘currentDNS’
  • The second action begins an If statement:
    • If the ‘currentDNS’ variable contains ‘8.8.8.8’ (the first of Google’s public DNS servers) then:
      • execute a shell script that clears the manual Google DNS entries*
    • Else set the Wi-Fi DNS servers to 8.8.8.8 and 8.8.4.4
  • The third action checks the current DNS servers and passes the results to a variable called ‘currentDNS2’
  • The fourth action begins an If statement:
    • If the variable ‘currentDNS2’ contains ‘8.8.8.8’ then:
      • Send a notification that I’m using Google’s DNS via Notification Center
    • Else send a notification that I’m using DHCP-assigned DNS via Notification Center

* I’m sure there’s a better method of sending the password through to the shell script, but clear text was all I could get to work, despite noodling around with the Keychain Password action.

km-notify

If you’re interested in importing it into your own Keyboard Maestro Macro library, you can download the DNS Switcheroo KM Macro on GitHub.

Post navigation

← Make It So, Make It So, Make It So
My Automation and Workflows →

Looking for my Prompting Frameworks? They've moved!

January 2014
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Dec   Feb »
  • Building an AI-Powered WordPress Publishing Pipeline with Claude Code
  • From Remote Access to Agentic OS: Two Weeks with Claude Code
  • This Apple Ad Genuinely Makes Me Smile
  • Updating my Claude setup to support remote work
  • Behind the Screens: Optimising My Newsletter With AI
  • December 2025
  • November 2025
  • August 2025
  • July 2025
  • May 2025
  • April 2025
  • February 2025
  • January 2025
  • December 2024
  • June 2024
  • May 2018
  • March 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • July 2017
  • May 2017
  • March 2017
  • December 2015
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • April 2013
  • January 2013
  • June 2012
  • April 2012
  • March 2012
  • January 2012
  • December 2011
  • February 2011
  • November 2010
  • July 2009
  • January 2008

AI AI writing animation apple automation bbc books Claude claude code coding content creation course creation education Estonia Gaming imovie Informatic AI ios iPad ipados launch center pro lecture london mac mcedit MCP microbit minecraft newsletter obsidian os x productivity raspberry pi restrictions scifi software bugs star wars streaming setup​​​​​​​​​​​​​​​​ subscription software tech technology textexpander URL schemes valencia wordpress

  • Bluesky
  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Mail
  • Mastodon
  • Medium
  • YouTube
  • X
Jim Christian
© 2025 Jim Christian | Powered by Minimalist Blog WordPress Theme