添加配置文件示例,添加nat列表展示,修改iptables判断逻辑bug

This commit is contained in:
wsczx
2022-11-24 14:51:21 +08:00
parent 42de009e30
commit ef5cad6c7a
3 changed files with 8 additions and 3 deletions

View File

@@ -40,12 +40,14 @@ func checkTun() {
}
natRule := []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-j", "MASQUERADE"}
forwardRule := []string{"-j", "ACCEPT"}
if natExists, _ := ipt.Exists("filter", "FORWARD", forwardRule...); !natExists {
if natExists, _ := ipt.Exists("nat", "POSTROUTING", natRule...); !natExists {
ipt.Insert("nat", "POSTROUTING", 1, natRule...)
}
if forwardExists, _ := ipt.Exists("filter", "FORWARD", natRule...); !forwardExists {
if forwardExists, _ := ipt.Exists("filter", "FORWARD", forwardRule...); !forwardExists {
ipt.Insert("filter", "FORWARD", 1, forwardRule...)
}
base.Info(ipt.List("nat", "POSTROUTING"))
base.Info(ipt.List("filter", "FORWARD"))
}
}