[CLOUDSTACK-10346] Problem with NAT configuration and VMs not accessing each other via public IPs - #2514
Conversation
|
@rafaelweingartner a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1842 |
|
any reason this should not be targeted for 4.11.1? |
|
No reason at all. It is just my habit of opening PRs against master directly. |
|
@rafaelweingartner since it's a useful bugfix, can you change the base branch and rebase the PR against 4.11 branch? |
|
@rafaelweingartner We faced the same issue before. eth1 is public interface The idea came from the code before 4.7 (systemvm refactoring) |
|
To tell you the truth, I do not understand how you solve this in the routing table. I saw your PR, and it is merged in 4.9.3.0, 4.11, and master, and still the problem persists. I am solving in the The packet is coming from ETH2 (internal interface) to one of our public IPs, we need to execute NAT as well from packets from ETH2 if we want VMs accessing each other via their public IPs. |
|
@rafaelweingartner thanks for your reply. This issue does not exist on our platform based on 4.7.1 (with some other changes) |
|
@blueorangutan package |
|
@borisstoyanov a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1857 |
|
@blueorangutan test |
|
@borisstoyanov a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
…not work 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: -A PREROUTING -d publicIP/32 -i eth1 -p tcp -m tcp --dport 80 -j DNAT --to-destination internalIp:80 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: -A PREROUTING -d publicIP/32 -i eth2 -p tcp -m tcp --dport 80 -j DNAT --to-destination internalIp:80
0dc1ead to
08eb922
Compare
|
@rhtyd changed the target branch to 4.11 |
|
Trillian test result (tid-2443)
|
borisstoyanov
left a comment
There was a problem hiding this comment.
@rafaelweingartner marvin tests looks good, can you add a message how you've tested this in your environment
|
Sure. I did the following to test this issue:
Without the changes introduces by this PR it is not possible to execute the last step. |
borisstoyanov
left a comment
There was a problem hiding this comment.
Thank you @rafaelweingartner.
LGTM
|
@rafaelweingartner okay I did a quick test. I allocated a public IP to my VPC, but did not SNAT it to any VM. Next I used console-proxy and was able to ssh from other vm to the VM which was port-forwarded to the VM with public IP (nat). iptables rules outputs: You can check my lab setup here https://lab.yadav.cloud/stack/ (use cloud:cloud, it's a read only admin :) ) |
|
@rafaelweingartner what is the ACLs for the VPC? I used an allow all policy (i.e. both ingress+egress is allow all) |
|
I just tested in your system, and it is indeed working. I applied your changes here, I am now restarting the network to see what is going to happen. |
|
No success :( |
|
I forgot to mention. In this test environment I am using ACS 4.9. |
|
@rafaelweingartner can you test against 4.11? I tested it against 4.11 ( you can verify yourself the lab env). A lot has changed between 4.9 and 4.11 including python based systemvm codebase and VR template, it is possible that my fix does not work in your 4.9 based env. |
|
That is what I am doing now. I am building 4.11 with your PR to test. |
|
@rafaelweingartner On further investigation and hints from Jayapal's reply on dev@ I found the issue was caused in 4.11/master due to a missing ip route rule which @ustcweizhou has advised. My hack worked because packets were no longer marked which was tied to routing rules. On adding this, instead of MARK rules worked for me at last: |
|
That is what you do in #2579, right? What does I mean, I understand the other commands such as |
|
The first time when I saw this
That is why I said I do not understand how that |
|
@rafaelweingartner yes I've updated #2579, do review that. Meanwhile, in your env can you post the following: Mine looks like this: You can add routing rule like this: (replace cidr with your VPC tiers cidrs, this assumes that eth1 is public nic for VPC VR which usually is) |
|
@rafaelweingartner okay let me try to explain what I understand (and btw this is wrt 4.11, and may not apply for older ACS). The mangle table get rules to mark some packets from PREROUTING (incoming packets), this is done by configure.py mainly and you can get hint from CsRule.py. You can put routing rules based on marked packets. For example, I see this in my VR: By above, packets marked The issue at least for 4.11/master was that these routing table rules (throw stuff may not be necessary, but the important is eth1 can do routing on VPC tier cidrs). I added that, and tests confirm it works. Just for reference, the same could be obtained without using a |
|
@rhtyd sorry the late reply, but the testing took much more time than expected. I tested with current master, and it is working just fine. However, differently, from the 4.9.3.0 that we have noticed a problem with NAT, SNAT is not working (in our 4.9, it was working just fine).The normal NAT is working (this was not working for our 4.9 here). Go figure!? Can you get master and do some testing too? My hosts are XenServer 6.5/7.2. Did you test with XenServer or only with KVM? PR #2514 was intended to fix the normal NAT, which does not seem to be broken in master anymore. Therefore, I think we can close it. We need however to check this errors before releasing a new version. I will re-test again with master before closing my PR. If something change, I will let you know. |
|
@rafaelweingartner I've made further changes on the PR, did you use the latest (see diff?). I've tested only on kvm, I can attempt testing next week on vmware and xenserver, waiting for test matrix to return results soon. |
|
Hmm, I think I used a different commit. I will try again tomorrow then with your newest commit. |
|
Cool, I've updated some commentary above. I found the right symptom but fixed it wrongly at first. |
|
Trillian test result (tid-2518)
|
|
I just finished testing master again. Indeed the problem that I was solving with this PR does not exist in master. Therefore, I will close this PR. |
|
@rafaelweingartner a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1950 |
|
@rhtyd Am I understand correctly, now in 4.11.0.0 we can have such situation: Public network (192.168.0.0/16) gateway is 192.168.1.1 Public network is on eth1 on VR and there is an iptables mark rule for it vr1 has rule for public network: and rules for table are: Such configuration means that vm2 can't connect to vm1 by public_ip(192.168.1.11), because vr2 during request marks packets with 0x1 and then tries to route through gate 192.168.1.1, when it should not (because 1.11 and 1.12 are in the same network) So, the result table should be: |
|
@izenk can you test the 4.11.1 (rc3)? I think it should be fixed and you're right about the expecting routes in the table. |
|
@rhtyd |
|
Thanks @izenk, I'm not sure but hope it should be fixed in 4.11.1 and of course time will tell. |
|
@rhtyd |
|
Let me test that this week @izenk and see if I can reproduce the bug (guest VMs insider same VPC/ same tier unable to access each other via public IP). |
|
@rhtyd may be this helps.. So if I try telnet from vm1 to VR publicIP:80 (which is forwarded to vm2:80), on vm2 I can see packets on port 80, but these packets are from vm1 internal ip(should be from VR SNAT). Next, I even can see replies from vm2 on vm1, but because this replies are coming from vm2 directly (to vm1:internal ip) - in fact connection is not established. |
|
@izenk The basic tests of ingress/egress to/from user VMs to other user VMs using public SNAT (attached) IP pass for me both when VMs were in (a) different tiers in the same VPC, (b) across VPCs, (c) in the same tier. Packet marking in 4.11.2.0 is slightly changed to fix a bug where marking a packet with 0x0 failed in the new VR. Routing etc LGTM, I tested the latest 4.11 branch (4.11.2.0 rc2 + two new commits not related to VR). |
Description
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:
-A PREROUTING -d publicIP/32 -i eth1 -p tcp -m tcp --dport 80 -j DNAT --to-destination internalIp:80The 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:
-A PREROUTING -d publicIP/32 -i eth2 -p tcp -m tcp --dport 80 -j DNAT --to-destination internalIp:80Types of changes
Screenshots (if appropriate):
How Has This Been Tested?
Locally in a development environment and with Both XenServer 6.5 and 7.2.
Checklist:
@blueorangutan package