Skip to content

NetSwitch is a comprehensive DNS management application built with Python and CustomTkinter that provides an easy-to-use interface for switching between different DNS providers, managing network adapters, and optimizing internet connectivity on Windows systems.

License

Notifications You must be signed in to change notification settings

KernFerm/net-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

NetSwitch v1.1.1

🌐 A modern, secure DNS management tool for Windows with an intuitive GUI

NetSwitch Python Platform License

πŸ” Overview

NetSwitch is a comprehensive DNS management application built with Python and CustomTkinter that provides an easy-to-use interface for switching between different DNS providers, managing network adapters, and optimizing internet connectivity on Windows systems.

Why NetSwitch?

  • 🎨 Modern UI: Beautiful, responsive interface with light/dark theme support
  • πŸ”’ Enhanced Security: Comprehensive input sanitization and validation
  • ⚑ Performance Focused: Built-in DNS speed testing and optimization
  • 🌐 IPv4 & IPv6 Support: Full support for both IP protocols
  • πŸ›‘οΈ Safe Operations: Prevents command injection and malicious inputs
  • 🎯 User-Friendly: Intuitive design inspired by DNS Jumper

✨ Features

Core Functionality

  • πŸ”„ DNS Switching: Quickly switch between popular DNS providers
  • πŸ“‘ Network Adapter Detection: Automatic detection of available network interfaces
  • 🧹 DNS Cache Management: Flush DNS cache with one click
  • ⚑ Speed Testing: Find the fastest DNS server for your connection
  • πŸŽ›οΈ Custom DNS: Support for custom DNS server configurations

Security & Validation

  • πŸ›‘οΈ Input Sanitization: Comprehensive sanitization of all user inputs
  • βœ… IP Validation: Enhanced IPv4 and IPv6 address validation
  • 🚫 Injection Prevention: Protection against command injection attacks
  • ⏱️ Timeout Protection: Prevents hanging operations with timeout controls
  • πŸ” Error Handling: Robust error handling with user-friendly messages

User Interface

  • 🎨 Modern Design: Clean, professional interface using CustomTkinter
  • πŸŒ™ Theme Support: Light and dark mode themes
  • 🟣 Custom Branding: Purple NetSwitch branding with light grey background
  • πŸ”΄ Clear Actions: Red exit button for clear visual distinction
  • πŸ“Š Status Updates: Real-time status bar with operation feedback

Advanced Features

  • 🌐 IPv6 Support: Full IPv6 DNS configuration support
  • πŸ”§ Options Panel: Customizable settings for themes and display
  • 🧡 Threaded Operations: Non-blocking operations for smooth user experience
  • πŸ’Ύ Persistent Settings: Remember user preferences between sessions
  • πŸ“‹ Multiple Adapters: Support for multiple network interfaces

πŸ–ΌοΈ Screenshots

Main Interface

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ NetSwitch                                      Exit β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                🌐 NetSwitch                         β”‚
β”‚                                                     β”‚
β”‚ Select Network Adapter                              β”‚
β”‚ [All Network Adapters           β–Ό]                 β”‚
β”‚                                                     β”‚
β”‚ Choose a DNS Server                                 β”‚
β”‚ [AU - Cloudflare (1.1.1.1, 1.0.0.1) β–Ό]           β”‚
β”‚                                                     β”‚
β”‚ [πŸ’Ύ Apply DNS] [⚑ Fastest DNS] [🧹 Flush DNS] [βš™οΈ Options] β”‚
β”‚                                                     β”‚
β”‚ Ready.                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Custom DNS Configuration

When "Custom..." is selected, additional fields appear for manual DNS entry with IPv6 support.

πŸš€ Installation

Prerequisites

  • Windows 10/11 (Required for netsh commands)
  • Python 3.11.9+
  • Administrator privileges (for DNS changes)

Method 1: Direct Installation

# Clone or download the repository
git clone https://github.com/kernferm/netswitch.git
cd netswitch

# Install dependencies
pip install customtkinter

# Run the application
python net-switch.py

Method 2: Requirements File

# Install from requirements.txt (if available)
pip install -r requirements.txt
python net-switch.py

