VERTRIEB: 1-800-867-1380

Configure a Static Internal IP Address (DIP) for a VM

In most cases, you won’t need to specify a static internal IP address (DIP) for your virtual machine. VMs in a virtual network will automatically receive an internal IP address from a range that you specify. But in certain cases, specifying a static IP address for a particular VM makes sense. For example, if your VM is going to run DNS or will be a domain controller. Or, if you have a VM that you plan to stop/deprovision at some point, but want retain the DIP for the VM when you provision it again. A static DIP stays with the VM even through a stop/deprovision state. You can specify a static DIP by using PowerShell at the time you create the VM, or you can update an existing VM.

If you have both VMs and PaaS instances in your virtual network, you may want to separate the VMs that have static DIPs from your PaaS instances by creating a separate subnet for the VMs and deploying them to that subnet. It’s not only helpful for you to be able to see your static VMs in a separate subnet and know immediately which have a static DIP, but for this release, it also prevents a new PaaS instance from acquiring the static DIP from a VM that is in the process of being stop/deprovisioned (not just restarted). This is a current limitation in this release for mixed VM/PaaS subnets and static DIPs. This issue doesn’t happen if you deploy only VMs to the subnet, even if some of the VMs don’t have a static DIP. If you’ve already deployed your VMs, you can easily move them to a new subnet to avoid this potential issue. For more information, see Move a VM or Role Instance to a Different Subnet.

Before you specify a static IP address from your address pool, you may want to verify that the IP address has not been already assigned. In the example below, we’re checking to see whether the IP address 192.168.4.7 is available in the TestVNet virtual network.

Test-AzureStaticVNetIP –VNetName TestVNet –IPAddress 192.168.4.7 

Be sure to change the variables for the cmdlets to reflect what you require for your environment before running them.

New-AzureVMConfig -Name $vmname -ImageName $img –InstanceSize Small | Set-AzureSubnet –SubnetNames $sub | Set-AzureStaticVNetIP -IPAddress 192.168.4.7 | New-AzureVM –ServiceName $vmsvc1 –AffinityGroup "NorthEuropeAG";

If you want to set a static IP address for a VM that you previously created, you can do so by using the following cmdlets. If you already set an IP address for the VM and you want to change it to a different IP address, you’ll need to remove the existing static IP address before running these cmdlets. See the instructions below to remove a static IP.

For this procedure, you’ll use the Update-AzureVM cmdlet. The Update-AzureVM cmdlet restarts the VM as part of the update process. The DIP that you specify will be assigned after the VM restarts. In this example, we set the IP address for VM2, which is located in cloud service StaticDemo.

Get-AzureVM -ServiceName StaticDemo -Name VM2 | Set-AzureStaticVNetIP -IPAddress 192.168.4.7 | Update-AzureVM

When you remove a static IP address from a VM, the VM will automatically receive a new DIP after the VM restarts as part of the update process. In the example below, we remove the static IP from VM2, which is located in cloud service StaticDemo.

$Get-AzureVM -ServiceName StaticDemo -Name VM2 | Remove-AzureStaticVNetIP | Update-AzureVM

Siehe auch

Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Vielen Dank für Ihr Feedback.
Anzeigen:
© 2014 Microsoft