-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix nat table by getting the fitting device for an address #9552
base: 4.19
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -554,7 +554,7 @@ def fw_vpcrouter(self): | |
if self.address["source_nat"]: | ||
self.fw.append(["nat", "front", | ||
"-A POSTROUTING -o %s -j SNAT --to-source %s" % | ||
(self.dev, self.address['public_ip'])]) | ||
(self.address['device'], self.address['public_ip'])]) | ||
if self.get_gateway() == self.get_ip_address(): | ||
for inf, addresses in self.config.address().dbag.iteritems(): | ||
if not inf.startswith("eth"): | ||
|
@@ -693,11 +693,8 @@ def post_config_change(self, method): | |
vpccidr = cmdline.get_vpccidr() | ||
self.fw.append( | ||
["filter", 3, "-A FORWARD -s %s ! -d %s -j ACCEPT" % (vpccidr, vpccidr)]) | ||
self.fw.append( | ||
["nat", "", "-A POSTROUTING -j SNAT -o %s --to-source %s" % (self.dev, self.address['public_ip'])]) | ||
elif cmdline.get_source_nat_ip() and not self.is_private_gateway(): | ||
self.fw.append( | ||
["nat", "", "-A POSTROUTING -j SNAT -o %s --to-source %s" % (self.dev, cmdline.get_source_nat_ip())]) | ||
self.fw.append( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there are multiple public ips (in multiple ranges), will there be same amount of rules ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I understand the question. I checked this in a lab env and the resulting nat table was exactly as described in the issue, with only the last line being different. Ar you considdering another configuration here @weizhouapache ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for each public ip (and private gateway), there will be a rule below, right ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DaanHoogland
If I understand correctly, for the current changes , the rules are for example,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll verify that. Do you happen to know what condition to test for? I don't think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the original issue does not exist in our lab (I can verify with infra). we can only verify the iptables rules in the VR
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I'll give it a try |
||
["nat", "", "-A POSTROUTING -j SNAT -o %s --to-source %s" % (self.dev, self.address['public_ip'])]) | ||
|
||
def list(self): | ||
self.iplist = {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line applies only when private gateway is source nat.
it seems we need to change line 698-700
https://github.com/apache/cloudstack/pull/9552/files#diff-3c470eee70094a82ad3ed790deed16a991e75ed18901cfb82d82a80cd71228a7L698-R700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll try and find if we have data on the second IF at that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DaanHoogland
have you checked the new iptables rules ? do they look good ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try changes on line 698-700
@DaanHoogland
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have a look at those @weizhouapache , they work in my test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this code snippet (line 554 to 557) can be removed.It has been covered by line 696-697 (new code)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please ignore my previous comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check, for private gateway , is
self.dev
same asself.address['device']
?