Step by step: Adding multiple IP addresses to an Azure Virtual Machine with PowerShell

Published Aug 24 2021 03:00 AM 2,551 Views
Microsoft

When creating a new Azure virtual machine using the Azure portal, you can create and assign a static public IP address to it, but what if you need it to have more than one? In this article, we'll use PowerShell commands in the Azure portal's Cloud Shell to add multiple public IP addresses to a virtual machine.

 

Overview of IP address configuration on Azure Virtual Machines

Lets start with the architecture of how IP addresses work with Azure Virtual Machines. An Azure virtual machine is more than one resource - as well as the virtual machine you have disk storage, a network interface (NIC), a virtual network and (hopefully) a network security group. Creating a virtual machine through the Azure portal allows you to add one network interface, one dynamic private IP address and one dynamic or static public IP address.

The Azure portal allows you to add a dynamic private IP and a public IP address when you create a VM.The Azure portal allows you to add a dynamic private IP and a public IP address when you create a VM.

 

But, virtual machines also support having static private IP addresses, multiple private IP addresses, multiple public IP addresses and multiple NICs. This could be useful if you want to split public-facing (or "front end") traffic from internal traffic to other Azure or on-premises resources (known as "back end" traffic).

 

Azure virtual machine with one NIC and multiple IP addressesAzure virtual machine with one NIC and multiple IP addresses

Today we'll keep it simple and stick with a single NIC, but add multiple IP addresses to it. 

If you want to add multiple NICs to your VM, you can follow the 5 steps to add a NIC to an existing VM.

We add new IP configurations to the appropriate NIC.

 

IP configurations

Each IP configuration can have one of the following combinations

  • Static private IP address, no public IP address
  • Dynamic private IP address, no public IP address
  • Static private IP address, dynamic public IP address
  • Static private IP address, static public IP address
  • Dynamic private IP address, dynamic public IP address
  • Dynamic private IP address, static public IP address

EXCEPT if your virtual machine is in an Availability zone, then only Standard SKU public IP addresses are supported, which means your public IP address can only be static.

One IP configuration on a single NICOne IP configuration on a single NIC


Note: If you delete an IP configuration from your virtual machine and it contains a public IP address, it won't automatically delete the public IP address resource (as you may wish to reallocate it). If the public IP address is no longer needed, make sure you delete the public IP address resource too (after it has been disassociated from the VM by the removal of the IP configuration).

 

Run these commands in PowerShell or the Cloud Shell:

Step 1: Fetch the details of your NIC

 

 

Get-AzNetworkInterface | Format-Table Name, ResourceGroupName, Location

 

 

 

Step 2: Create variables to store the values of the name of your NIC, its resource group name and its location (replacing the values in " " with your own details).

 

 

$NicName  = "MyNIC"
$RgName   = "MyResourceGroup"
$Location = "westus"

 

 

 

Step 3: Create a variable that fetches and stores information about your NIC:

 

 

$MyNIC = Get-AzNetworkInterface -Name $NicName -ResourceGroupName $RgName

 

 

 

Step 4: Query the details of the $MyNIC variable to note the VNet and Subnet your NIC is connected to:

 

 

$MyNIC.IpConfigurations

 

 

The output of step 4 will look similar to this:
"Id": "/subscriptions/[Id]/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVNet/subnets/MySubnet"

so the MyVNet and MySubnet values are what you need from this.

 

Now you have a choice to make - you can add a public IP address to an existing IP configuration which already has private IP address (dynamic or static), OR you can add a public IP address as a new, additional IP configuration.
If you add it to a new IP config, you also have to add a new private IP address at the same time, as all public IP addresses must have a corresponding private IP address.

 

Step 5: Create a new public IP address resource:

 

 

$myPublicIp3 = New-AzPublicIpAddress `
-Name "myPublicIp3" `
-ResourceGroupName $RgName `
-Location $Location `
-AllocationMethod Static

 

 

 

Step 6: Create a new IP configuration, including the public IP address and specifying a static private IP address:

 

 

