<# .AUTHOR Luis Alberto Garcia + Gemini AI .VERSION 2.4 .DESCRIPTION Herramienta de diagnóstico de red: Detección ultra-precisa de Máscara de Red vinculada a la IP activa. #> Clear-Host Write-Host @' ::: ::: :::::::: ::::::::: ::: ::: :::::::: ::::::: :::::::: :::::::: :+: :+: :+: :+: :+: :+: :+:+: :+:+: :+: :+: :+: :+: :+: :+: :+: :+: +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +#+ +:+ +#+ +#+ +:+ +#++:++#: +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#++:++#+ +#+ +#+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ #+#+# #+#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# +#+ ### ### ######## ### ### ### ### ########## ####### ########## ######## '@ -ForegroundColor Blue Write-Host "Midiendo velocidad de internet con 10MB..." -ForegroundColor White # 1. Obtención de datos básicos try { $infoPublica = Invoke-RestMethod -Uri "https://ipinfo.io/json" -ErrorAction Stop } catch { $infoPublica = @{ ip = "Desconectado"; org = "N/A"; city = "N/A"; country = "N/A" } } # Identificar adaptador y configuración de IP de forma precisa $adapter = Get-NetAdapter | Where-Object { $_.Status -eq "Up" } | Select-Object -First 1 $ipConfig = Get-NetIPConfiguration -InterfaceAlias $adapter.Name $ipPrivada = ($ipConfig.IPv4Address).IPAddress # EXTRAER MÁSCARA $ipDetail = Get-NetIPAddress | Where-Object { $_.IPAddress -eq $ipPrivada } | Select-Object -First 1 $prefix = $ipDetail.PrefixLength # Convertir Prefijo a Decimal $prefixTemp = $prefix $maskArray = for($i=0; $i -lt 4; $i++) { $bits = [Math]::Max(0, [Math]::Min(8, $prefixTemp)) $prefixTemp -= $bits [Convert]::ToInt32(("1"*$bits).PadRight(8, "0"), 2) } $maskDecimal = $maskArray -join "." # Latencias $pingGoogle = Test-Connection -ComputerName 8.8.8.8 -Count 1 -ErrorAction SilentlyContinue $pingCloudflare = Test-Connection -ComputerName 1.1.1.1 -Count 1 -ErrorAction SilentlyContinue $pingQuad9 = Test-Connection -ComputerName 9.9.9.9 -Count 1 -ErrorAction SilentlyContinue # Velocidad $url = "https://nbg1-speed.hetzner.com/10MB.bin" $destino = "$env:TEMP est.bin" $tiempo = Measure-Command { try { Invoke-WebRequest -Uri $url -OutFile $destino -ErrorAction Stop } catch {} } $velocidadMbps = [math]::Round((10 * 8) / $tiempo.TotalSeconds, 2) Remove-Item $destino -ErrorAction SilentlyContinue # 2. Renderizado Manual Compacto Write-Host "--------------------------------------------------------------------------" -ForegroundColor Gray Write-Host "HARDWARE" -ForegroundColor Cyan Write-Host " Adaptador : $($adapter.InterfaceDescription)" Write-Host " Velocidad Link : $($adapter.LinkSpeed)" Write-Host "EXTERNO" -ForegroundColor Cyan Write-Host " IP Publica : $($infoPublica.ip)" Write-Host " Proveedor (ISP) : $($infoPublica.org)" Write-Host " Ubicacion : $($infoPublica.city), $($infoPublica.country)" Write-Host "LOCAL" -ForegroundColor Cyan Write-Host " IP Privada : $ipPrivada" Write-Host " Mascara de Red : $maskDecimal (/$prefix)" Write-Host " Puerta Enlace : $(($ipConfig.IPv4DefaultGateway).NextHop)" Write-Host " Servidores DNS : $(($ipConfig.DNSServer).ServerAddresses -join ', ')" Write-Host "LATENCIAS Y VELOCIDAD" -ForegroundColor Cyan Write-Host " Google (8.8.8.8) : $(if($pingGoogle){ "$($pingGoogle.ResponseTime) ms" } else { 'Fallo' })" Write-Host " Cloudflare (1.1.1.1) : $(if($pingCloudflare){ "$($pingCloudflare.ResponseTime) ms" } else { 'Fallo' })" Write-Host " Quad9 (9.9.9.9) : $(if($pingQuad9){ "$($pingQuad9.ResponseTime) ms" } else { 'Fallo' })" Write-Host " Velocidad Internet : $velocidadMbps Mbps" Write-Host "--------------------------------------------------------------------------" -ForegroundColor Gray