准备工作
将网线接入以太网口,接通电源,等待以太网口指示灯稳定闪烁。
专业快速开始
打开cmd或pwsh输入ssh root@<局域网设备IP> 后输入密码lynx即可,比如
ssh root@192.168.88.201查看设备局域网IP地址
在与设备相同局域网下的本地电脑中打开Powershell执行以下指令,复制后粘贴回车运行等待返回结果。
# ===== 1. 自动获取本机活动网卡及 IPv4 =====
$nic = Get-NetIPConfiguration |
Where-Object { $_.IPv4DefaultGateway -and $_.NetAdapter.Status -eq 'Up' } |
Select-Object -First 1
if (-not $nic) { Write-Error "未找到带默认网关的活动网卡"; exit 1 }
$localIp = $nic.IPv4Address.IPAddress
Write-Host "本机网卡: $($nic.InterfaceAlias) | IP: $localIp" -ForegroundColor Cyan
# ===== 2. 自动推算所在 /24 网段 =====
$base = ($localIp -split '\.')[0..2] -join '.'
Write-Host "扫描网段: $base.0/24 ..." -ForegroundColor Cyan
# ===== 3. 并发 Ping 扫描 + 反向解析主机名 =====
$online = 1..254 | ForEach-Object -Parallel {
$target = "$using:base.$_"
if (Test-Connection -ComputerName $target -Count 1 -TimeoutSeconds 1 -Quiet) {
$name = $null
try { $name = ([System.Net.Dns]::GetHostEntry($target)).HostName } catch {}
[PSCustomObject]@{ IP = $target; HostName = $name }
}
} -ThrottleLimit 128
# ===== 4. 用 ARP 表补全 MAC 地址 =====
$arp = @{}
if (Get-Command Get-NetNeighbor -ErrorAction SilentlyContinue) {
# Windows
Get-NetNeighbor -AddressFamily IPv4 -State Reachable, Stale -ErrorAction SilentlyContinue |
ForEach-Object { $arp[$_.IPAddress] = $_.LinkLayerAddress }
} else {
# Linux / macOS
(arp -a 2>$null) | ForEach-Object {
if ($_ -match '^\s*([\d\.]+)\s+[\w:-]+\s+([\da-fA-F:.-]+)') { $arp[$matches[1]] = $matches[2] }
}
}
# ===== 5. 输出结果 =====
$result = $online | Sort-Object { [int]($_.IP -split '\.' | Select-Object -Last 1) } | ForEach-Object {
[PSCustomObject]@{
IP = $_.IP
HostName = if ($_.HostName) { $_.HostName } else { '-' }
MAC = if ($arp.ContainsKey($_.IP)) { $arp[$_.IP] } else { '-' }
}
}
Write-Host "`n=== 网段 $base.0/24 在线设备 ===" -ForegroundColor Green
$result | Format-Table -AutoSize从扫描结果中找到设备IP
图上的orangepizero.lan就是设备,其ip为192.168.88.201
或者可以通过路由器后台看到设备所连IP,还可以通过Angry IP Scanner等工具获取设备IP
Angry IP Scanner工具链接