Forum Discussion

Saifhussain000's avatar
Saifhussain000
Copper Contributor
Mar 30, 2024
Solved

Azure VM - Best Practice to associate a Public IP to a Internal VM

Good Day all,

 

So we have our VNET in hub & spoke network in VM configured using the Site to Site VPN. This network is for private only. Now we deployed a Windows Server 2022 VM in azure for internal communication (on-premise to cloud) all is working well but now the management needs to assign a Public IP Address to this VM so a set of websites on this VM needs to be accessed from the internet.

 

Question

1. What is the best practice to associate a Public IP to an private network VM ?

2. Is it good to associate a Public IP to a new NIC or an existing NIC with private IP Address ?

3. We have a Azure Firewall, if i need to enable Public IP do i need to make any changes to the Firewall ?

 

Thanks


  • 1)Best Practice for Associating a Public IP to a Private Network VM:
    The best practice for associating a public IP address with a virtual machine (VM) in a private network is to ensure that the public IP is not directly assigned to the VM. Instead, use a network device like a load balancer or a NAT gateway. This approach provides an additional layer of security, as the VMs are not exposed directly to the internet. For example, in Azure, you can assign the public IP to a load balancer and then configure the load balancer to forward traffic to the private IP of the VM within the virtual network.

    2)Associating a Public IP to a New NIC vs. Existing NIC with Private IP:

    New NIC: Adding a new network interface card (NIC) with a public IP can be a good approach if you want to segregate traffic. For instance, you might use one NIC for internal traffic (with a private IP) and another for external traffic (with a public IP). However, this can add complexity and might not be necessary depending on your architecture and security requirements.
    Existing NIC: Associating a public IP with an existing NIC that already has a private IP is a common practice. It simplifies the network configuration and is sufficient for most scenarios. However, direct exposure of VMs to the internet should be avoided for security reasons, and access should be controlled through firewalls or other security appliances.

    3)Changes to Azure Firewall for Enabling Public IP:

    If you're planning to enable a public IP on a resource behind an Azure Firewall, you might need to configure DNAT (Destination Network Address Translation) rules on the firewall to allow inbound traffic to reach the VM. The firewall will need to know how to route the traffic coming to the public IP to the correct private IP in the virtual network. Additionally, ensure that your network security groups (NSGs) and firewall rules are properly configured to allow the necessary inbound and outbound traffic while maintaining security.

5 Replies


  • 1)Best Practice for Associating a Public IP to a Private Network VM:
    The best practice for associating a public IP address with a virtual machine (VM) in a private network is to ensure that the public IP is not directly assigned to the VM. Instead, use a network device like a load balancer or a NAT gateway. This approach provides an additional layer of security, as the VMs are not exposed directly to the internet. For example, in Azure, you can assign the public IP to a load balancer and then configure the load balancer to forward traffic to the private IP of the VM within the virtual network.

    2)Associating a Public IP to a New NIC vs. Existing NIC with Private IP:

    New NIC: Adding a new network interface card (NIC) with a public IP can be a good approach if you want to segregate traffic. For instance, you might use one NIC for internal traffic (with a private IP) and another for external traffic (with a public IP). However, this can add complexity and might not be necessary depending on your architecture and security requirements.
    Existing NIC: Associating a public IP with an existing NIC that already has a private IP is a common practice. It simplifies the network configuration and is sufficient for most scenarios. However, direct exposure of VMs to the internet should be avoided for security reasons, and access should be controlled through firewalls or other security appliances.

    3)Changes to Azure Firewall for Enabling Public IP:

    If you're planning to enable a public IP on a resource behind an Azure Firewall, you might need to configure DNAT (Destination Network Address Translation) rules on the firewall to allow inbound traffic to reach the VM. The firewall will need to know how to route the traffic coming to the public IP to the correct private IP in the virtual network. Additionally, ensure that your network security groups (NSGs) and firewall rules are properly configured to allow the necessary inbound and outbound traffic while maintaining security.
  • haifa23's avatar
    haifa23
    Copper Contributor
    I think it is not a good idea from the security perspective, because it brings new attack entry to your internal network, it can be risky if you don't have protections for this attack path. You may consider using Application Gateway with WAF, it is a more secure way in this case.
  • stivencastro90's avatar
    stivencastro90
    Copper Contributor
    Hello

    On my experience, the best practice is to create a new NIC and then associate the PIP to that new NIC, that will ensure the separation between your private traffic and the publicly accessible services on your VM.

    Regards

Resources