You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatic configure juniper srx/vsrx nat loopback,
Constraint condition that manual configure source nat in juniper srx,allowed vm vist public network :
zone : trust to {trust,untrust}
rule : source address {0.0.0.0/0},destination address{0.0.0.0/0} ,do source nat with pool {public network getway ip}.
code change for trust to trust destination or static nat:
1. add srxCommand :CHECK_PRIVATE_IF_EXISTS. for add/delete rule to detect whether exist or not contain DestinationNatRule or StaticNatRule (ruleName_private) in trust zone .
2. add DestinationNatRule (ruleName_private) to trust zone when ADD DestinationNatRule to untrust .
3. delete DestinationNatRule (ruleName_private) from trust zone when DELETE DestinationNatRule from untrust.
4. add StaticNatRule (ruleName_private) to trust zone when ADD StaticNatRule to untrust .
5. delete StaticNatRule (ruleName_private) from trust zone when DELETE StaticNatRule from untrust.
Check private if exist.
thrownewExecutionException("Failed to add destination NAT rule from public IP " + publicIp + ", public port " + srcPort + ", private IP " +
2220
2256
privateIp + ", and private port " + destPort);
2221
2257
} else {
2258
+
2259
+
xml = SrxXml.DEST_NAT_RULE_ADD.getXml();
2260
+
xml = replaceXmlValue(xml, "rule-set", _privateZone);
2261
+
xml = replaceXmlValue(xml, "from-zone", _privateZone);
2262
+
xml = replaceXmlValue(xml, "rule-name", ruleName_private);
2263
+
xml = replaceXmlValue(xml, "public-address", publicIp);
2264
+
xml = replaceXmlValue(xml, "src-port", String.valueOf(srcPort));
2265
+
xml = replaceXmlValue(xml, "pool-name", poolName);
2266
+
2267
+
if (!sendRequestAndCheckResponse(command, xml))
2268
+
{
2269
+
s_logger.debug("Purple: loopback Failed to add " + _privateZone + " destination NAT rule from public IP " + publicIp + ", public port " + srcPort + ", private IP " +
thrownewExecutionException("Failed to delete destination NAT rule from public IP " + publicIp + ", public port " + srcPort + ", private IP " +
2238
2288
privateIp + ", and private port " + destPort);
2239
2289
} else {
2290
+
if (manageDestinationNatRule(SrxCommand.CHECK_PRIVATE_IF_EXISTS, publicIp, privateIp, srcPort, destPort))
2291
+
{
2292
+
xml = SrxXml.DEST_NAT_RULE_GETONE.getXml();
2293
+
xml = setDelete(xml, true);
2294
+
xml = replaceXmlValue(xml, "rule-set", _privateZone);
2295
+
xml = replaceXmlValue(xml, "from-zone", _privateZone);
2296
+
xml = replaceXmlValue(xml, "rule-name", ruleName_private);
2297
+
2298
+
if (!sendRequestAndCheckResponse(command, xml))
2299
+
{
2300
+
s_logger.debug("Purple: Failed to delete " + _privateZone + " destination NAT rule from public IP " + publicIp + ", public port " + srcPort + ", private IP " +
0 commit comments