Skip to content

Based on yggland dns datas, this script allow you to directly update your macos DNS by selecting a service and a provider.

Notifications You must be signed in to change notification settings

JimmyMtl/macos-dns-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛜🍎 macOS DNS Switcher (Python)

A command-line utility to programmatically change the DNS settings of your macOS network services using Python and networksetup. It is based on Yggland datas.


✨ Features

  • Choose from pre-configured public DNS providers:
    • OpenDNS
    • Cloudflare
    • Quad9
    • Or reset to default
  • Supports both IPv4 and IPv6 addresses
  • Configure one or multiple network services (e.g., Wi-Fi, Ethernet, iPhone USB)
  • Easily reset DNS to DHCP-provided values

🛠 Requirements

  • macOS
  • Python 3.7+
  • Admin privileges (sudo required to change network settings)

🚀 Installation

You can install via pip (if published on PyPI):

pip install macos-dns-switcher

Or install from source:

git clone https://github.com/JimmyMtl/macos-dns-switcher.git
cd macos-dns-switcher
pip install .

▶️ Usage

Run the CLI tool with:

sudo mdns

🧭 Interactive Flow

  1. Select one or more network services (e.g., Wi-Fi, Ethernet)
  2. Choose a DNS provider:
    • 0 – Default (reset to DHCP)
    • 1 – OpenDNS
    • 2 – Cloudflare
    • 3 – Quad9
  3. The tool applies the selected DNS settings to all selected services

🔍 Verifying DNS Settings

To confirm the DNS settings applied to a service:

networksetup -getdnsservers "Wi-Fi"

Replace "Wi-Fi" with your actual service name if different.


🧼 Reset DNS to Default

To remove custom DNS settings and restore DHCP:

sudo mdns

Then:

  • Select the target service(s)
  • Choose option 0 to reset

🛡️ Notes & Warnings

  • Only works on macOS via networksetup
  • DNS settings apply system-wide and may not persist if overwritten by VPNs or profiles

📄 License

MIT License


🙋 Support

Feel free to open an issue or submit a pull request if you’d like to contribute or request a feature!

About

Based on yggland dns datas, this script allow you to directly update your macos DNS by selecting a service and a provider.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages