|
24 | 24 | from .CsApp import CsApache, CsDnsmasq, CsPasswdSvc |
25 | 25 | from .CsRoute import CsRoute |
26 | 26 | from .CsRule import CsRule |
| 27 | +from .CsStaticRoutes import CsStaticRoutes |
27 | 28 |
|
28 | 29 | VRRP_TYPES = ['guest'] |
29 | 30 |
|
@@ -567,6 +568,23 @@ def fw_vpcrouter(self): |
567 | 568 | self.fw.append(["mangle", "front", |
568 | 569 | "-A PREROUTING -s %s -d %s -m state --state NEW -j MARK --set-xmark %s/0xffffffff" % |
569 | 570 | (self.cl.get_vpccidr(), self.address['network'], hex(100 + int(self.dev[3:])))]) |
| 571 | + |
| 572 | + static_routes = CsStaticRoutes("staticroutes", self.config) |
| 573 | + if static_routes: |
| 574 | + for item in static_routes.get_bag(): |
| 575 | + if item == "id": |
| 576 | + continue |
| 577 | + static_route = static_routes.get_bag()[item] |
| 578 | + if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']: |
| 579 | + self.fw.append(["mangle", "", |
| 580 | + "-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s/32 -j ACL_OUTBOUND_%s" % |
| 581 | + (self.dev, static_route['network'], static_route['ip_address'], self.dev)]) |
| 582 | + self.fw.append(["filter", "front", "-A FORWARD -d %s -o %s -j ACL_INBOUND_%s" % |
| 583 | + (static_route['network'], self.dev, self.dev)]) |
| 584 | + self.fw.append(["filter", "front", |
| 585 | + "-A FORWARD -d %s -o %s -m state --state RELATED,ESTABLISHED -j ACCEPT" % |
| 586 | + (static_route['network'], self.dev)]) |
| 587 | + |
570 | 588 | if self.address["source_nat"]: |
571 | 589 | self.fw.append(["nat", "front", |
572 | 590 | "-A POSTROUTING -o %s -j SNAT --to-source %s" % |
|
0 commit comments