By default, each Azure virtual machine has one NIC with, or without, public IP address. If you have virtual machine that has public IP address, by design, everything will be configured automatically. All traffic that comes to instance public IP address will be forwarded to instance private IP address. But, what if you need to add more than one NIC to virtual machine? Process is, basically, pretty straight forward, but just adding a new NIC will not make this NIC fully functional.
So, let’s deep dive in problem …
Az-VM-1 has a two NIC. Both NICs have a public IP addresses configured. Both private IP addresses are configured as Dynamic, so virtual network is responsible for IP address lease. But, as you can see in picture below, only one IP address has a internet connectivity.
Also, second network interface is not reachable through public IP and cannot be used for any external traffic. That is because virtual network, by default, assigning private IP addresses to each network interface that is connected to the virtual network and allows external traffic only through primary network interface. But, if you configure private IP addresses as a static, from the virtual machine network interface, you well be able to connect to virtual machine using external IP address.
This action could be “critical” and lead to losing network connectivity to the virtual machine, so you need to perform following steps:
- Set private IP address on network interface in Azure to Static
- Configure IP address in virtual machine as static with the same IP address as you configured in Azure
- Add default gateway parameter
Now, you can see that virtual machine’s second network interface has internet connectivity, and you will be able access to virtual machine from outside 🙂