A modern, web-based interface to manage and switch between DNS over HTTPS (DoH) providers for your system. DoH Switcher allows you to easily select, test, and manage your DNS over HTTPS providers through an intuitive interface.
DoH Switcher is a Flask-based web application that helps you manage the DNS over HTTPS service running on your system. It works with Cloudflared as the DoH proxy service and allows you to:
- Switch between different DoH providers with a single click
- Test and compare latency between providers
- Add custom DoH providers
- Backup and restore your configuration
- Monitor service status
The install.sh
script will automatically check for Cloudflared and install it if missing. You can run:
sudo ./install.sh
to install all required components.
If you prefer to install prerequisites manually, see the Prerequisites guide in the Prerequisites folder.
-
Clone this repository and enter the directory:
git clone https://github.com/1999AZZAR/doh-switcher.git cd doh-switcher
-
Run the installer script:
sudo ./install.sh
This will:
- Install the
cdns
alias - Create a Python virtual environment and install dependencies
- Set up and start the systemd service
- Add the
cdns
alias to your shell configuration
- Install the
-
Reload your shell configuration:
source ~/.bashrc # or ~/.zshrc, ~/.profile
-
Launch the Web UI:
cdns
This will silently start the service and open your browser.
To remove DoH Switcher and clean up all components, run:
sudo ./uninstall.sh
This will:
- Stop any running Web UI processes and the systemd service
- Remove the service unit, application files, logs, and alias
- Backup Config: Save your current DoH providers configuration
- Restore Config: Restore a previously saved configuration
- Test All Providers: Measure latency and connectivity of all providers at once
- View Current Provider: See which DoH provider is currently active
- Service Status Monitoring: Check if the Cloudflared service is running
- Switch Providers: Change your DoH provider with a single click
- Test Individual Providers: Check the performance of specific providers
- Add Custom Providers: Add your own DoH provider endpoints
- Delete Custom Providers: Remove custom providers you no longer need
The application performs one type of test:
- Ping Test: Basic connectivity test to the provider's host
The application comes with these pre-configured providers:
- Cloudflare (
https://cloudflare-dns.com/dns-query
) - Google (
https://dns.google/dns-query
) - Quad9 (
https://dns.quad9.net/dns-query
) - NextDNS (
https://dns.nextdns.io
) - AdGuard (
https://dns.adguard.com/dns-query
)
To add a custom DoH provider:
- Enter the provider name in the "Provider Name" field
- Enter the DoH URL in the "DoH URL" field
- Click "Add Provider"
The application will validate the DoH URL before adding it to ensure it's a valid DNS over HTTPS endpoint.
DoH Switcher manages the Cloudflared service by:
- Modifying the systemd service file located at
/etc/systemd/system/cloudflared.service
- Updating the
--upstream
parameter to point to your selected DoH provider - Reloading the systemd daemon and restarting the service
app.py
: Main Flask application and backend logictemplates/index.html
: Web interface templatestatic/css/styles.css
: CSS styling for the web interfacedoh_providers.json
: Saved DoH providers configurationdoh_providers_backup.json
: Backup of the configuration
The application logs all actions to doh_manager.log
for troubleshooting and auditing purposes.
If the service status shows "not running":
- Check the Cloudflared service manually:
sudo systemctl status cloudflared
- Check logs:
sudo journalctl -u cloudflared
- Ensure prerequisites are installed: run
sudo ./install.sh
(it will install Cloudflared if needed), or consult the Prerequisites guide - Try restarting the service:
sudo systemctl restart cloudflared
If providers show "Failed" in testing:
- Check your internet connection
- Verify the DoH provider is operational
- Ensure there's no firewall blocking the connection
The application requires root privileges to modify system service files. Always run with:
sudo python app.py
- The application requires root privileges to modify systemd service files
- All provider URLs are validated before use
- The web interface is only accessible from localhost by default
- Consider setting up basic authentication if exposing to a network
Contributions are welcome! Please feel free to submit a Pull Request.
- This project relies on Cloudflared by Cloudflare
- Thanks to all the public DoH providers for their services
Note: The installer automatically handles Cloudflared setup. Run sudo ./install.sh
, or see the Prerequisites guide for manual installation steps.