|
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 |
|
@@ -553,6 +554,23 @@ def fw_vpcrouter(self): |
553 | 554 | self.fw.append(["mangle", "front", |
554 | 555 | "-A PREROUTING -s %s -d %s -m state --state NEW -j MARK --set-xmark %s/0xffffffff" % |
555 | 556 | (self.cl.get_vpccidr(), self.address['network'], hex(100 + int(self.dev[3:])))]) |
| 557 | + |
| 558 | + static_routes = CsStaticRoutes("staticroutes", self.config) |
| 559 | + if static_routes: |
| 560 | + for item in static_routes.get_bag(): |
| 561 | + if item == "id": |
| 562 | + continue |
| 563 | + static_route = static_routes.get_bag()[item] |
| 564 | + if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']: |
| 565 | + self.fw.append(["mangle", "", |
| 566 | + "-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s/32 -j ACL_OUTBOUND_%s" % |
| 567 | + (self.dev, static_route['network'], static_route['ip_address'], self.dev)]) |
| 568 | + self.fw.append(["filter", "front", "-A FORWARD -d %s -o %s -j ACL_INBOUND_%s" % |
| 569 | + (static_route['network'], self.dev, self.dev)]) |
| 570 | + self.fw.append(["filter", "front", |
| 571 | + "-A FORWARD -d %s -o %s -m state --state RELATED,ESTABLISHED -j ACCEPT" % |
| 572 | + (static_route['network'], self.dev)]) |
| 573 | + |
556 | 574 | if self.address["source_nat"]: |
557 | 575 | self.fw.append(["nat", "front", |
558 | 576 | "-A POSTROUTING -o %s -j SNAT --to-source %s" % |
|
0 commit comments