Cuir in eagar

Comhroinn trí


Outbound-only load balancer configuration

Use a combination of internal and external standard load balancers to create outbound connectivity for VMs behind an internal load balancer.

This configuration provides outbound NAT for an internal load balancer scenario, producing an "egress only" setup for your backend pool.

Note

Azure NAT Gateway is the recommended configuration for outbound connectivity in production deployments. For more information about NAT Gateway, see What is Azure NAT Gateway?.

To deploy an outbound only load balancer configuration with Azure NAT Gateway, see Tutorial: Integrate NAT gateway with an internal load balancer - Azure portal.

For more information about outbound connections in Azure and default outbound access, see Source Network Address Translation (SNAT) for outbound connections and Default outbound access.

Figure depicts a egress only load balancer configuration

Figure: Egress only load balancer configuration

Prerequisites

Create a virtual network and bastion host

The following procedure creates a virtual network with a resource subnet, an Azure Bastion subnet, and an Azure Bastion host.

Important

Hourly pricing starts from the moment that Bastion is deployed, regardless of outbound data usage. For more information, see Pricing and SKUs. If you're deploying Bastion as part of a tutorial or test, we recommend that you delete this resource after you finish using it.

  1. In the portal, search for and select Virtual networks.

  2. On the Virtual networks page, select + Create.

  3. On the Basics tab of Create virtual network, enter or select the following information:

    Setting Value
    Project details
    Subscription Select your subscription.
    Resource group Select Create new.
    Enter load-balancer-rg in Name.
    Select OK.
    Instance details
    Name Enter lb-vnet.
    Region Select East US.

    Screenshot of Basics tab of Create virtual network in the Azure portal.

  4. Select the Security tab or Next button at the bottom of the page.

  5. Under Azure Bastion, enter or select the following information:

    Setting Value
    Azure Bastion
    Enable Azure Bastion Select checkbox.
    Azure Bastion host name Enter lb-bastion.
    Azure Bastion public IP address Select Create new.
    Enter lb-bastion-ip in Name.
    Select OK.
  6. Select the IP addresses tab, or Next at the bottom of the page.

  7. On Create virtual network page, enter or select the following information:

    Setting Value
    Add IPv4 address space
    IPv4 address space Enter 10.0.0.0/16 (65,356 addresses).
    Subnets Select the default subnet link to edit.
    Subnet template Leave the default Default.
    Name Enter backend-subnet.
    Starting address Enter 10.0.0.0.
    Subnet size Enter /24(256 addresses).
    Security
    NAT Gateway Select None.

    Screenshot of default subnet rename and configuration.

  8. Select Save.

  9. Select Review + create at the bottom of the screen, and when validation passes, select Create.

Create internal load balancer

In this section, you'll create the internal load balancer.

  1. In the search box at the top of the portal, enter Load balancer. Select Load balancers in the search results.

  2. In the Load balancer page, select Create.

  3. In the Basics tab of the Create load balancer page, enter, or select the following information:

    Setting Value
    Project details
    Subscription Select your subscription.
    Resource group Select lb-resource-group.
    Instance details
    Name Enter lb-internal
    Region Select (US) East US.
    SKU Leave the default Standard.
    Type Select Internal.
  4. Select Next: Frontend IP configuration at the bottom of the page.

  5. In Frontend IP configuration, select + Add a frontend IP configuration.

  6. Enter lb-int-frontend in Name.

  7. Select lb-vnet in Virtual Network.

  8. Select backend-subnet in Subnet.

  9. Select Dynamic for Assignment.

  10. Select Zone-redundant in Availability zone.

    Note

    In regions with Availability Zones, you have the option to select no-zone (default option), a specific zone, or zone-redundant. The choice will depend on your specific domain failure requirements. In regions without Availability Zones, this field won't appear.
    For more information on availability zones, see Availability zones overview.

  11. Select Add.

  12. Select Next: Backend pools at the bottom of the page.

  13. In the Backend pools tab, select + Add a backend pool.

  14. Enter lb-int-backend-pool for Name in Add backend pool.

  15. Select NIC or IP Address for Backend Pool Configuration.

  16. Select Save.

  17. Select the blue Review + create button at the bottom of the page.

  18. Select Create.

Create public load balancer

In this section, you'll create the public load balancer.

  1. In the search box at the top of the portal, enter Load balancer. Select Load balancers in the search results.

  2. In the Load balancer page, select Create.

  3. In the Basics tab of the Create load balancer page, enter, or select the following information:

    Setting Value
    Project details
    Subscription Select your subscription.
    Resource group Select lb-resource-group.
    Instance details
    Name Enter lb-public
    Region Select (US) East US.
    SKU Leave the default Standard.
    Type Select Public.
    Tier Leave the default Regional.
  4. Select Next: Frontend IP configuration at the bottom of the page.

  5. In Frontend IP configuration, select + Add a frontend IP.

  6. Enter lb-ext-frontend in Name.

  7. Select IPv4 or IPv6 for the IP version.

    Note

    IPv6 isn't currently supported with Routing Preference or Cross-region load-balancing (Global Tier).

  8. Select IP address for the IP type.

    Note

    For more information on IP prefixes, see Azure Public IP address prefix.

  9. Select Create new in Public IP address.

  10. In Add a public IP address, enter lb-public-ip for Name.

  11. Select Zone-redundant in Availability zone.

    Note

    In regions with Availability Zones, you have the option to select no-zone (default option), a specific zone, or zone-redundant. The choice will depend on your specific domain failure requirements. In regions without Availability Zones, this field won't appear.
    For more information on availability zones, see Availability zones overview.

  12. Leave the default of Microsoft Network for Routing preference.

  13. Select OK.

  14. Select Add.

  15. Select Next: Backend pools at the bottom of the page.

  16. In the Backend pools tab, select + Add a backend pool.

  17. Enter lb-pub-backend-pool for Name in Add backend pool.

  18. Select lb-VNet in Virtual network.

  19. Select NIC or IP Address for Backend Pool Configuration.

  20. Select Save.

  21. Select the blue Review + create button at the bottom of the page.

  22. Select Create.

