列出vSphere群集中所有活动的NIC和IP地址的最佳方法是什么?

我有ESXi 5.1与群集中的许多主机。 我想生成一个活动的NIC列表和他们的IP地址。 什么是最简单的工具来产生这样的清单?

*我不是在寻找虚拟硬件,只有物理networking硬件。

我将使用VMware vSphere PowerCLI。

它包含基于Microsoft PowerShell的自动执行vSpherepipe理的cmdlet的备份。

它可以从这里下载https://my.vmware.com/web/vmware/details?downloadGroup=PCLI550&productId=353

在我写的一个示例powershell脚本下面检索你想要的信息。

要点是:

  • Get-VMHost-Location参数来查询一个特定的集群(如果你有多个并且你想限制查询只有一个,那就是我的情况)
  • 具有-Physical参数的Get-VMHostNetworkAdapter只能获取物理网卡。

 $myVCenter = "vcenter.dom" #fqdn or ip of the VCenter Server $myClusterName = "PROD" #Name of the ESXi cluster $user = "username" $pass = "password" Connect-VIServer "$myVCenter" -User $user -Password "$pass" $myvmhosts = Get-VMHost -Location $myClusterName | select Name foreach($myvmhost in $myvmhosts) { Get-VMHostNetworkAdapter -Physical -VMHost $myvmhost.Name | select VMhost, Name, Mac, IP | format-table -autosize | Out-String } 

会产生这个输出:

 VMHost Name Mac IP ------ ---- --- -- esxsrv1 vmnic0 d4:ae:52:9e:7f:ad esxsrv1 vmnic1 d4:ae:52:9e:7f:af esxsrv1 vmnic2 d4:ae:52:9e:7f:b1 esxsrv1 vmnic3 d4:ae:52:9e:7f:b3 esxsrv1 vmnic4 00:10:18:e4:80:24 esxsrv1 vmnic5 00:10:18:e4:80:25 esxsrv1 vmnic6 00:10:18:dc:12:e0 esxsrv1 vmnic7 00:10:18:dc:12:e2 VMHost Name Mac IP ------ ---- --- -- esxsrv2 vmnic0 d4:ae:52:98:29:6e esxsrv2 vmnic1 d4:ae:52:98:29:70 esxsrv2 vmnic2 d4:ae:52:98:29:72 esxsrv2 vmnic3 d4:ae:52:98:29:74 esxsrv2 vmnic4 00:10:18:e4:86:6e esxsrv2 vmnic5 00:10:18:e4:86:6f esxsrv2 vmnic6 00:10:18:dc:20:20 esxsrv2 vmnic7 00:10:18:dc:20:22 

对于群集中的每个ESXi服务器等等

在我的VMWare体系结构中,我没有在物理网卡上使用IP,但是如果有的话,它们将被显示。

另一个有用的工具是RVTools 。 无需编写脚本。 安装该工具,启动并login,您将拥有所有的信息,包括filter和导出的可能性。

加载PowerCLI,

连接到您的Vcenter服务器。

 Connect-VIServer <servername> 

然后运行

 Get-VMHostNetworkAdapter 

并列出所有nics和他们的IP地址列表。

导出为CSV

 Get-VMHostAdapter | Export-Csv C:\list.csv