flnxi-Wu/scripts/deploy/check-server-network.ps1
WuYongJie f646b71813
Some checks failed
CI Check / check (push) Has been cancelled
chore: 初始化本地仓库并同步最近改动
2025-11-18 17:50:16 +08:00

48 lines
2.1 KiB
PowerShell

# Check server network connectivity
param(
[string]$Server = "45.249.208.118",
[string]$User = "root",
[string]$Password = "lxvhNYFZ4160"
)
$ErrorActionPreference = "Stop"
Write-Host "Checking server network connectivity..." -ForegroundColor Cyan
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
if (-not (Test-Path $plinkPath)) {
Write-Host "Error: plink.exe not found" -ForegroundColor Red
exit 1
}
Write-Host "`n[1/5] Testing basic internet connectivity..." -ForegroundColor Yellow
$pingResult = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "ping -c 2 8.8.8.8 2>&1"
Write-Host $pingResult
Write-Host "`n[2/5] Testing DNS resolution..." -ForegroundColor Yellow
$dnsResult = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "nslookup registry-1.docker.io 2>&1"
Write-Host $dnsResult
Write-Host "`n[3/5] Testing HTTPS connectivity to Docker Hub..." -ForegroundColor Yellow
$httpsResult = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "curl -I https://registry-1.docker.io/v2/ --max-time 10 2>&1 | head -5"
Write-Host $httpsResult
Write-Host "`n[4/5] Checking Docker proxy settings..." -ForegroundColor Yellow
$proxyResult = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "docker info 2>&1 | grep -i proxy"
Write-Host $proxyResult
Write-Host "`n[5/5] Checking system proxy environment variables..." -ForegroundColor Yellow
$envProxy = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "env | grep -i proxy"
Write-Host $envProxy
Write-Host "`n=== Analysis ===" -ForegroundColor Cyan
Write-Host "If all tests fail, the server may:" -ForegroundColor Yellow
Write-Host "1. Have no internet access" -ForegroundColor White
Write-Host "2. Be behind a firewall that blocks Docker Hub" -ForegroundColor White
Write-Host "3. Require a proxy to access external services" -ForegroundColor White
Write-Host "`nAlternative solutions:" -ForegroundColor Cyan
Write-Host "1. Export image from local machine and upload to server" -ForegroundColor Green
Write-Host "2. Configure Docker to use a proxy" -ForegroundColor Green
Write-Host "3. Use a local registry or private mirror" -ForegroundColor Green