Dependencies

  • customtkinter>=5.2.2 - Modern UI framework
  • tkinter - Built-in GUI library (included with Python)

πŸ“– Usage

Basic Operations

1. Changing DNS Servers

  1. Select Network Adapter: Choose your network interface from the dropdown
  2. Choose DNS Provider: Select from Cloudflare, Google, Quad9, or Custom
  3. Apply Changes: Click "πŸ’Ύ Apply DNS" to apply the settings
  4. Verify: Check the status bar for confirmation

2. Using Custom DNS

  1. Select "Custom..." from the DNS dropdown
  2. Enter primary and secondary DNS addresses
  3. Optionally enable IPv6 and enter IPv6 DNS addresses
  4. Click "πŸ’Ύ Apply DNS" to apply

3. Finding Fastest DNS

  1. Click "⚑ Fastest DNS" button
  2. Wait for speed testing to complete
  3. Review results in the popup dialog
  4. Optionally apply the fastest DNS found

4. Flushing DNS Cache

  1. Click "🧹 Flush DNS" button
  2. Wait for operation to complete
  3. Check status bar for confirmation

Advanced Settings

Theme Configuration

  1. Click "βš™οΈ Options" button
  2. Select Light or Dark theme
  3. Toggle status bar visibility
  4. Click "Save" to apply changes

IPv6 Configuration

  1. Select "Custom..." DNS option
  2. Check "Use IPv6 DNS" checkbox
  3. Enter IPv6 DNS addresses in the format: 2001:4860:4860::8888
  4. Apply settings as usual

🌐 DNS Providers

Included Providers

Provider Primary DNS Secondary DNS Features
Cloudflare 1.1.1.1 1.0.0.1 Fast, privacy-focused, global
Google 8.8.8.8 8.8.4.4 Reliable, widely used, feature-rich
Quad9 9.9.9.9 149.112.112.112 Security-focused, malware blocking
Custom User-defined User-defined Your choice of DNS servers

IPv6 Support

All providers support IPv6 DNS servers when using custom configuration:

  • Cloudflare IPv6: 2606:4700:4700::1111, 2606:4700:4700::1001
  • Google IPv6: 2001:4860:4860::8888, 2001:4860:4860::8844
  • Quad9 IPv6: 2620:fe::fe, 2620:fe::9

πŸ”’ Security Features

Input Sanitization

  • String Sanitization: Removes control characters and limits length
  • Network Adapter Validation: Validates adapter names against injection
  • Command Argument Sanitization: Cleans command-line arguments
  • DNS Server Validation: Ensures only valid DNS selections

Validation Systems

  • IPv4 Validation: Comprehensive IPv4 address validation
  • IPv6 Validation: Support for IPv6 address formats
  • Length Limits: Prevents buffer overflow attacks
  • Character Filtering: Removes dangerous characters

Protection Mechanisms

  • Command Injection Prevention: Sanitizes all subprocess arguments
  • Timeout Protection: Prevents hanging operations
  • Error Handling: Safe error handling with sanitized messages
  • Safe Defaults: Fallback to safe values on validation failure

πŸ’» Technical Requirements

System Requirements

  • Operating System: Windows 10/11
  • Python Version: 3.11.9 or higher
  • Memory: 50MB RAM minimum
  • Storage: 10MB disk space
  • Network: Internet connection for DNS testing

Permissions

  • Administrator Rights: Required for changing DNS settings
  • Network Access: Needed for DNS testing and validation
  • Registry Access: For persistent settings (future feature)

πŸ—οΈ Architecture

Project Structure

NetSwitch-v1.0/
β”œβ”€β”€ net-switch.py          # Main application file
β”œβ”€β”€ README.md             # This documentation
└── requirements.txt      # Python dependencies (optional)

Code Organization

# Input Sanitization Functions
β”œβ”€β”€ sanitize_string()              # General string sanitization
β”œβ”€β”€ sanitize_network_adapter_name() # Network adapter validation
β”œβ”€β”€ validate_dns_server_name()     # DNS server selection validation
└── sanitize_command_args()        # Command argument sanitization

