Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Add Firewall Rules to all vApps (or even one!)

$
0
0

Hi,

 

Hoping someone can help, I need to add 2x firewall rules to all vApps in preparation for an environment change. I'm trying to test the following script on one vApp (the rules are just examples), it passes through without error but doesn't apply. Any advice would be much appreciated!


--------------------------


Connect-CIServer -Server vcloud -Username administrator -Password XXXXX

 

$vAppNet = Get-CIVAPP "TEMP 2012 R2 Multi" | Get-CIVAppNetwork "vApp Network"

$vApp = Get-CIVAPP "TEMP 2012 R2 Multi"

$networkConfigSection = (Get-CIVapp "TEMP 2012 R2 Multi").extensiondata.GetNetworkConfigSection()

$vAppNetwork = $networkConfigSection.NetworkConfig | where {$_.networkName -eq "vApp Network"}

 

 

$fwService = New-Object vmware.vimautomation.cloud.views.firewallservice

$fwService.DefaultAction = "drop"

$fwService.LogDefaultAction = $false

$fwService.IsEnabled = $true

$fwService.FirewallRule = New-Object vmware.vimautomation.cloud.views.firewallrule

$fwService.FirewallRule += New-Object vmware.vimautomation.cloud.views.firewallrule

 

 

#First Rule

$fwService.FirewallRule[0].isenabled = $true

$fwService.FirewallRule[0].description = "Test1"

$fwService.FirewallRule[0].protocols = New-Object vmware.vimautomation.cloud.views.firewallRuleTypeProtocols

$fwService.FirewallRule[0].protocols.ANY = $true

$fwService.FirewallRule[0].policy = "allow"

$fwService.FirewallRule[0].destinationIp = "external"

$fwService.FirewallRule[0].sourceip = "internal"

 

 

#Second Rule

$fwService.FirewallRule[1].isenabled = $true

$fwService.FirewallRule[1].description = "Test2"

$fwService.FirewallRule[1].protocols = New-Object vmware.vimautomation.cloud.views.firewallRuleTypeProtocols

$fwService.FirewallRule[1].protocols.tcp = $true

$fwService.FirewallRule[1].policy = "allow"

$fwService.FirewallRule[1].port = "3389"

$fwService.FirewallRule[1].destinationIp = "Any"

$fwService.FirewallRule[1].sourceport = "3389"

$fwService.FirewallRule[1].sourceip = "192.168.1.81-192.168.1.89"

 

 

$vAppNetwork.Configuration.Features = $vAppNetwork.Configuration.Features | where {!($_ -is [vmware.vimautomation.cloud.views.firewallservice])}

$vAppNetwork.configuration.features += $fwService

$networkConfigSection.UpdateServerData()

 

---------------------------------


Viewing all articles
Browse latest Browse all 168455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>