我有$loopback_address
是192.168.1.1/24和$source_address
是192.168.1.1。我编写了一个PowerShell脚本来拆分回送地址,并将其与源地址进行比较,如下所示:
$Loopback_ip = ($loopback_address -split '/')
# so my $loopback_ip[0] is now equal to 192.168.1.1 which should be the
# same as the source_address.
if ($loopback_ip[0] -eq $source_address) {
Write-Host "same"
} else {
Write-Host "different"
}
结果应该是“相同”,但是“不同”。