Add-AzNetworkInterfaceIpConfig `
-Name IPConfig-4 `
-NetworkInterface $myNIC `
-Subnet $Subnet `
-PrivateIpAddress 10.0.0.7 `
-PublicIpAddress $myPublicIp3

 

 

 

Step 7: Bind (or set) this new IP configuration to your NIC:

 

 

Set-AzNetworkInterface -NetworkInterface $MyNIC

 

 

And we can confirm it's now listed by checking the portal or running the following command:

 

 

$MyNIC.IpConfigurations | Format-Table Name, PrivateIPAddress, PublicIPAddress, Primary

 

 

 

You'll also see it in the Azure portal:

2 IP configurations on one NIC2 IP configurations on one NIC

 

 

Step 8: Add the IP address to the Guest OS

Wait, what? 

The golden rule is usually to never manage Azure VM public IP addressing in the guest operating system. But because we've added a new static, private IP address to the Azure configuration, we need to manually tell the guest operating system that there is now a new, secondary private IP address it needs to be listening on.

 

So for Windows Server, log into the operating system, run ipconfig to see your current network settings (primary IP address, subnet mask, default gateway and Azure DNS server 163.63.129.16) then run ncpa.cpl and add these to the IP address settings for your NIC:

 

Set IP configuration for the primary IP address in the guest OSSet IP configuration for the primary IP address in the guest OS

 

Then under Advanced, add your secondary private IP address:

 

Adding a secondary private IP to the guest OSAdding a secondary private IP to the guest OS 

 

Note: When you close these network settings, you will temporary lose your connection, then it should re-establish itself. This also works if your RDP port is NOT open to the internet and the remote access into your guest OS is done with Azure Bastion.

 

Learn more

Azure Virtual Network concepts and best practices

Public IP addresses in Microsoft Azure

Create a VM with multiple IP addresses

Design an IP addressing schema for your Azure deployment - MS Learn

 

 

1 Comment

Works on different subnets?

%3CLINGO-SUB%20id%3D%22lingo-sub-2677513%22%20slang%3D%22en-US%22%3EStep%20by%20step%3A%20Adding%20multiple%20IP%20addresses%20to%20an%20Azure%20Virtual%20Machine%20with%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2677513%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20creating%20a%20new%20Azure%20virtual%20machine%20using%20the%20Azure%20portal%2C%20you%20can%20create%20and%20assign%20a%20static%20public%20IP%20address%20to%20it%2C%20but%20what%20if%20you%20need%20it%20to%20have%20more%20than%20one%3F%20In%20this%20article%2C%20we'll%20use%20PowerShell%20commands%20in%20the%20Azure%20portal's%20Cloud%20Shell%20to%20add%20multiple%20public%20IP%20addresses%20to%20a%20virtual%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--379138925%22%20id%3D%22toc-hId--379108914%22%20id%3D%22toc-hId--379108914%22%20id%3D%22toc-hId--379108914%22%20id%3D%22toc-hId--379108914%22%3EOverview%20of%20IP%20address%20configuration%20on%20Azure%20Virtual%20Machines%3C%2FH2%3E%0A%3CP%3ELets%20start%20with%20the%20architecture%20of%20how%20IP%20addresses%20work%20with%20Azure%20Virtual%20Machines.%20An%20Azure%20virtual%20machine%20is%20more%20than%20one%20resource%20-%20as%20well%20as%20the%20virtual%20machine%20you%20have%20disk%20storage%2C%20a%20network%20interface%20(NIC)%2C%20a%20virtual%20network%20and%20(hopefully)%20a%20network%20security%20group.%20Creating%20a%20virtual%20machine%20through%20the%20Azure%20portal%20allows%20you%20to%20add%20one%20network%20interface%2C%20one%20dynamic%20private%20IP%20address%20and%20one%20dynamic%20or%20static%20public%20IP%20address.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Azure-portal-VM-defaults.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305276i1FE7724C1C0C774B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Azure-portal-VM-defaults.jpg%22%20alt%3D%22The%20Azure%20portal%20allows%20you%20to%20add%20a%20dynamic%20private%20IP%20and%20a%20public%20IP%20address%20when%20you%20create%20a%20VM.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EThe%20Azure%20portal%20allows%20you%20to%20add%20a%20dynamic%20private%20IP%20and%20a%20public%20IP%20address%20when%20you%20create%20a%20VM.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%2C%20virtual%20machines%20also%20support%20having%20static%20private%20IP%20addresses%2C%20multiple%20private%20IP%20addresses%2C%20multiple%20public%20IP%20addresses%20and%20multiple%20NICs.%20This%20could%20be%20useful%20if%20you%20want%20to%20split%20public-facing%20(or%20%22front%20end%22)%20traffic%20from%20internal%20traffic%20to%20other%20Azure%20or%20on-premises%20resources%20(known%20as%20%22back%20end%22%20traffic).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22multiple-ipconfigs.png%22%20style%3D%22width%3A%20390px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305278i429E8C443B6BA185%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22multiple-ipconfigs.png%22%20alt%3D%22Azure%20virtual%20machine%20with%20one%20NIC%20and%20multiple%20IP%20addresses%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAzure%20virtual%20machine%20with%20one%20NIC%20and%20multiple%20IP%20addresses%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EToday%20we'll%20keep%20it%20simple%20and%20stick%20with%20a%20single%20NIC%2C%20but%20add%20multiple%20IP%20addresses%20to%20it.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20add%20multiple%20NICs%20to%20your%20VM%2C%20you%20can%20follow%20the%205%20steps%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fvirtual-machines%2Fwindows%2Fmultiple-nics%3Fwt.mc_id%3Dmodinfra-38921-socuff%23add-a-nic-to-an-existing-vm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eadd%20a%20NIC%20to%20an%20existing%20VM%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EWe%20add%20new%20IP%20configurations%20to%20the%20appropriate%20NIC.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2108373908%22%20id%3D%22toc-hId-2108403919%22%20id%3D%22toc-hId-2108403919%22%20id%3D%22toc-hId-2108403919%22%20id%3D%22toc-hId-2108403919%22%3EIP%20configurations%3C%2FH2%3E%0A%3CP%3EEach%20IP%20configuration%20can%20have%20one%20of%20the%20following%20combinations%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EStatic%20private%20IP%20address%2C%20no%20public%20IP%20address%3C%2FLI%3E%0A%3CLI%3EDynamic%20private%20IP%20address%2C%20no%20public%20IP%20address%3C%2FLI%3E%0A%3CLI%3EStatic%20private%20IP%20address%2C%20dynamic%20public%20IP%20address%3C%2FLI%3E%0A%3CLI%3EStatic%20private%20IP%20address%2C%20static%20public%20IP%20address%3C%2FLI%3E%0A%3CLI%3EDynamic%20private%20IP%20address%2C%20dynamic%20public%20IP%20address%3C%2FLI%3E%0A%3CLI%3EDynamic%20private%20IP%20address%2C%20static%20public%20IP%20address%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3EEXCEPT%3C%2FSTRONG%3E%20if%20your%20virtual%20machine%20is%20in%20an%20Availability%20zone%2C%20then%20only%20Standard%20SKU%20public%20IP%20addresses%20are%20supported%2C%20which%20means%20your%20public%20IP%20address%20can%20only%20be%20static.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22IPconfig-1.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305292i2669DD14F2C4D003%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22IPconfig-1.jpg%22%20alt%3D%22One%20IP%20configuration%20on%20a%20single%20NIC%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EOne%20IP%20configuration%20on%20a%20single%20NIC%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CEM%3ENote%3A%3C%2FEM%3E%20If%20you%20delete%20an%20IP%20configuration%20from%20your%20virtual%20machine%20and%20it%20contains%20a%20public%20IP%20address%2C%20it%20won't%20automatically%20delete%20the%20public%20IP%20address%20resource%20(as%20you%20may%20wish%20to%20reallocate%20it).%20If%20the%20public%20IP%20address%20is%20no%20longer%20needed%2C%20make%20sure%20you%20delete%20the%20public%20IP%20address%20resource%20too%20(after%20it%20has%20been%20disassociated%20from%20the%20VM%20by%20the%20removal%20of%20the%20IP%20configuration).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERun%20these%20commands%20in%20PowerShell%20or%20the%20Cloud%20Shell%3A%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1496031914%22%20id%3D%22toc-hId--1496001903%22%20id%3D%22toc-hId--1496001903%22%20id%3D%22toc-hId--1496001903%22%20id%3D%22toc-hId--1496001903%22%3EStep%201%3A%20Fetch%20the%20details%20of%20your%20NIC%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EGet-AzNetworkInterface%20%7C%20Format-Table%20Name%2C%20ResourceGroupName%2C%20Location%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-991480919%22%20id%3D%22toc-hId-991510930%22%20id%3D%22toc-hId-991510930%22%20id%3D%22toc-hId-991510930%22%20id%3D%22toc-hId-991510930%22%3EStep%202%3A%20Create%20variables%20to%20store%20the%20values%20of%20the%20name%20of%20your%20NIC%2C%20its%20resource%20group%20name%20and%20its%20location%20(replacing%20the%20values%20in%20%22%20%22%20with%20your%20own%20details).%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24NicName%20%20%3D%20%22MyNIC%22%0A%24RgName%20%20%20%3D%20%22MyResourceGroup%22%0A%24Location%20%3D%20%22westus%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--815973544%22%20id%3D%22toc-hId--815943533%22%20id%3D%22toc-hId--815943533%22%20id%3D%22toc-hId--815943533%22%20id%3D%22toc-hId--815943533%22%3EStep%203%3A%20Create%20a%20variable%20that%20fetches%20and%20stores%20information%20about%20your%20NIC%3A%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24MyNIC%20%3D%20Get-AzNetworkInterface%20-Name%20%24NicName%20-ResourceGroupName%20%24RgName%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1671539289%22%20id%3D%22toc-hId-1671569300%22%20id%3D%22toc-hId-1671569300%22%20id%3D%22toc-hId-1671569300%22%20id%3D%22toc-hId-1671569300%22%3EStep%204%3A%20Query%20the%20details%20of%20the%20%24MyNIC%20variable%20to%20note%20the%20VNet%20and%20Subnet%20your%20NIC%20is%20connected%20to%3A%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24MyNIC.IpConfigurations%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20output%20of%20step%204%20will%20look%20similar%20to%20this%3A%3CBR%20%2F%3E%22Id%22%3A%20%22%2Fsubscriptions%2F%5BId%5D%2FresourceGroups%2FmyResourceGroup%2Fproviders%2FMicrosoft.Network%2FvirtualNetworks%2FMyVNet%2Fsubnets%2FMySubnet%22%3C%2FP%3E%0A%3CP%3Eso%20the%20MyVNet%20and%20MySubnet%20values%20are%20what%20you%20need%20from%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20you%20have%20a%20choice%20to%20make%20-%20you%20can%20add%20a%20public%20IP%20address%20to%20an%20existing%20IP%20configuration%20which%20already%20has%20private%20IP%20address%20(dynamic%20or%20static)%2C%20OR%20you%20can%20add%20a%20public%20IP%20address%20as%20a%20new%2C%20additional%20IP%20configuration.%20%3CBR%20%2F%3EIf%20you%20add%20it%20to%20a%20new%20IP%20config%2C%20you%20also%20have%20to%20add%20a%20new%20private%20IP%20address%20at%20the%20same%20time%2C%20as%20all%20public%20IP%20addresses%20must%20have%20a%20corresponding%20private%20IP%20address.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--135915174%22%20id%3D%22toc-hId--135885163%22%20id%3D%22toc-hId--135885163%22%20id%3D%22toc-hId--135885163%22%20id%3D%22toc-hId--135885163%22%3EStep%205%3A%20Create%20a%20new%20public%20IP%20address%20resource%3A%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24myPublicIp3%20%3D%20New-AzPublicIpAddress%20%60%0A-Name%20%22myPublicIp3%22%20%60%0A-ResourceGroupName%20%24RgName%20%60%0A-Location%20%24Location%20%60%0A-AllocationMethod%20Static%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1943369637%22%20id%3D%22toc-hId--1943339626%22%20id%3D%22toc-hId--1943339626%22%20id%3D%22toc-hId--1943339626%22%20id%3D%22toc-hId--1943339626%22%3EStep%206%3A%20Create%20a%20new%20IP%20configuration%2C%20including%20the%20public%20IP%20address%20and%20specifying%20a%20static%20private%20IP%20address%3A%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EAdd-AzNetworkInterfaceIpConfig%20%60%0A-Name%20IPConfig-4%20%60%0A-NetworkInterface%20%24myNIC%20%60%0A-Subnet%20%24Subnet%20%60%0A-PrivateIpAddress%2010.0.0.7%20%60%0A-PublicIpAddress%20%24myPublicIp3%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-544143196%22%20id%3D%22toc-hId-544173207%22%20id%3D%22toc-hId-544173207%22%20id%3D%22toc-hId-544173207%22%20id%3D%22toc-hId-544173207%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--1263311267%22%20id%3D%22toc-hId--1263281256%22%20id%3D%22toc-hId--1263281256%22%20id%3D%22toc-hId--1263281256%22%20id%3D%22toc-hId--1263281256%22%3EStep%207%3A%20Bind%20(or%20set)%20this%20new%20IP%20configuration%20to%20your%20NIC%3A%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ESet-AzNetworkInterface%20-NetworkInterface%20%24MyNIC%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20we%20can%20confirm%20it's%20now%20listed%20by%20checking%20the%20portal%20or%20running%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24MyNIC.IpConfigurations%20%7C%20Format-Table%20Name%2C%20PrivateIPAddress%2C%20PublicIPAddress%2C%20Primary%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou'll%20also%20see%20it%20in%20the%20Azure%20portal%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22IPconfig-2.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305291i5CF4DCEEB93AC205%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22IPconfig-2.jpg%22%20alt%3D%222%20IP%20configurations%20on%20one%20NIC%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3E2%20IP%20configurations%20on%20one%20NIC%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-529038087%22%20id%3D%22toc-hId-529068098%22%20id%3D%22toc-hId-529068098%22%20id%3D%22toc-hId-529068098%22%20id%3D%22toc-hId-529068098%22%3EStep%208%3A%20Add%20the%20IP%20address%20to%20the%20Guest%20OS%3C%2FH3%3E%0A%3CP%3E%3CEM%3EWait%2C%20what%3F%3C%2FEM%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20golden%20rule%20is%20usually%20to%20never%20manage%20Azure%20VM%20public%20IP%20addressing%20in%20the%20guest%20operating%20system.%20But%20because%20we've%20added%20a%20new%20static%2C%20private%20IP%20address%20to%20the%20Azure%20configuration%2C%20we%20need%20to%20manually%20tell%20the%20guest%20operating%20system%20that%20there%20is%20now%20a%20new%2C%20secondary%20private%20IP%20address%20it%20needs%20to%20be%20listening%20on.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20for%20Windows%20Server%2C%20log%20into%20the%20operating%20system%2C%20run%20ipconfig%20to%20see%20your%20current%20network%20settings%20(primary%20IP%20address%2C%20subnet%20mask%2C%20default%20gateway%20and%20Azure%20DNS%20server%20163.63.129.16)%20then%20run%20ncpa.cpl%20and%20add%20these%20to%20the%20IP%20address%20settings%20for%20your%20NIC%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Primary-private-IP-GuestOS.jpg%22%20style%3D%22width%3A%20590px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305289i9EABF1C2EC78DBC8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Primary-private-IP-GuestOS.jpg%22%20alt%3D%22Set%20IP%20configuration%20for%20the%20primary%20IP%20address%20in%20the%20guest%20OS%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESet%20IP%20configuration%20for%20the%20primary%20IP%20address%20in%20the%20guest%20OS%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20under%20Advanced%2C%20add%20your%20secondary%20private%20IP%20address%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22secondary-private-IP-GuestOS.jpg%22%20style%3D%22width%3A%20570px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305290iFEE7421DB36D89C2%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22secondary-private-IP-GuestOS.jpg%22%20alt%3D%22Adding%20a%20secondary%20private%20IP%20to%20the%20guest%20OS%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAdding%20a%20secondary%20private%20IP%20to%20the%20guest%20OS%3C%2FSPAN%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENote%3A%20When%20you%20close%20these%20network%20settings%2C%20you%20will%20temporary%20lose%20your%20connection%2C%20then%20it%20should%20re-establish%20itself.%20This%20also%20works%20if%20your%20RDP%20port%20is%20NOT%20open%20to%20the%20internet%20and%20the%20remote%20access%20into%20your%20guest%20OS%20is%20done%20with%20Azure%20Bastion.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1407499095%22%20id%3D%22toc-hId--1407469084%22%20id%3D%22toc-hId--1407469084%22%20id%3D%22toc-hId--1407469084%22%20id%3D%22toc-hId--1407469084%22%3ELearn%20more%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fvirtual-network%2Fconcepts-and-best-practices%3Fwt.mc_id%3Dmodinfra-38921-socuff%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Virtual%20Network%20concepts%20and%20best%20practices%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fvirtual-network%2Fpublic-ip-addresses%3Fwt.mc_id%3Dmodinfra-38921-socuff%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPublic%20IP%20addresses%20in%20Microsoft%20Azure%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fvirtual-network%2Fvirtual-network-multiple-ip-addresses-powershell%3Fwt.mc_id%3Dmodinfra-30921-socuff%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreate%20a%20VM%20with%20multiple%20IP%20addresses%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fdesign-ip-addressing-for-azure%2F%3Fwt.mc_id%3Dmodinfra-38921-socuff%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDesign%20an%20IP%20addressing%20schema%20for%20your%20Azure%20deployment%20-%20MS%20Learn%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2677513%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20add%20more%20public%20and%20private%20IP%20addresses%20to%20your%20Azure%20virtual%20machine%2C%20using%20PowerShell%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Multiple-IP-Azure-VM.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305275i916A681EAF859BCB%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Multiple-IP-Azure-VM.jpg%22%20alt%3D%22Multiple-IP-Azure-VM.jpg%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2677513%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESonia%20Cuff%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2686973%22%20slang%3D%22en-US%22%3ERe%3A%20Step%20by%20step%3A%20Adding%20multiple%20IP%20addresses%20to%20an%20Azure%20Virtual%20Machine%20with%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2686973%22%20slang%3D%22en-US%22%3E%3CP%3EWorks%20on%20different%20subnets%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎Aug 23 2021 09:04 PM
Updated by: