Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
manualnat4.destination_intf(name="SZ-OUTSIDE1")
manualnat4.nat_policy(name=namer)
manualnat4.enabled = True
manualnat4.interfaceInTranslatedSource = True
# Manualnat divert
manualnat5 = fmcapi.ManualNatRules(fmc=fmc)
manualnat5.identity_nat(name="_net_source_divert")
manualnat5.original_destination(name="_net_destination_divert")
manualnat5.source_intf(name="IG-INSIDE")
manualnat5.destination_intf(name="SZ-OUTSIDE1")
manualnat5.enabled = True
manualnat5.nat_policy(name=namer)
# Manualnat port-based
manualnat6 = fmcapi.ManualNatRules(fmc=fmc)
manualnat6.original_source(name="_net_source_portbased")
manualnat6.original_source_port(name="_port_original")
manualnat6.translated_source(name="_net_xlate_portbased")
manualnat6.translated_source_port(name="_port_xlate")
manualnat6.natType = "STATIC"
manualnat6.source_intf(name="IG-INSIDE")
manualnat6.destination_intf(name="SZ-OUTSIDE1")
manualnat6.enabled = True
manualnat6.nat_policy(name=namer)
manualnat1.post()
manualnat2.post()
manualnat3.post()
manualnat4.post()
manualnat5.post()
manualnat6.post()
obj12 = fmcapi.ProtocolPortObjects(fmc=fmc)
obj12.name = "_port_xlate"
obj12.protocol = "TCP"
obj12.port = "8443"
obj12.post()
time.sleep(1)
# Create Security Zones
sz1 = fmcapi.SecurityZones(fmc=fmc, name="IG-INSIDE")
sz1.post()
sz2 = fmcapi.SecurityZones(fmc=fmc, name="SZ-OUTSIDE1")
sz2.post()
# Manualnat a network object to a host
manualnat1 = fmcapi.ManualNatRules(fmc=fmc)
manualnat1.original_source(name="_net_original")
manualnat1.translated_source(name="_net_xlate")
manualnat1.natType = "STATIC"
# Source and destination interface can be either an interface group or security zone
manualnat1.source_intf(name="IG-INSIDE")
manualnat1.destination_intf(name="SZ-OUTSIDE1")
manualnat1.enabled = True
manualnat1.nat_policy(name=namer)
# Manualnat identity nat
manualnat2 = fmcapi.ManualNatRules(fmc=fmc)
manualnat2.identity_nat(name="_net_identity")
manualnat2.source_intf(name="IG-INSIDE")
manualnat2.destination_intf(name="SZ-OUTSIDE1")
manualnat2.enabled = True
manualnat2.nat_policy(name=namer)
manualnat2.source_intf(name="IG-INSIDE")
manualnat2.destination_intf(name="SZ-OUTSIDE1")
manualnat2.enabled = True
manualnat2.nat_policy(name=namer)
# Manualnat nat pool
manualnat3 = fmcapi.ManualNatRules(fmc=fmc)
manualnat3.original_source(name="_net_original_pool")
manualnat3.patPool(name="_net_xlate_pool")
manualnat3.source_intf(name="IG-INSIDE")
manualnat3.destination_intf(name="SZ-OUTSIDE1")
manualnat3.enabled = True
manualnat3.nat_policy(name=namer)
# Manualnat interface PAT
manualnat4 = fmcapi.ManualNatRules(fmc=fmc)
manualnat4.original_source(name="_net_original_intf")
manualnat4.natType = "DYNAMIC"
manualnat4.unidirectional = True
manualnat4.source_intf(name="IG-INSIDE")
manualnat4.destination_intf(name="SZ-OUTSIDE1")
manualnat4.nat_policy(name=namer)
manualnat4.enabled = True
manualnat4.interfaceInTranslatedSource = True
# Manualnat divert
manualnat5 = fmcapi.ManualNatRules(fmc=fmc)
manualnat5.identity_nat(name="_net_source_divert")
manualnat5.original_destination(name="_net_destination_divert")
manualnat5.source_intf(name="IG-INSIDE")
manualnat5.destination_intf(name="SZ-OUTSIDE1")
manualnat5.enabled = True
sz2 = fmcapi.SecurityZones(fmc=fmc, name="SZ-OUTSIDE1")
sz2.post()
# Manualnat a network object to a host
manualnat1 = fmcapi.ManualNatRules(fmc=fmc)
manualnat1.original_source(name="_net_original")
manualnat1.translated_source(name="_net_xlate")
manualnat1.natType = "STATIC"
# Source and destination interface can be either an interface group or security zone
manualnat1.source_intf(name="IG-INSIDE")
manualnat1.destination_intf(name="SZ-OUTSIDE1")
manualnat1.enabled = True
manualnat1.nat_policy(name=namer)
# Manualnat identity nat
manualnat2 = fmcapi.ManualNatRules(fmc=fmc)
manualnat2.identity_nat(name="_net_identity")
manualnat2.source_intf(name="IG-INSIDE")
manualnat2.destination_intf(name="SZ-OUTSIDE1")
manualnat2.enabled = True
manualnat2.nat_policy(name=namer)
# Manualnat nat pool
manualnat3 = fmcapi.ManualNatRules(fmc=fmc)
manualnat3.original_source(name="_net_original_pool")
manualnat3.patPool(name="_net_xlate_pool")
manualnat3.source_intf(name="IG-INSIDE")
manualnat3.destination_intf(name="SZ-OUTSIDE1")
manualnat3.enabled = True
manualnat3.nat_policy(name=namer)
# Manualnat interface PAT
manualnat3.enabled = True
manualnat3.nat_policy(name=namer)
# Manualnat interface PAT
manualnat4 = fmcapi.ManualNatRules(fmc=fmc)
manualnat4.original_source(name="_net_original_intf")
manualnat4.natType = "DYNAMIC"
manualnat4.unidirectional = True
manualnat4.source_intf(name="IG-INSIDE")
manualnat4.destination_intf(name="SZ-OUTSIDE1")
manualnat4.nat_policy(name=namer)
manualnat4.enabled = True
manualnat4.interfaceInTranslatedSource = True
# Manualnat divert
manualnat5 = fmcapi.ManualNatRules(fmc=fmc)
manualnat5.identity_nat(name="_net_source_divert")
manualnat5.original_destination(name="_net_destination_divert")
manualnat5.source_intf(name="IG-INSIDE")
manualnat5.destination_intf(name="SZ-OUTSIDE1")
manualnat5.enabled = True
manualnat5.nat_policy(name=namer)
# Manualnat port-based
manualnat6 = fmcapi.ManualNatRules(fmc=fmc)
manualnat6.original_source(name="_net_source_portbased")
manualnat6.original_source_port(name="_port_original")
manualnat6.translated_source(name="_net_xlate_portbased")
manualnat6.translated_source_port(name="_port_xlate")
manualnat6.natType = "STATIC"
manualnat6.source_intf(name="IG-INSIDE")
manualnat6.destination_intf(name="SZ-OUTSIDE1")
autonat.interfaceInTranslatedNetwork = this_rule[
"interface_in_translated_network"
]
if "original_network" in this_rule:
autonat.original_network(this_rule["original_network"])
if "source_interface" in this_rule:
autonat.source_intf(name=this_rule["source_interface"])
if "destination_interface" in this_rule:
autonat.destination_intf(
name=this_rule["destination_interface"]
)
autonat.nat_policy(name=natp["name"])
autonat.post()
if "manual" in natp["rules"]:
for this_rule in natp["rules"]["manual"]:
manualnat = fmcapi.ManualNatRules(fmc=fmc)
if "nat_type" in this_rule:
manualnat.natType = this_rule["nat_type"]
if "original_source" in this_rule:
manualnat.original_source(this_rule["original_source"])
if "translated_source" in this_rule:
manualnat.translated_source(this_rule["translated_source"])
if "source_interface" in this_rule:
manualnat.source_intf(name=this_rule["source_interface"])
if "destination_interface" in this_rule:
manualnat.destination_intf(
name=this_rule["destination_interface"]
)
if "enabled" in this_rule:
manualnat.enabled = this_rule["enabled"]
manualnat.nat_policy(name=natp["name"])
manualnat.post()
# Build NAT Policy
nat = fmcapi.FTDNatPolicies(fmc=fmc1, name="NAT Policy")
nat.post()
# Build NAT Rule to NAT all_lans to interface outside
autonat = fmcapi.AutoNatRules(fmc=fmc1)
autonat.natType = "DYNAMIC"
autonat.interfaceInTranslatedNetwork = True
autonat.original_network(all_lans.name)
autonat.source_intf(name=sz_inside.name)
autonat.destination_intf(name=sz_outside.name)
autonat.nat_policy(name=nat.name)
autonat.post()
# Build NAT Rule to allow inbound traffic to FMC (Branches need to register to FMC.)
fmc_nat = fmcapi.ManualNatRules(fmc=fmc1)
fmc_nat.natType = "STATIC"
fmc_nat.original_source(hq_fmc.name)
fmc_nat.translated_source(fmc_public.name)
fmc_nat.source_intf(name=sz_inside.name)
fmc_nat.destination_intf(name=sz_outside.name)
fmc_nat.nat_policy(name=nat.name)
fmc_nat.enabled = True
fmc_nat.post()
# Add hq-ftd device to FMC
hq_ftd = fmcapi.DeviceRecords(fmc=fmc1)
# Minimum things set.
hq_ftd.hostName = "10.0.0.254"
hq_ftd.regKey = "cisco123"
hq_ftd.acp(name=acp.name)
# Other stuff I want set.