|
An Azure Virtual Machine (VM) has one or more network interfaces (NIC) attached to it. Any NIC can have one or more static or dynamic public and private IP addresses assigned to it. Assigning multiple IP addresses to a VM enables the following capabilities:
- Hosting multiple websites or services with different IP addresses and SSL certificates on a single server.
- Serve as a network virtual appliance, such as a firewall or load balancer.
Every NIC attached to a VM has one or more IP configurations associated to it. Each configuration is assigned one static or dynamic private IP address. Each configuration may also have one public IP address resource associated to it. A public IP address resource has either a dynamic or static public IP address assigned to it.
|
|
|
|
Add a private IP address
-
Browse to the Azure portal at https://portal.azure.com and sign into it, if necessary.
-
In the portal, click More services > type virtual machines in the filter box, and then click Virtual machines.
-
In the Virtual machines pane, click the VM you want to add IP addresses to. Navigate to Networking Tab. Click Network interface on the page.
-
In the Network interface pane, click the IP configurations.
-
In the pane that appears for the NIC you selected, click IP configurations. Review the subnet shown as default (such as 10.0.0.0/24), and then click OK.
-
Click Add. In the Add IP configuration pane that appears, create an IP configuration named IPConfig-4 with a new Static private IP address by picking a new number for the final octet, then click OK. (For the 10.0.0.0/24 subnet, an example IP would be 10.0.0.7.)
Note
When adding a static IP address, you must specify an unused, valid address on the subnet the NIC is connected to. If the address you select is not available, the portal displays an X for the IP address and you must select a different one.
-
Once you click OK, the pane closes and you see the new IP configuration listed. Click OK to close the Add IP configuration pane.
-
You can click Add to add additional IP configurations, or close all open blades to finish adding IP addresses.
|
|
Add a public IP address
A public IP address is added by associating a public IP address resource to either a new IP configuration or an existing IP configuration.
Create a public IP address resource
A public IP address is one setting for a public IP address resource. If you have a public IP address resource that is not currently associated to an IP configuration that you want to associate to an IP configuration, skip the following steps and complete the steps in one of the sections that follow, as you require. If you don't have an available public IP address resource, complete the following steps to create one:
-
Browse to the Azure portal at https://portal.azure.com and sign into it, if necessary.
-
In the portal, click Create a resource > Networking > Public IP address.
-
In the Create public IP address pane that appears, enter a Name, select an IP address assignment type, a Subscription, a Resource group, and a Location, then click Create.
-
Complete the steps in one of the sections that follow to associate the public IP address resource to an IP configuration.
Associate the public IP address resource to a new IP configuration
-
Complete the steps in the Core steps section of this article.
-
Click Add. In the Add IP configuration pane that appears, create an IP configuration named IPConfig-4. Enable the Public IP address and select an existing, available public IP address resource from the Choose public IP address pane that appears.
Once you've selected the public IP address resource, click OK and the pane closes.
-
Review the new IP configuration. Even though a private IP address wasn't explicitly assigned, one was automatically assigned to the IP configuration, because all IP configurations must have a private IP address.
-
You can click Add to add additional IP configurations, or close all open blades to finish adding IP addresses.
Associate the public IP address resource to an existing IP configuration
- In the portal, click More services > type virtual machines in the filter box, and then click Virtual machines.
-
In the Virtual machines pane, click the VM you want to add IP addresses to. Navigate to Networking Tab. Click Network interface on the page.
-
In the Network interface pane, click the IP configurations.
- Click the IP configuration you want to add the public IP address resource to.
- In the IPConfig pane that appears, click IP address.
- In the Choose public IP address pane that appears, select a public IP address.
- Click Save and the panes close.
|
|
Add IP addresses to a VM operating system (Windows)
Connect and sign in to a VM you created with multiple private IP addresses. You must manually add all the private IP addresses (including the primary) that you added to the VM. Complete the steps that following for your VM operating system.
-
From a command prompt, type ipconfig /all. You only see the Primary private IP address (through DHCP).
-
Type ncpa.cpl in the command prompt to open the Network connections window.
-
Open the properties for the appropriate adapter: Ethernet.
-
Double-click Internet Protocol version 4 (IPv4).
-
Select Use the following IP address and enter the following values:
-
IP address: Enter the Primary private IP address
-
Subnet mask: Set based on your subnet. For example, if the subnet is a /24 subnet then the subnet mask is 255.255.255.0.
-
Default gateway: The first IP address in the subnet. If your subnet is 10.0.0.0/24, then the gateway IP address is 10.0.0.1.
-
Select Use the following DNS server addresses and enter the following values:
- Preferred DNS server: If you are not using your own DNS server, enter 168.63.129.16. If you are using your own DNS server, enter the IP address for your server. (For Alternate DNS Server you can pick any free public DNS server address.)
-
Select the Advanced button and add additional IP addresses. Add each of the secondary private IP addresses, that you added to the Azure network interface in a previous step, to the Windows network interface that is assigned the primary IP address assigned to the Azure network interface.
You should never manually assign the public IP address assigned to an Azure virtual machine within the virtual machine's operating system. When you manually set the IP address within the operating system, ensure that it is the same address as the private IP address assigned to the Azure network interface, or you can lose connectivity to the virtual machine. Learn more about private IP address settings. You should never assign an Azure public IP address within the operating system.
-
Click OK to close out the TCP/IP settings and then OK again to close the adapter settings. Your RDP connection is re-established.
-
From a command prompt, type ipconfig /all. Verify all IP addresses you added are shown and DHCP is turned off.
-
Configure Windows to use the private IP address of the primary IP configuration in Azure as the primary IP address for Windows. See No Internet access from Azure Windows VM that has multiple IP addresses for details.
Validation (Windows Server)
To ensure you are able to connect to the internet from your secondary IP configuration via the public IP associated it, once you have added it correctly using steps above, use the following command (replacing 10.0.0.7 with the secondary, private IP address):
BashCopy
ping -S 10.0.0.7 outlook.com
Note
For secondary IP configurations, you can only ping to the Internet if the configuration has a public IP address associated with it. For primary IP configurations, a public IP address is not required to ping to the Internet.
|
|