title | titleSuffix | description | services | documentationcenter | author | ms.custom | ms.service | ms.devlang | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Outbound-only load balancer configuration |
Azure Load Balancer |
With this article, learn about how to create an internal load balancer with outbound NAT |
load-balancer |
na |
asudbring |
seodec18 |
load-balancer |
na |
how-to |
na |
infrastructure-services |
08/07/2020 |
allensu |
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.
Figure: Egress only load balancer configuration
The steps required are:
- Create a virtual network with a bastion host.
- Create a virtual machine with only a private IP.
- Create both internal and public standard load balancers.
- Add backend pools to both load balancers and place the VM into each pool.
- Connect to your VM through the bastion host and:
- Test outbound connectivity,
- Configure an outbound rule on the public load balancer.
- Retest outbound connectivity.
Create a virtual network with two subnets:
- Primary subnet
- Bastion subnet
Create a virtual machine in the new virtual network.
-
Sign in to the Azure portal.
-
On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.
-
In Create virtual network, enter or select this information in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select Create new.
Enter myResourceGroupLB.
Select OK.Instance details Name Enter myVNet Region Select East US 2 -
Select the IP Addresses tab or select the Next: IP Addresses button at the bottom of the page.
-
In the IP Addresses tab, enter this information:
Setting Value IPv4 address space Enter 10.1.0.0/16 -
Under Subnet name, select the word default.
-
In Edit subnet, enter this information:
Setting Value Subnet name Enter myBackendSubnet Subnet address range Enter 10.1.0.0/24 -
Select Save.
-
Select the Security tab.
-
Under BastionHost, select Enable. Enter this information:
Setting Value Bastion name Enter myBastionHost AzureBastionSubnet address space Enter 10.1.1.0/24 Public IP Address Select Create new.
For Name, enter myBastionIP.
Select OK. -
Select the Review + create tab or select the Review + create button.
-
Select Create.
-
On the upper-left side of the portal, select Create a resource > Compute > Virtual machine.
-
In Create a virtual machine, type or select the values in the Basics tab:
Setting Value Project Details Subscription Select your Azure subscription Resource Group Select myResourceGroupLB Instance details Virtual machine name Enter myVM Region Select East US 2 Availability Options Select No infrastructure redundancy required Image Select Windows Server 2019 Datacenter Azure Spot instance Select No 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 Allow selected ports Select inbound ports Select RDP (3389) -
Select the Networking tab, or select Next: Disks, then Next: Networking.
-
In the Networking tab, select or enter:
Setting Value Network interface Virtual network myVNet Subnet myBackendSubnet Public IP Select None. NIC network security group Select None Place this virtual machine behind an existing load-balancing solution? Select No -
Select the Management tab, or select Next > Management.
-
In the Management tab, select or enter:
Setting Value Monitoring Boot diagnostics Select Off -
Select Review + create.
-
Review the settings, and then select Create.
Use the Azure portal to create:
- Internal load balancer
- Public load balancer
Add your created VM to the backend pool of each. You'll then set up a configuration to only permit outbound connectivity from your VM, testing before and after.
-
On the top left-hand side of the screen, select Create a resource > Networking > Load Balancer.
-
In the Basics tab of the Create load balancer page, enter, or select the following information:
Setting Value Subscription Select your subscription. Resource group Select myResourceGroupLB created in the previous step. Name Enter myInternalLoadBalancer Region Select East US 2. Type Select Internal. SKU Select Standard Virtual network Select myVNet created in the previous step. Subnet Select myBackendSubnet created in the previous step. IP address assignment Select Dynamic. -
Accept the defaults for the remaining settings, and then select Review + create.
-
In the Review + create tab, select Create.
-
On the top left-hand side of the screen, select Create a resource > Networking > Load Balancer.
-
In the Basics tab of the Create load balancer page, enter, or select the following information:
Setting Value Subscription Select your subscription. Resource group Select Create new and enter myResourceGroupLB in the text box. Name Enter myPublicLoadBalancer Region Select East US 2. Type Select Public. SKU Select Standard Public IP address Select Create new. Public IP address name Enter myFrontendIP in the text box. Availability zone Select Zone-redundant Add a public IPv6 address Select No. -
Accept the defaults for the remaining settings, and then select Review + create.
-
In the Review + create tab, select Create.
Create the backend address pool myInternalBackendPool:
-
Select All services in the left-hand menu, select All resources, and then select myInternalLoadBalancer from the resources list.
-
Under Settings, select Backend pools, then select Add.
-
On the Add a backend pool page, for name, type myInternalBackendPool, as the name for your backend pool.
-
In Virtual network, select myVNet.
-
Under Virtual machines, select Add and choose myVM.
-
select Add.
Create the backend address pool myPublicBackendPool:
-
Select All services in the left-hand menu, select All resources, and then select myPublicLoadBalancer from the resources list.
-
Under Settings, select Backend pools, then select Add.
-
On the Add a backend pool page, for name, type myPublicBackendPool, as the name for your backend pool.
-
In Virtual network, select myVNet.
-
Under Virtual machines, select Add and choose myVM.
-
select Add.
-
Select All services in the left-hand menu, select All resources, and then from the resources list, select myVM that is located in the myResourceGroupLB resource group.
-
On the Overview page, select Connect, then Bastion.
-
Enter the username and password entered during VM creation.
-
Select Connect.
-
Open Internet Explorer.
-
Enter https://whatsmyip.org in the address bar.
-
The connection should fail. By default, standard public load balancer doesn't allow outbound traffic without a defined outbound rule.
-
Select All services in the left-hand menu, select All resources, and then select myPublicLoadBalancer from the resources list.
-
Under Settings, select Outbound rules, then select Add.
-
Use these values to configure the outbound rules:
Setting Value Name Enter myOutboundRule. Frontend IP address Select LoadBalancerFrontEnd. Idle timeout (minutes) Move slider to 15 minutes. TCP Reset Select Enabled. Backend pool Select myPublicBackendPool. Port allocation -> Port allocation Select Use the default number of outbound ports -
Select Add.
-
Select All services in the left-hand menu, select All resources, and then from the resources list, select myVM that is located in the myResourceGroupLB resource group.
-
On the Overview page, select Connect, then Bastion.
-
Enter the username and password entered during VM creation.
-
Select Connect.
-
Open Internet Explorer.
-
Enter https://whatsmyip.org in the address bar.
-
The connection should succeed.
-
The IP address displayed should be the frontend IP address of myPublicLoadBalancer.
When no longer needed, delete the resource group, load Balancers, VM, and all related resources.
To do so, select the resource group myResourceGroupLB and then select Delete.
In this tutorial, 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.
- Learn about Azure Load Balancer.
- Learn about outbound connections in Azure.
- Load balancer FAQs.
- Learn about Azure Bastion