pfSense Community Edition on Azure with 2 NICs

Login

Blog History

$vnetName = "tgn-vnet"

# storage account append the SAS to this url if you are copying from another Account
$vhd = 'https://tgnvhddisk.blob.core.windows.net/vhd/TGN-PFS-01.vhd'
 
$pfsenseResourceGroupName = "tgn-rg"

$storageAccountName = "tgnvhddisk"

$frontendSubnet = "front"
 
$backendSubnet = "back"

$frontNic = "tgn-pfs-front-nic-01"

$backNic = 'tgn-pfs-back-nic-01'
 
$publicIpName = "tgn-pfs-pip-01"

$vnetResourceGroup = $pfsenseResourceGroupName

$vmName = "tgn-pfs-vm-01"
 
$vmSku = "Standard_B1ms"

$managedDiskName = "tgn-pfs-disk-01"

$storageAccount = Get-AzStorageAccount -Name $storageAccountName `
    -ResourceGroupName $pfsenseResourceGroupName
 
$storageAccountId = $storageAccount.Id
 
$location = $storageAccount.PrimaryLocation
  
$diskConfig = New-AzDiskConfig -SkuName Standard_LRS -Location $location -CreateOption Import `
    -StorageAccountId $storageAccountId `
    -SourceUri $vhd
 
New-AzDisk -Disk $diskConfig -ResourceGroupName $pfsenseResourceGroupName -DiskName $managedDiskName

$disk = Get-AzDisk -DiskName $managedDiskName -ResourceGroupName $pfsenseResourceGroupName
 
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $vnetResourceGroup
 
$frontendId = (Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $frontendSubnet).Id

$backendId = (Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $backendSubnet).Id
 
$virtualMachine = New-AzVMConfig -VMName $vmName -VMSize $vmSku

$pubip = New-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $pfsenseResourceGroupName `
    -Location $location -AllocationMethod Static
 
$virtualMachine = Set-AzVMOSDisk -VM $virtualMachine -ManagedDiskId $disk.Id -CreateOption Attach -Linux
 
$frontendNic = New-AzNetworkInterface -Name $frontNic -ResourceGroupName $pfsenseResourceGroupName `
    -Location $location -SubnetId $frontendId -PublicIpAddressId $pubip.Id
 
$backendNic = New-AzNetworkInterface -Name $backNic -ResourceGroupName $pfsenseResourceGroupName `
    -Location $location -SubnetId $backendId
 
$virtualMachine = Add-AzVMNetworkInterface -VM $virtualMachine -Id $frontendNic.Id -Primary
$virtualMachine = Add-AzVMNetworkInterface -VM $virtualMachine -Id $backendNic.Id
 
Set-AzVMBootDiagnostic -VM $virtualMachine -Enable
 
New-AzVM -VM $virtualMachine -ResourceGroupName $pfsenseResourceGroupName -Location $location

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.