Skip to content

Commit

Permalink
add -s source for MASQUERADE rule
Browse files Browse the repository at this point in the history
  • Loading branch information
yabinma committed Apr 23, 2024
1 parent 0dc4fe6 commit c7c86ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion firewall/iptables_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (i *iptablesManager) InsertEgressRoutingRules(server string, egressInfo mod
if err != nil {
logger.Log(0, "failed to get interface name: ", egressRangeIface, err.Error())
} else {
ruleSpec := []string{"-o", egressRangeIface, "-j", "MASQUERADE"}
ruleSpec := []string{"-s", egressInfo.Network.String(), "-o", egressRangeIface, "-j", "MASQUERADE"}
ruleSpec = appendNetmakerCommentToRule(ruleSpec)
// to avoid duplicate iface route rule,delete if exists
iptablesClient.DeleteIfExists(defaultNatTable, nattablePRTChain, ruleSpec...)
Expand Down
2 changes: 1 addition & 1 deletion firewall/nftables_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (n *nftablesManager) InsertEgressRoutingRules(server string, egressInfo mod
if egressRangeIface, err := getInterfaceName(config.ToIPNet(egressGwRange)); err != nil {
logger.Log(0, "failed to get interface name: ", egressRangeIface, err.Error())
} else {
ruleSpec := []string{"-o", egressRangeIface, "-j", "MASQUERADE"}
ruleSpec := []string{"-s", egressInfo.Network.String(), "-o", egressRangeIface, "-j", "MASQUERADE"}
// to avoid duplicate iface route rule,delete if exists
n.deleteRule(defaultNatTable, nattablePRTChain, genRuleKey(ruleSpec...))
rule = &nftables.Rule{
Expand Down

0 comments on commit c7c86ec

Please sign in to comment.