CLI tool to switch DNS providers for macOS network services
Project description
🛜🍎 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 (
sudorequired 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
- Select one or more network services (e.g., Wi-Fi, Ethernet)
- Choose a DNS provider:
0– Default (reset to DHCP)1– OpenDNS2– Cloudflare3– Quad9
- 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
0to 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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macos_dns_switcher-1.0.0.tar.gz.
File metadata
- Download URL: macos_dns_switcher-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d3f46beb817ce76cdd43668aea4529b55c7ee572b83f08c8f145a000fe846cb
|
|
| MD5 |
4abc361ca7aac35c9b9bcb85e6a9535f
|
|
| BLAKE2b-256 |
77b1e123258eb1c987f0d930a1d56687970f8091c9251b30fa954275aa5d593c
|
File details
Details for the file macos_dns_switcher-1.0.0-py3-none-any.whl.
File metadata
- Download URL: macos_dns_switcher-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88b064e4efd61fa56658d15af2ed7deb48d30e69b9ff551d05a377f7763867ab
|
|
| MD5 |
d917cc59808b07646a597986f7e731a9
|
|
| BLAKE2b-256 |
7ed2f8b7ca77c3c7d7c9a64fb43b6bfb3660eb48d8d2ee1e80171d3bc1b4b114
|