[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444148#comment-16444148
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10346:
---------------------------------------------

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:
us...@infra.apache.org


> Problem with NAT configuration and VMs not accessing each other via public IPs
> ------------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-10346
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10346
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Rafael Weingärtner
>            Assignee: Rafael Weingärtner
>            Priority: Major
>
> When users create a VPC, and configure a NAT from a public IP to application 
> in a VM. This VM(applications) are not accessible via public IP for other VMs 
> in the same VPC.
>  
> The problem is in the NAT table. If you take a closer look at rules, you will 
> see something like:
> {code:java}
> -A PREROUTING -d publicIP/32 -i eth1 -p tcp -m tcp --dport 80 -j DNAT 
> --to-destination internalIp:80
> {code}
> The problem is that according to this rule only packets coming via 
> eth1(public interface), will be “redirected” to the internal IP. We need an 
> extra entry to each one of the NAT configurations. For the presented rule, we 
> would need something like:
> {code:java}
> -A PREROUTING -d publicIP/32 -i eth2 -p tcp -m tcp --dport 80 -j DNAT 
> --to-destination internalIp:80
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to