【问题标题】:try to get a list of ips attached to the NIC尝试获取附加到 NIC 的 ips 列表
【发布时间】:2021-01-25 23:02:19
【问题描述】:

我正在尝试获取连接到 NIC 的 Ip 列表。 尝试使用

Get-NetIPAddress。没有得到清单。我有一个 nic 的主要和多个辅助 ips。尝试一种方法来获得这一切。

【问题讨论】:

  • Get-NetIPConfiguration ?这给了你什么?
  • 看起来像 Azure,这是 Azure 虚拟机吗?
  • 是的,这是一个与 azure vm 关联的网卡
  • 我正在通过 vm 运行它,但想知道它给出了主地址,其余的呢?
  • 嗨,怎么样?您的问题解决了吗?

标签: azure azure-powershell azure-vm


【解决方案1】:

如果您想获取虚拟机的所有私有 IP 地址,请尝试以下 PS 命令:

$vm = get-azvm -VMName <vm name> -ResourceGroupName <resource Group name>
#get network interface information of vm
$nicRes = Get-AzResource -ResourceId $vm.NetworkProfile.NetworkInterfaces.Id
#get network interface object 
$nic = Get-AzNetworkInterface -name $nicRes.name -ResourceGroupName $nicRes.ResourceGroupName
#read ip configs of this network interface
foreach($ipConfig in $nic.IpConfigurations){
    $ipConfig.PrivateIpAddress
}

我的网卡IP配置:

结果:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2015-05-30
    相关资源
    最近更新 更多