Created
September 22, 2025 21:22
-
-
Save Apurer/2c2ac900461a0e92057609e7f74502b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Fix-DNS.ps1 | |
| # Run this script in PowerShell as Administrator | |
| Write-Host "=== Flushing DNS Cache ===" | |
| Clear-DnsClientCache | |
| Write-Host "=== Releasing IP Address ===" | |
| ipconfig /release | |
| Write-Host "=== Renewing IP Address ===" | |
| ipconfig /renew | |
| Write-Host "=== Resetting Winsock ===" | |
| netsh winsock reset | |
| Write-Host "=== Resetting TCP/IP stack ===" | |
| netsh int ip reset | |
| # Get active network adapter | |
| $adapter = Get-NetAdapter | Where-Object { $_.Status -eq "Up" } | Select-Object -First 1 | |
| if ($adapter) { | |
| Write-Host "=== Setting DNS servers on adapter $($adapter.Name) ===" | |
| # Google DNS (8.8.8.8 & 8.8.4.4) - change to Cloudflare if you like (1.1.1.1 & 1.0.0.1) | |
| Set-DnsClientServerAddress -InterfaceAlias $adapter.Name -ServerAddresses ("8.8.8.8","8.8.4.4") | |
| } else { | |
| Write-Host "No active network adapter found!" | |
| } | |
| Write-Host "=== Verifying DNS resolution ===" | |
| try { | |
| Resolve-DnsName google.com | Select-Object -First 1 | |
| } catch { | |
| Write-Host "DNS resolution failed. Please reboot and try again." | |
| } | |
| Write-Host "=== Done! Please reboot your computer to apply all changes. ===" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment