Add files via upload
This commit is contained in:
1 parent
ef745e44bb
commit
6580f84357
7 files changed
+823
-2
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
# Получаем default gateway (IPv4)
|
||||
$gateway = Get-NetRoute `
|
||||
-DestinationPrefix "0.0.0.0/0" `
|
||||
| Sort-Object RouteMetric `
|
||||
| Select-Object -First 1 -ExpandProperty NextHop
|
||||
|
||||
if (-not $gateway) {
|
||||
Write-Error "Не удалось определить default gateway"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Default gateway: $gateway"
|
||||
|
||||
# Читаем адреса из stdin
|
||||
$input | ForEach-Object {
|
||||
$addr = $_.Trim()
|
||||
if ($addr -eq "") { return }
|
||||
|
||||
Write-Host "Добавляем маршрут к $addr через $gateway"
|
||||
|
||||
New-NetRoute `
|
||||
-DestinationPrefix "$addr/32" `
|
||||
-NextHop $gateway `
|
||||
-PolicyStore ActiveStore `
|
||||
-ErrorAction Stop
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user