Create virtual machine

You'll create a virtual machine in this section. During creation, you'll add it to the backend pool of the internal load balancer. After the virtual machine is created, you'll add the virtual machine to the backend pool of the public load balancer.

  1. In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.

  2. In Virtual machines, select + Create > Virtual machine.

  3. In Create a virtual machine, enter or select the values in the Basics tab:

    Setting Value
    Project Details
    Subscription Select your Azure subscription
    Resource Group Select lb-resource-group
    Instance details
    Virtual machine name Enter lb-VM
    Region Select (US) East US
    Availability Options Select No infrastructure redundancy required
    Security type Select Standard.
    Image Select Windows Server 2022 Datacenter: Azure Edition - Gen2
    Azure Spot instance Leave the default of unchecked.
    Size Choose VM size or take default setting
    Administrator account
    Username Enter a username
    Password Enter a password
    Confirm password Reenter password
    Inbound port rules
    Public inbound ports Select None
  4. Select the Networking tab, or select Next: Disks, then Next: Networking.

  5. In the Networking tab, select or enter:

    Setting Value
    Network interface
    Virtual network lb-VNet
    Subnet backend-subnet
    Public IP Select None.
    NIC network security group Select Advanced
    Configure network security group Leave the default of vm-NSG. This might be different if you choose a different name for your VM.
  6. Under Load balancing, select the following:

    Setting Value
    Load-balancing options Select Azure load balancing
    Select a load balancer Select lb-internal
    Select a backend pool Select lb-int-backend-pool
  7. Select Review + create.

  8. Review the settings, and then select Create.

Add VM to backend pool of public load balancer

In this section, you'll add the virtual machine you created previously to the backend pool of the public load balancer.

  1. In the search box at the top of the portal, enter Load balancer. Select Load balancers in the search results.

  2. Select lb-public.

  3. Select Backend pools in Settings in lb-public.

  4. Select lb-pub-backend-pool under Backend pool in the Backend pools page.

  5. In lb-pub-backend-pool, select lb-VNet in Virtual network.

  6. In Virtual machines, select the blue + Add button.

  7. Select the box next to lb-VM in Add virtual machines to backend pool.

  8. Select Add.

  9. Select Save.

Test connectivity before outbound rule

  1. In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.

  2. Select lb-VM.

  3. In the Overview page, select Connect, then Bastion.

  4. Enter the username and password entered during VM creation.

  5. Select Connect.

  6. Open Microsoft Edge browser.

  7. Enter https://whatsmyip.org in the address bar.

  8. The connection should fail. By default, standard public load balancer doesn't allow outbound traffic without a defined outbound rule.

Create a public load balancer outbound rule

  1. In the search box at the top of the portal, enter Load balancer. Select Load balancers in the search results.

  2. Select lb-public.

  3. Select Outbound rules in Settings in lb-public.

  4. Select + Add in Outbound rules.

  5. Enter or select the following information to configure the outbound rule.

    Setting Value
    Name Enter myOutboundRule.
    Frontend IP address Select lb-ext-frontend.
    Protocol Leave the default of All.
    Idle timeout (minutes) Move slider to 15 minutes.
    TCP Reset Select Enabled.
    Backend pool Select lb-pub-backend-pool.
    Port allocation
    Port allocation Select Manually choose number of outbound ports.
    Outbound ports
    Choose by Select Ports per instance.
    Ports per instance Enter 10000
  6. Select Add.

Test connectivity after outbound rule

  1. In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.

  2. Select lb-VM.

  3. On the Overview page, select Connect, then Bastion.

  4. Enter the username and password entered during VM creation.

  5. Select Connect.

  6. Open Microsoft Edge browser.

  7. Enter https://whatsmyip.org in the address bar.

  8. The connection should succeed.

  9. The IP address displayed should be the frontend IP address of lb-public.

Clean up resources

When no longer needed, delete the resource group, load balancers, VM, and all related resources.

To do so, select the resource group lb-resource-group and then select Delete.

Next steps

In this article, you created an "egress only" configuration with a combination of public and internal load balancers.

This configuration allows you to load balance incoming internal traffic to your backend pool while still preventing any public inbound connections.

For more information about Azure Load Balancer and Azure Bastion, see What is Azure Load Balancer? and What is Azure Bastion?.