Create outbound rule configuration
In this we will learn about Load balancer outbound rules configure outbound SNAT for VMs in the backend pool.
However, a public IP or prefix can be used for the outbound configuration.
Public IP
Use az network public-ip create to create a single IP for the outbound connectivity.
- Firstly, Named myPublicIPOutbound.
- Secondly, In CreatePubLBQS-rg.
Azure CLI:
az network public-ip create \
–resource-group CreatePubLBQS-rg \
–name myPublicIPOutbound \
–sku Standard
To create a zonal redundant public IP address in Zone 1:
Azure CLI:
az network public-ip create \
–resource-group CreatePubLBQS-rg \
–name myPublicIPOutbound \
–sku Standard \
–zone 1
Public IP Prefix
Use az network public-ip prefix create to create a public IP prefix for the outbound connectivity.
- Firstly, Named myPublicIPPrefixOutbound.
- Secondly, In CreatePubLBQS-rg.
- Lastly, Prefix length of 28.
Azure CLI:
az network public-ip prefix create \
–resource-group CreatePubLBQS-rg \
–name myPublicIPPrefixOutbound \
–length 28
However, to create a zonal redundant public IP prefix in Zone 1:
Azure CLI:
az network public-ip prefix create \
–resource-group CreatePubLBQS-rg \
–name myPublicIPPrefixOutbound \
–length 28 \
–zone 1
Create outbound frontend IP configuration
Create a new frontend IP configuration with az network lb frontend-ip create :
Firstly, Select the public IP or public IP prefix commands based on decision in previous step.
Public IP
- Firstly, Named myFrontEndOutbound.
- Secondly, In resource group CreatePubLBQS-rg.
- Thirdly, Associated with public IP address myPublicIPOutbound.
- Lastly, Associated with load balancer myLoadBalancer.
Azure CLI:
az network lb frontend-ip create \
–resource-group CreatePubLBQS-rg \
–name myFrontEndOutbound \
–lb-name myLoadBalancer \
–public-ip-address myPublicIPOutbound
Public IP prefix
- Firstly, Named myFrontEndOutbound.
- Secondly, In resource group CreatePubLBQS-rg.
- Thirdly, Associated with public IP prefix myPublicIPPrefixOutbound.
- Lastly, Associated with load balancer myLoadBalancer.
Azure CLI:
az network lb frontend-ip create \
–resource-group CreatePubLBQS-rg \
–name myFrontEndOutbound \
–lb-name myLoadBalancer \
–public-ip-prefix myPublicIPPrefixOutbound
Create outbound pool
Create a new outbound pool with az network lb address-pool create:
- Firstly, Named myBackEndPoolOutbound.
- Secondly, In resource group CreatePubLBQS-rg.
- Lastly, Associated with load balancer myLoadBalancer.
Azure CLI:
az network lb address-pool create \
–resource-group CreatePubLBQS-rg \
–lb-name myLoadBalancer \
–name myBackendPoolOutbound
Create outbound rule
Create a new outbound rule for the outbound backend pool with az network lb outbound-rule create:
- Firstly, Named myOutboundRule.
- Secondly, In resource group CreatePubLBQS-rg.
- Thirdly, Associated with load balancer myLoadBalancer
- Fourthly, Associated with frontend myFrontEndOutbound.
- Then, Protocol All.
- Idle timeout of 15.
- After that, 10000 outbound ports.
- Lastly, Associated with backend pool myBackEndPoolOutbound.
Azure CLI:
az network lb outbound-rule create \
–resource-group CreatePubLBQS-rg \
–lb-name myLoadBalancer \
–name myOutboundRule \
–frontend-ip-configs myFrontEndOutbound \
–protocol All \
–idle-timeout 15 \
–outbound-ports 10000 \
–address-pool myBackEndPoolOutbound
Add virtual machines to outbound pool
Add the virtual machines to the outbound pool with az network nic ip-config address-pool add:
- Firstly, In backend address pool myBackEndPoolOutbound.
- Secondly, In resource group CreatePubLBQS-rg.
- Lastly, Associated with load balancer myLoadBalancer.
Azure CLI:
array=(myNicVM1 myNicVM2 myNicVM3)
for vmnic in “${array[@]}”
do
az network nic ip-config address-pool add \
–address-pool myBackendPoolOutbound \
–ip-config-name ipconfig1 \
–nic-name $vmnic \
–resource-group CreatePubLBQS-rg \
–lb-name myLoadBalancer
done
Reference: Microsoft Documentation