Skip to content

Commit

Permalink
Merge pull request #44803 from akerouanton/fix-44721
Browse files Browse the repository at this point in the history
libnetwork: Remove iptables nat rule when hairpin is disabled
  • Loading branch information
neersighted committed Jan 12, 2023
2 parents 4c02882 + 566a2e4 commit dae48a8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libnetwork/drivers/bridge/setup_ip_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,10 @@ func setupIPTablesInternal(hostIP net.IP, bridgeIface string, addr *net.IPNet, i
}
}

// In hairpin mode, masquerade traffic from localhost
if hairpin {
if err := programChainRule(ipVersion, hpNatRule, "MASQ LOCAL HOST", enable); err != nil {
return err
}
// In hairpin mode, masquerade traffic from localhost. If hairpin is disabled or if we're tearing down
// that bridge, make sure the iptables rule isn't lying around.
if err := programChainRule(ipVersion, hpNatRule, "MASQ LOCAL HOST", enable && hairpin); err != nil {
return err
}

// Set Inter Container Communication.
Expand Down

0 comments on commit dae48a8

Please sign in to comment.