@@ -3620,7 +3620,8 @@ def getEdgeGatewayNatConfig(self, edgeGatewayId, validation=True):
36203620 errorList = list ()
36213621 natConfigDict = {
36223622 'Nat64 rule' : [],
3623- 'Range of IPs or network found in DNAT rule' : []
3623+ 'Range of IPs or network found in DNAT rule' : [],
3624+ 'Invalid IP present in SNAT rule' : []
36243625 }
36253626 logger .debug ("Getting NAT Services Configuration Details of Source Edge Gateway" )
36263627 # url to retrieve the nat config details of the specified edge gateway
@@ -3649,6 +3650,14 @@ def getEdgeGatewayNatConfig(self, edgeGatewayId, validation=True):
36493650 'Range of IPs or network found in this DNAT rule {} and range cannot be used in target edge gateway\n ' .format (
36503651 natrule ['ruleId' ]))
36513652 natConfigDict ['Range of IPs or network found in DNAT rule' ].append (natrule ['ruleId' ])
3653+ if natrule ['action' ] == "snat" and "/" in natrule ['originalAddress' ]:
3654+ originalIP = natrule ['originalAddress' ]
3655+ ip_part , mask = originalIP .split ('/' )
3656+ # Check if the IP is a network address
3657+ network = ipaddress .ip_network (originalIP , strict = False )
3658+ if ip_part != str (network .network_address ):
3659+ errorList .append ("Invalid IP present in SNAT rule {} " .format (natrule ['ruleId' ]))
3660+ natConfigDict ['Invalid IP present in SNAT rule' ].append (natrule ['ruleId' ])
36523661 return errorList , natrules , natConfigDict
36533662 else :
36543663 return errorList , False , natConfigDict
0 commit comments