# Core DNS Functions
β”œβ”€β”€ is_valid_ip()                  # IPv4 validation
β”œβ”€β”€ is_valid_ipv6()                # IPv6 validation
β”œβ”€β”€ apply_dns()                    # DNS application logic
β”œβ”€β”€ flush_dns()                    # DNS cache flushing
β”œβ”€β”€ test_dns()                     # DNS speed testing
└── find_fastest_dns()             # Fastest DNS detection

# GUI Components
└── NetSwitchApp                   # Main application class
    β”œβ”€β”€ __init__()                 # UI initialization
    β”œβ”€β”€ get_adapters()             # Network adapter detection
    β”œβ”€β”€ show_options()             # Options dialog
    β”œβ”€β”€ apply_dns_action()         # DNS application handler
    β”œβ”€β”€ flush_dns_action()         # DNS flush handler
    └── fastest_dns_action()       # Fastest DNS handler

Design Patterns

  • MVC Pattern: Separation of UI, logic, and data
  • Singleton Pattern: Single application instance
  • Observer Pattern: Status updates and threading
  • Factory Pattern: DNS provider configurations

πŸ”§ Troubleshooting

Common Issues

"Access Denied" Error

Cause: Insufficient permissions to modify DNS settings Solution:

  1. Right-click on Command Prompt/PowerShell
  2. Select "Run as Administrator"
  3. Navigate to NetSwitch directory
  4. Run python net-switch.py

DNS Changes Not Applied

Cause: Network adapter name mismatch Solution:

  1. Select correct network adapter from dropdown
  2. Try "All Network Adapters" option
  3. Verify adapter is enabled in Network Settings

Application Won't Start

Cause: Missing dependencies or Python version Solution:

# Check Python version
python --version

# Install/upgrade customtkinter
pip install --upgrade customtkinter

# Run with UTF-8 encoding
python -X utf8 net-switch.py

Unicode/Encoding Errors

Cause: System encoding issues with emojis Solution:

# Run with explicit UTF-8 encoding
python -X utf8 net-switch.py

# Or set environment variable
set PYTHONIOENCODING=utf-8
python net-switch.py

Error Messages

Error Meaning Solution
"Invalid Input" IP address format error Check IP address format
"Command timed out" Network operation timeout Check internet connection
"Failed to apply DNS" System-level error Run as administrator
"No DNS servers reachable" Network connectivity issue Check network connection

Performance Tips

  • Network Speed: Use ethernet connection for fastest results
  • Firewall: Ensure DNS traffic isn't blocked
  • Antivirus: Add NetSwitch to exclusions if needed
  • Background Apps: Close unnecessary network applications

🀝 Contributing

We welcome contributions to NetSwitch! Here's how you can help:

Development Setup

# Clone the repository
git clone https://github.com/kernferm/netswitch.git
cd netswitch

# Create virtual environment
python -m venv netswitch-env
netswitch-env\Scripts\activate

# Install dependencies
pip install customtkinter

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Test your changes thoroughly
  4. Commit with clear messages: git commit -m "Add feature description"
  5. Push to your fork: git push origin feature-name
  6. Submit a pull request

Areas for Contribution

  • 🌐 Additional DNS providers
  • πŸ”§ Enhanced IPv6 support
  • 🎨 UI/UX improvements
  • πŸ”’ Security enhancements
  • πŸ“š Documentation updates
  • πŸ› Bug fixes and testing

Code Standards

  • PEP 8: Follow Python style guidelines
  • Type Hints: Use type annotations where possible
  • Documentation: Include docstrings for functions
  • Security: Maintain input sanitization standards
  • Testing: Test on multiple Windows versions

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

Copyright 2025 NetSwitch Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

πŸ™ Acknowledgments

  • CustomTkinter - Modern UI framework
  • DNS Jumper - Inspiration for UI design
  • Python Community - Excellent documentation and support
  • Contributors - Everyone who helps improve NetSwitch

πŸ“ž Support


Made with ❀️ by BubblesTheDev

NetSwitch v1.1.1 - Simplifying DNS management for Windows users

About

NetSwitch is a comprehensive DNS management application built with Python and CustomTkinter that provides an easy-to-use interface for switching between different DNS providers, managing network adapters, and optimizing internet connectivity on Windows systems.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages