powershell 使用指定IP地址 ping


PowerShell交流中心分类: Powershell基础powershell 使用指定IP地址 ping
1
Net asked 5年 ago
$Node1 = "SQL01"
$Node2 = "SQL02"
$Node1Conn = Test-NetConnection -ComputerName "$Node1" | ForEach-Object {$_.RemoteAddress } | ForEach-Object {$_.IPAddressToString }
$Node2Conn = Test-NetConnection -ComputerName "$Node2" | ForEach-Object {$_.RemoteAddress } | ForEach-Object {$_.IPAddressToString }
 
# 事情是这样的,我 iSCSI 服务器上有 多张 10G 网卡,其中一张用于 LAN 网络,另外一张专用于 iSCSI 存储网卡
# 服务器之间都处于 Domain 环境中,因此服务器之间都默认走的 LAN 网卡的 IP 地址
# 现在我想使用 iSCSI 的网卡去 ping SQL01 这台机上的IP地址,从而返回 SQL01 服务器上使用的 iSCSI 网卡的IP地址
# 而非使用默认的 LAN 网卡的IP地址去 Ping,

Mooser Lee 管理员 replied 5年 ago

顶起求高手解答?

2 Answers
0
Best Answer
yhcfsr answered 5年 ago

我是不是可以理解为获取本机特定网卡的IP呢?
 
Get-NetIPConfiguration|?{$_.InterfaceDescription -eq ‘VMware Virtual Ethernet Adapter for VMnet1’}|%{$_.IPv4Address.IPAddress}

Net replied 5年 ago

相反,我是要获取远程指定适配器的IP地址
Invoke-Command -ComputerName “$Node2” { Get-NetIPAddress -InterfaceAlias “iSCSI 01” -AddressFamily IPv4 | ForEach-Object {$_.IPAddress } } -Credential $UserPasswd

0
pstip_newer answered 4年 ago

使用固定IP就行了吧。或者登记主机的mac地址。利用arp信息来获取mac对应的Ip。