Hands-on exercise – exploring private IP assignments
In this exercise, you will explore private IP assignment options for VNet resources. Here are the tasks that you will complete in this exercise:
- Task 1 – deploying VMs with dynamic and static private IP assignments
Let’s get into this!
Task 1 – deploying VMs with dynamic and static private IP assignments
The steps are as follows:
- In the Azure Cloud Shell environment, enter the following commands to set the values that we will use for the following variables: resource group, location, VNet, subnet, and VM size. Replace the
Standard_B2s
value if you are using a different size than you verified in the previous exercise:group=CharisTechRG location=eastus VNet=CoreServicesVNet subnet=PublicWebServiceSubnet size=Standard_B2s
- Deploy a VM called
WebVM0
intoPublicWebServiceSubnet
ofCoreServicesVNet
with theaz vm create
command. This will default to the dynamic private IP assignment method:az vm create -g $group -n WebVM0 --image UbuntuLTS --admin-username azureuser --generate-ssh-keys --VNet-name $VNet --subnet $subnet --size $size --public-ip-address ""
The following figure shows the output of this command. Ignore the warning about the public IP as the VM is created without a public IP assigned.
Figure 1.40 – VM creation with the default dynamic private IP assignment
- Deploy a VM called
WebVM1
intoPublicWebServiceSubnet
ofCoreServicesVNet
with theaz vm create
command. This time around, we will specify a static private IP assignment of10.10.3.10
:az vm create -g $group -n WebVM1 --image UbuntuLTS --admin-username azureuser --generate-ssh-keys --VNet-name $VNet --subnet $subnet --size $size --public-ip-address "" --private-ip-address "10.10.3.10"
The following figure shows the output of this command. Ignore the warning about the public IP as the VM is created without a public IP assigned.
Figure 1.41 – VM creation with the default dynamic private IP assignment
- Review the private IP assignment of the VM network interfaces using the
az network nic
list
command:az network nic list -g $group --query "[*].{NIC:name, PrivateIP: ipConfigurations[0].privateIpAddress, Assignment: ipConfigurations[0].privateIpAllocationMethod, IPVersion: ipConfigurations[0].privateIpAddressVersion}" -o table
The --query
parameter is used to sort through the JSON array response to select the properties that we are interested in. The following screenshot shows what the output looks like:
Figure 1.42 – The VM NIC dynamic private IP assignment
Leave Cloud Shell open for the last exercise in this chapter.