Creating Network Interface Card using Powershell
Creating Network Interface Card using PowerShell(Part 5)
NIC:
Network Interface Card is a Circuit board or card that is installed on your computer so that it can be connected to a network
A NIC provides the computer with dedicated,full-time connected to network
Azure allows you to manage network interfaces as object that can be decoupled from the Virtual Machine.This is very important because even after deleting the VM the NIC still remains and we can reuse it
Things we need as input for NIC creation:
- Subnet
- Virtual Network
- NSG
We need to Set the Network Subnet config we created in previous parts, Set the virtual networks
$RG="Osgroup"
$NSGNAME="OsgroupNSG"
$LOCATION="South Central US"
$NICName="osgroupNIC"
$VNETName="OsgroupVnet"
#If NSG RULES ARE NOT YET CREATED!!
$Rule1=New-AzureRmNetworkSecurityRuleConfig -Name "web-rule" -Description "allow all" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix Internet `
-SourcePortRange "*" -DestinationAddressPrefix * -DestinationPortRange *
# If IS NOT YET CREATED !!!
$NSG=New-AzureRmNetworkSecurityGroup -Name $NSGNAME -ResourceGroupName $RG -Location $LOCATION `
-SecurityRules $Rule1
#If VNET is not yet created !!
$VNET=New-AzureRmVirtualNetwork -Name $VNETName -ResourceGroupName $RG -Location $LOCATION `
-AddressPrefix 192.168.0.0/16
#Setting the Subnet Configuration
Set-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VNET -Name $Subnet1 `
-AddressPrefix 192.168.1.0/24 -NetworkSecurityGroup $NSG
Set-AzureRmVirtualNetwork -VirtualNetwork $VNET
#Finally Creating NIC
$NIC=New-AzureRmNetworkInterface -Name $NICName -ResourceGroupName $RG -Location $LOCATION `
-SubnetId $vnet.Subnets[0].id -PublicIpAddressId $PIP.Id -NetworkSecurityGroupId $NSG.Id
$NSG
#AND DONE WE HAVE SUCCESSFULLY CREATED NIC CARD
# Have a Nice Day Ahead!!!
No comments:
Post a Comment