Created
April 8, 2020 13:27
-
-
Save heoelri/8a52b8d0a82f4ac9fa82dd1e833506f6 to your computer and use it in GitHub Desktop.
Azure VM with 3 NICs in different Subnets with a Frontend Loadbalancer and IPv6 enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GROUPNAME=cet-testing # Azure Resource Group | |
LOCATION=westeurope # Azure Location | |
LBFRONTEND=cet-testing-lb # Load Balancer Resource Name | |
VNETNAME=cet-testing-vnet # Virtual Network Name | |
# Create a Azure Resource Group | |
GROUP=`az group create --name $GROUPNAME --location $LOCATION --query name -o tsv` | |
# Create a new VNET + Subnet with IPv6 address prefix | |
az network vnet create --name $VNETNAME --resource-group $GROUP --address-prefixes "10.0.0.0/16" "ace:cab:deca::/48" | |
az network vnet subnet create --name frontend --vnet-name $VNETNAME --resource-group $GROUP \ | |
--address-prefixes "10.0.1.0/24" "ace:cab:deca:decd::/64" | |
az network vnet subnet create --name backend --vnet-name $VNETNAME --resource-group $GROUP \ | |
--address-prefixes "10.0.2.0/24" "ace:cab:deca:dedd::/64" | |
az network vnet subnet create --name management --vnet-name $VNETNAME --resource-group $GROUP \ | |
--address-prefixes "10.0.3.0/24" "ace:cab:deca:deed::/64" | |
# Create two new NIC | |
az network nic create --name NIC1_frontend -g $GROUP --subnet frontend --vnet-name $VNETNAME | |
az network nic create --name NIC2_backend -g $GROUP --subnet backend --vnet-name $VNETNAME | |
az network nic create --name NIC3_mgmt -g $GROUP --subnet frontend --vnet-name $VNETNAME | |
# Create the Loadbalancer | |
az network lb create -g $GROUP -n $LBFRONTEND --sku Standard | |
# Create Dummy VM (min. B2s to use 3 nics) | |
az vm create --name cet-test-vm -g $GROUP --location $LOCATION --size Standard_B2s \ | |
--image UbuntuLTS --public-ip-sku Standard --nics NIC1_frontend NIC2_backend NIC3_mgmt | |
# Create IPv6 addresses for the LB | |
az network public-ip create --name PublicIP_v6 --resource-group $GROUP \ | |
--location $LOCATION --sku Standard --allocation-method static --version IPv6 | |
# Configure IPv6 load balancer frontend | |
az network lb frontend-ip create --lb-name $LBFRONTEND \ | |
--name dsLbFrontEnd_v6 --resource-group $GROUP --public-ip-address PublicIP_v6 | |
# Configure IPv6 load balancer backend pool | |
az network lb address-pool create --lb-name $LBFRONTEND --name dsLbBackEndPool_v6 --resource-group $GROUP | |
# Configure IPv6 load balancer rules | |
az network lb rule create --lb-name $LBFRONTEND --name dsLBrule_v6 --resource-group $GROUP \ | |
--frontend-ip-name dsLbFrontEnd_v6 --protocol Tcp --frontend-port 80 \ | |
--backend-port 80 --backend-pool-name dsLbBackEndPool_v6 | |
# add ipv6 config to nic | |
az network nic ip-config create --name dsIp6Config_NIC1 --nic-name NIC1_frontend --resource-group $GROUP \ | |
--lb-name $LBFRONTEND --vnet-name $VNETNAME --subnet frontend \ | |
--private-ip-address-version IPv6 --lb-address-pools dsLbBackEndPool_v6 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment