DNSwitch is a small Go-based utility for managing and switching system DNS settings across multiple operating systems.
DNSwitch simplifies switching DNS servers temporarily or permanently. The project is designed to be cross-platform (Windows, Linux, macOS) and separates DNS logic from platform-specific network operations.
- Manage system DNS settings
- Cross-platform support (Windows, Linux, macOS)
- Load and apply custom DNS configurations
- Simple, modular structure for easy extension
main.go: program entry point.go.mod: Go module and dependency management.dns/: DNS-related logicdns.go: public interfaces and general DNS functions.system.go: system-level DNS application logic that calls platform-specific implementations.custom_dns.go: read/write custom DNS configuration files.utils.go: helper utilities related to DNS.vars.go: global and default variables.custom_dns.json: example or default custom DNS configuration (dns/custom_dns.json).
network/: platform-specific network implementationswindows.go,linux.go,darwin.go: platform-specific routines to apply network/DNS changes.network.go: public interface for network operations.
pkg/: utility packagesinput.go: input/argument handling (e.g., CLI args or interactive input).
- The program reads configuration or user input to determine which DNS settings to apply.
- The
dnslayer manages DNS details and delegates platform-specific work to thenetworklayer. - Custom configurations can be provided via
dns/custom_dns.jsonor interactive input.
- Example configuration file: dns/custom_dns.json. It can contain a list of DNS servers, priorities, and optional labels.
To build the binary:
go build -o DNSwitch main.goTo run directly during development:
go run main.goCommand-line arguments and runtime behavior are defined in the code; consult pkg/input.go for how inputs are parsed.
- To add support for a new OS or improve DNS behavior, extend the appropriate files in
network/anddns/. - Implementations should follow the interfaces in
dns.goandnetwork.go.
- Please open issues on the repository for bugs or feature requests.
No license file is included in this repository. Add a suitable license if you plan to publish or distribute the project.
If you want, I can add: CLI usage examples, a concrete dns/custom_dns.json sample, or a short usage guide. Tell me which you'd like next.