Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Create and configure inbound NAT rules

A worked example

Put in order

You are creating a Standard, Regional, public load balancer named load-balancer in the Azure portal. You have already completed the Basics tab of Create load balancer.

  • lb-vm1 is an Ubuntu VM in lb-vnet. Its NIC IP configuration is ipconfig1 (10.0.0.4), and the VM has no public IP address.
  • The VM's SSH service and network security configuration already permit the administrator's SSH traffic to TCP 22. The administrator has the private key for azureuser.
  • No load-balancing rules are required.

Requirements:

  1. Create the inbound NAT rule in the same deployment as the load balancer, not after it.
  2. Administrators must reach SSH (TCP 22) on lb-vm1 through frontend port 221 on a new public frontend IP address of the load balancer.
  3. Only inbound SSH access is in scope. The VM needs no new outbound connectivity.

Which actions should you perform, in order, to meet the requirements and open an SSH session to lb-vm1?

Your order

You didn't answer this one.

Correct order
1On the Frontend IP configuration tab, add a frontend IP configuration named lb-frontend that uses a newly created public IP address, and select Add.
2On the Inbound rules tab, select + Add an inbound nat rule. Set Name to lb-NAT-rule-VM1-221, Target virtual machine to lb-vm1, Network IP configuration to ipconfig1 (10.0.0.4), Frontend IP address to lb-frontend, Frontend Port to 221, Backend port to 22 and Protocol to TCP. Leave the other settings at their defaults, and select Add.
3Select Review + create, and then select Create.
4Open the deployed load balancer, select Frontend IP configuration, and note the IP address of lb-frontend.
5From a Bash or PowerShell prompt, run ssh -i <key-file> azureuser@<lb-frontend-IP> -p 221, substituting the private-key path and the address noted in the previous step.
Why

An inbound NAT rule forwards traffic arriving at the load balancer's public IP and frontend port to the selected VM's backend port. Define the frontend before selecting it in the rule, then submit both configurations in the same deployment. Once deployment finishes, obtain the frontend address and use SSH with port 221 to reach TCP 22 on lb-vm1.

  • Step 1: On the Frontend IP configuration tab, add a frontend IP configuration named lb-frontend that uses a newly created public IP address, and select Add. The NAT rule must reference a frontend IP configuration, so the frontend must be defined before the rule can select it. None of the other required actions can precede this step.
  • Step 2: On the Inbound rules tab, select + Add an inbound nat rule. Set Name to lb-NAT-rule-VM1-221, Target virtual machine to lb-vm1, Network IP configuration to ipconfig1 (10.0.0.4), Frontend IP address to lb-frontend, Frontend Port to 221, Backend port to 22 and Protocol to TCP. Leave the other settings at their defaults, and select Add. The rule needs the lb-frontend configuration from the previous step. Requirement 1 also means the rule must be added inside the creation wizard.
  • Step 3: Select Review + create, and then select Create. Requirement 1 requires the NAT rule and load balancer to be deployed together, so the rule must be configured before submitting the deployment.
  • Step 4: Open the deployed load balancer, select Frontend IP configuration, and note the IP address of lb-frontend. The deployment must finish before the frontend address can be read from the deployed load balancer.
  • Step 5: From a Bash or PowerShell prompt, run ssh -i <key-file> azureuser@<lb-frontend-IP> -p 221, substituting the private-key path and the address noted in the previous step. The connection uses the address obtained in the previous step and frontend port 221, which the NAT rule forwards to TCP 22 on lb-vm1.
  • Not needed: Run ssh -i <key-file> azureuser@<lb-frontend-IP> -p 22. Port 22 is the backend port on the VM. The NAT rule exposes frontend port 221, so the connection must use port 221.
  • Not needed: Create a NAT gateway and associate it with the subnet of lb-vm1. A NAT gateway provides outbound internet access. New outbound connectivity is unnecessary for the stated goal; the inbound NAT rule provides the required port forwarding.
  • Not needed: Add a load-balancing rule that uses frontend port 221 and backend port 22. The scenario requires no load-balancing rules. The inbound NAT rule already provides the required port forwarding to lb-vm1.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free