Skip to content
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(iptables): 复杂环境下转发删除端口错误 #7868

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/utils/firewall/client/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ func (iptables *Iptables) NatAdd(protocol, srcPort, dest, destPort string, save

// 非本机转发, 按公网流程走
if err := iptables.runf(NatTab, fmt.Sprintf(
"-A %s -p %s -d %s --dport %s -j MASQUERADE",
"-A %s -d %s -p %s --dport %s -j MASQUERADE",
PostRoutingChain,
protocol,
dest,
protocol,
destPort,
)); err != nil {
return err
Expand Down Expand Up @@ -192,7 +192,7 @@ func (iptables *Iptables) NatRemove(num string, protocol, srcPort, dest, destPor
// 删除公网转发规则
if dest != "" && dest != "127.0.0.1" && dest != "localhost" {
if err := iptables.runf(NatTab, fmt.Sprintf(
"-D %s -p %s -d %s --dport %s -j MASQUERADE",
"-D %s -d %s -p %s --dport %s -j MASQUERADE",
PostRoutingChain,
dest,
protocol,
Expand Down
Loading