我正在通过 Ubuntu 命令行配置一个新的 Azure VM(资源管理器)。我正在按照此处列出的步骤进行操作:https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-tutorial/
我的问题是:在配置新 VM 时,我如何在命令行上执行操作以确保它具有静态 IP(保留 IP)?
可以使用 Azure PowerShell 通过 New-AzureReservedIP -ReservedIPName $reservedIP -Location $location
最佳答案
您需要将公共(public) IP 地址定义为资源组的一部分,然后将其分配给正确的虚拟 NIC(网络接口(interface)卡)。
公共(public) IP 地址资源类型表示公共(public)互联网上的 DNS 名称。它可用于为托管在 Azure 负载均衡器上的虚拟 IP 地址 (VIP) 或直接托管在 VM 上的公共(public)实例 IP 地址 (PIP) 提供 DNS 名称。
使用 Azure CLI,您需要编写如下内容:
azure network public-ip create -g MyResourceGroup -a Dynamic -l northeurope MyPublicIP
然后您可以将您的 IP 分配给 VM 的虚拟 NIC。 VM 和 NIC 都属于同一个资源组:
azure network nic set -g MyResourceGroup -p MyPublicIP MyNicName
您可以使用“azure network nic list”来获取网卡的名称。
似乎currently only Dynamic Public IPs are supported for being used directly on VMs (在 ARM 模式下)。目前,静态 IP 只能分配给负载均衡器配置。在执行“azure network nic set”时尝试使用“-a Static”会出现错误:
Network interface xxx references public IP address yyy with AllocationMethod property set to Static. Currently this configuration is not supported. Network interfaces can use only dynamic public IPs.
我还想知道什么时候支持。
编辑:here is a good Azure CLI reference .您还可以使用 -h 获取命令使用帮助。
关于linux - 如何在配置 Azure VM(资源管理器)时保留 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34021375/