You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/04/19 14:47:17 UTC

[GitHub] rafaelweingartner closed pull request #2514: [CLOUDSTACK-10346] Problem with NAT configuration and VMs not accessing each other via public IPs

rafaelweingartner closed pull request #2514: [CLOUDSTACK-10346] Problem with NAT configuration and VMs not accessing each other via public IPs
URL: https://github.com/apache/cloudstack/pull/2514
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/systemvm/debian/opt/cloud/bin/configure.py b/systemvm/debian/opt/cloud/bin/configure.py
index a3b7674926c..c83d832b202 100755
--- a/systemvm/debian/opt/cloud/bin/configure.py
+++ b/systemvm/debian/opt/cloud/bin/configure.py
@@ -801,6 +801,7 @@ def portsToString(self, ports, delimiter):
             return "%s%s%s" % (ports_parts[0], delimiter, ports_parts[1])
 
     def processForwardRule(self, rule):
+        logging.info("Is going to process VPC forwarding: %s",  self.config.is_vpc())
         if self.config.is_vpc():
             self.forward_vpc(rule)
         else:
@@ -894,6 +895,15 @@ def forward_vpc(self, rule):
         if not rule["internal_ports"] == "any":
             fw_prerout_rule += ":" + self.portsToString(rule["internal_ports"], "-")
 
+        fw_prerout_rule2 = "-A PREROUTING -d %s/32 -i %s" % (rule["public_ip"], self.getDeviceByIp(rule['internal_ip']))
+        if not rule["protocol"] == "any":
+            fw_prerout_rule2 += " -m %s -p %s" % (rule["protocol"], rule["protocol"])
+        if not rule["public_ports"] == "any":
+            fw_prerout_rule2 += " --dport %s" % self.portsToString(rule["public_ports"], ":")
+        fw_prerout_rule2 += " -j DNAT --to-destination %s" % rule["internal_ip"]
+        if not rule["internal_ports"] == "any":
+            fw_prerout_rule2 += ":" + self.portsToString(rule["internal_ports"], "-")
+
         fw_postrout_rule = "-A POSTROUTING -d %s/32 " % rule["public_ip"]
         if not rule["protocol"] == "any":
             fw_postrout_rule += " -m %s -p %s" % (rule["protocol"], rule["protocol"])
@@ -913,6 +923,7 @@ def forward_vpc(self, rule):
             fw_output_rule += ":" + self.portsToString(rule["internal_ports"], "-")
 
         self.fw.append(["nat", "", fw_prerout_rule])
+        self.fw.append(["nat", "", fw_prerout_rule2])
         self.fw.append(["nat", "", fw_postrout_rule])
         self.fw.append(["nat", "", fw_output_rule])
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services