A stunning, glassmorphism-themed Windows desktop application that blocks websites by safely modifying the C:\Windows\System32\drivers\etc\hosts file. Built with Flask, modern HTML/CSS/JS, and a premium security dashboard aesthetic.
- ๐จ Glassmorphism UI โ Premium dark-themed dashboard with animated gradient orbs, frosted-glass cards, and the Outfit font
- ๐ Safe Hosts File Editing โ Uses unique
# NETGUARD-START/# NETGUARD-ENDtags so it never touches your manual entries - ๐ง Smart Domain Cleaner โ Paste any URL (even with paths, query params, or subdomains) and NetGuard extracts the clean hostname
- ๐ Subdomain Auto-Expansion โ Blocking
youtube.comautomatically blockswww.,m.,music.,studio., andyoutu.be - โก Quick Presets โ Block entire categories (Social Media, Gaming, Entertainment) with one click
- ๐ DNS Cache Invalidation โ Automatically runs
ipconfig /flushdnsafter every change - ๐ Automatic Backups โ Creates timestamped backups before every modification
โ ๏ธ Admin Detection โ Prominent red warning banner if not running as Administrator
- Windows 10/11
- Python 3.10 or higher
- Administrator privileges (required to modify the hosts file)
pip install flask- Press
Win + S, type cmd - Right-click Command Prompt โ Run as administrator
- Navigate to the NetGuard folder:
cd "D:\Cyber Project\NEW\NetGuard"
- Launch the app:
python app.py
- Open your browser to http://127.0.0.1:5000
If you forget to run as Administrator, the UI will show a prominent red warning banner.
Modern browsers can bypass the hosts file entirely by using DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT). When Secure DNS is enabled, your browser sends DNS queries directly to external resolvers (like Google 8.8.8.8 or Cloudflare 1.1.1.1), completely skipping the local hosts file.
This means NetGuard will not work unless you disable Secure DNS in your browser.
DNS-over-HTTPS is a protocol that encrypts DNS queries by sending them over HTTPS instead of the traditional unencrypted UDP port 53. While this improves privacy by preventing ISP snooping, it also means:
- Your browser ignores the local
hostsfile - All DNS resolution happens through external servers
- Hosts-based blockers like NetGuard become completely ineffective
- Click the โฎ menu โ Settings
- Navigate to Privacy and security โ Security
- Scroll down to Advanced
- Toggle "Use Secure DNS" to OFF
- Restart Chrome
Alternatively, go to: chrome://settings/security and disable Secure DNS.
- Click the โฏ menu โ Settings
- Navigate to Privacy, search, and services
- Scroll down to Security
- Toggle "Use secure DNS to specify how names are resolved" to OFF
- Restart Edge
Alternatively, go to: edge://settings/privacy and disable Secure DNS.
- Click the โฐ menu โ Settings
- Navigate to Privacy & Security
- Scroll to the very bottom โ DNS over HTTPS
- Set it to "Off" or "Default Protection" (not "Max Protection")
- Restart Firefox
Alternatively, go to: about:preferences#privacy and find the DNS over HTTPS section.
If you want to disable DoH at the OS level:
- Open Settings โ Network & Internet โ Wi-Fi (or Ethernet)
- Click on your active connection โ DNS server assignment โ Edit
- Turn off "DNS over HTTPS"
- Click Save
After disabling, visit these URLs to confirm:
- Chrome:
chrome://net-internals/#dnsโ Check "Secure DNS" status - Firefox:
about:networking#dnsโ Verify DoH is not active - Online test: Visit https://1.1.1.1/help โ "Using DNS over HTTPS (DoH)" should show No
NetGuard/
โโโ app.py # Flask application & API routes
โโโ hosts_manager.py # Hosts file read/write logic
โโโ domain_cleaner.py # URL parsing & subdomain expansion
โโโ presets.py # Preset category definitions
โโโ templates/
โ โโโ index.html # Main dashboard HTML
โโโ static/
โ โโโ css/
โ โ โโโ style.css # Glassmorphism stylesheet
โ โโโ js/
โ โโโ app.js # Frontend application logic
โโโ run.bat # One-click launcher (run as admin!)
โโโ README.md # This file
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Serve the dashboard |
GET |
/api/status |
Get current blocking status & admin state |
GET |
/api/presets |
Get all available presets |
POST |
/api/block |
Block domain(s) โ body: { "domains": ["example.com"] } |
POST |
/api/unblock |
Unblock domain(s) โ body: { "domains": ["example.com"] } |
POST |
/api/unblock-all |
Remove all NetGuard blocks |
POST |
/api/preset/<key>/apply |
Apply a preset by key (social_media, gaming, entertainment) |
Input: https://www.facebook.com/user/profile?q=test
Output: facebook.com
Input: www.youtube.com/watch?v=abc123
Output: youtube.com + www.youtube.com + m.youtube.com + music.youtube.com + ...
NetGuard only modifies lines between these markers:
# NETGUARD-START
127.0.0.1 facebook.com
::1 facebook.com
127.0.0.1 www.facebook.com
::1 www.facebook.com
# NETGUARD-END
Anything outside these tags is never touched. Your manual entries are safe.
Every modification creates a backup:
C:\Windows\System32\drivers\etc\hosts.netguard_backup_20260404_143022
- Admin Check: Uses
ctypes.windll.shell32.IsUserAnAdmin()to verify privileges - Binary Writing: Opens hosts file in
wbmode with explicit\r\nline endings to prevent Windows file corruption - Atomic-ish Writes: Backs up before modifying; restores on failure
- Solution: Run your terminal as Administrator (see Quick Start)
- Solution: Disable Secure DNS / DoH in your browser (see section above)
- Solution: Restore from the latest
.netguard_backup_*file in the same directory
- Solution: Ensure the Flask server is running (check terminal for
Running on http://127.0.0.1:5000)
- Solution: Manually run
ipconfig /flushdnsin an admin terminal
Blocks: Facebook, Instagram, Twitter/X, TikTok, Snapchat, Pinterest, LinkedIn, Reddit, Tumblr, Threads, Mastodon, Bluesky
Blocks: Steam, Steam Community, Epic Games, EA, Ubisoft, Battle.net, GOG, Origin, Riot Games, Roblox, Minecraft, Twitch, Discord
Blocks: YouTube, Netflix, Spotify, Hulu, Disney+, Prime Video, HBO Max, Crunchyroll, SoundCloud, Vimeo, Twitch, TikTok
MIT License. See LICENSE for details.
- Font: Outfit by Google Fonts
- Icons: Material Icons Round by Google
- Framework: Flask by Pallets
Note: This tool is designed for personal productivity and parental control. Always respect others' privacy and terms of service.