Skip to content

Conversation

@terassyi
Copy link
Contributor

@terassyi terassyi commented May 15, 2025

This PR adds new iptables rule in egress NAT pods to drop invalid packets.

The specific added rule is here.

iptables -t filter -A FORWARD -o <interface> -m state --state INVALID -j DROP

Signed-off-by: terashima tomoya-terashima@cybozu.co.jp

Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>
@terassyi terassyi self-assigned this May 15, 2025
@terassyi terassyi marked this pull request as ready for review May 29, 2025 07:05
@chez-shanpu chez-shanpu self-requested a review May 29, 2025 07:06
Copy link
Contributor

@chez-shanpu chez-shanpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a small comment.

Comment on lines 79 to 82
err = ipt.Append("filter", "FORWARD", "-o", e.iface, "-m", "state", "--state", "INVALID", "-j", "DROP")
if err != nil {
return fmt.Errorf("failed to setup drop rule for invalid packets: %w", err)
}
Copy link
Contributor

@chez-shanpu chez-shanpu May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = ipt.Append("filter", "FORWARD", "-o", e.iface, "-m", "state", "--state", "INVALID", "-j", "DROP")
if err != nil {
return fmt.Errorf("failed to setup drop rule for invalid packets: %w", err)
}
if err := ipt.Append("filter", "FORWARD", "-o", e.iface, "-m", "state", "--state", "INVALID", "-j", "DROP"); err != nil {
return fmt.Errorf("failed to setup drop rule for invalid packets: %w", err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done.

Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>
@terassyi terassyi requested a review from chez-shanpu May 30, 2025 08:20
Copy link
Contributor

@chez-shanpu chez-shanpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@terassyi terassyi merged commit 314fc3a into main Jun 2, 2025
29 checks passed
@terassyi terassyi deleted the add-iptables-rule-for-dropping-invalid-packet branch June 2, 2025 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants