Files
scripts/sergey-fix1.ps1

30 lines
3.1 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# sergey-fix1.ps1 — правка 16.09: DNS всегда в AdGuard независимо от VPN (NRPT), сброс кэша, диагностика Яндекс.Браузера
# Запуск от администратора: irm https://git.dttb.ru/oleg/scripts/raw/branch/main/sergey-fix1.ps1 | iex
[Console]::OutputEncoding=[Text.Encoding]::UTF8
$ErrorActionPreference='Continue'
$DNS = @('94.140.14.49','94.140.14.59')
function Step($t){ Write-Host "`n=== $t ===" -ForegroundColor Cyan }
Step "1. NRPT: все имена → AdGuard (действует и внутри VPN)"
Get-DnsClientNrptRule -EA SilentlyContinue | Where-Object { $_.Comment -eq 'sergey-filter' } | ForEach-Object { Remove-DnsClientNrptRule -Name $_.Name -Force }
try { Add-DnsClientNrptRule -Namespace '.' -NameServers $DNS -Comment 'sergey-filter' -EA Stop | Out-Null; Write-Host " правило '.' → $($DNS -join ', ') добавлено" } catch { Write-Host " ОШИБКА NRPT: $($_.Exception.Message)" -ForegroundColor Red }
Get-DnsClientNrptRule | Where-Object Comment -eq 'sergey-filter' | Format-Table Namespace,NameServers -AutoSize | Out-String | Write-Host
Step "2. DoH-шаблоны и политика"
Get-DnsClientDohServerAddress | Where-Object { $_.ServerAddress -like '94.140.*' } | Format-Table ServerAddress,AllowFallbackToUdp,DohTemplate -AutoSize | Out-String | Write-Host
Write-Host " DoHPolicy = $((Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient' -EA SilentlyContinue).DoHPolicy)"
Step "3. Сброс кэша DNS"
Clear-DnsClientCache; ipconfig /flushdns | Out-Null; Write-Host " сброшен"
Step "4. Яндекс.Браузер: политики и свой DoH"
(Get-ItemProperty 'HKLM:\SOFTWARE\Policies\YandexBrowser' -EA SilentlyContinue).PSObject.Properties | Where-Object { $_.Name -notmatch '^PS' } | ForEach-Object { Write-Host " policy $($_.Name)=$($_.Value)" }
$ls = Get-ChildItem 'C:\Users\*\AppData\Local\Yandex\YandexBrowser\User Data\Local State' -EA SilentlyContinue
foreach($f in $ls){ try { $j = Get-Content $f.FullName -Raw | ConvertFrom-Json; Write-Host " $($f.FullName.Split('\')[2]): dns_over_https=$($j.dns_over_https | ConvertTo-Json -Compress)" } catch {} }
$yb = Get-Process browser -EA SilentlyContinue | Measure-Object | Select-Object -Expand Count; Write-Host " процессов Яндекс.Браузера: $yb (политики применяются при перезапуске браузера)"
Step "5. Проверка резолва"
foreach($d in 'pornhub.com','xvideos.com','eromassage-msk.ru','t.me','ya.ru','web.max.ru'){ try { $r=(Resolve-DnsName $d -Type A -EA Stop | Where-Object IPAddress | Select-Object -First 1).IPAddress } catch { $r='NX/err' }; Write-Host (" {0,-20} -> {1}" -f $d,$r) }
Write-Host "`nОжидание: pornhub/xvideos → 94.140.14.35, eromassage/t.me → 0.0.0.0, ya.ru и web.max.ru → реальный IP." -ForegroundColor Green
Write-Host "Дальше: полностью закрыть и открыть Яндекс.Браузер, затем проверить с включённым VPN." -ForegroundColor Green