Azure VMs can have multiple Virtual Network Interfaces(NICs) attached to them. Few of the common scenarios where multiple NICs are required on a Virtual Machine:
- WebServer hosting multiple websites
- Dedicated network for backup solution that does not intervene with application’s network performance.
- Dedicated network for a monitoring solution
This article explains how to attach additional network interfaces (NICs) to existing Azure Virtual machine.
Note that the number of network interfaces that can be attached to a VM is limited by its “Size”. Refer to this link to know the maximum number of NICs that can be attached to your VM.
Attaching additional NIC to an Azure VM:
- Stop the Azure VM you want to attach an additional NIC.
- Open Azure Portal and got to the VM Blade for which you intend to attach an additional VM
- Selecting “Networking” under “Settings” to open the networking section of the VM.
- Click on “Add Network Interface”.
- If you have an existing NIC already created, select it from the drop down otherwise click on “Create network interface” > ensure to create a network interface and associate a public IP for the network interface.
- Network Interface is now created, lets associate a public IP address for the network interface. Note that you only have to associate a public IP address if you intend to expose the network to the internet. Otherwise this step is not required.
- Go to the network interface blade we just created and select Public IP address as “Enabled” and then select an existing public ip address or create one to associate it to our secondary NIC. Once done click on “Save”.
- Now that the required IP configuration for our newly created NIC is ready, let us attach it to the VM. Go back to the networking section of the VM and click on Attach network interface.
What to expect?
Although the virtual machine is associated with 2 network interfaces, only the (first) primary network interface will have the internet gateway and by default the additional NICs attached to the VM will not have an internet gateway nor the connectivity to internet. It is very much possible to enable internet to the additional NICs and in the next blog post I will explain how to go around this issue.
- VM must be in Shutdown state while associating additional NICs.
- A VM can only have as many network interfaces attached to it as the VM size supports.
- The network interfaces you add to a VM cannot currently be attached to another VM.
- By default, the first network interface attached to a VM is defined as the primary network interface. All other network interfaces in the VM are secondary network interfaces.
- Though you can control which network interface you sent outbound traffic to, by default, all outbound traffic from the VM is sent out the IP address assigned to the primary IP configuration of the primary network interface.
- Deleting a VM does not delete the network interfaces attached to it.