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

Add back IPv6 protocol support for recent rule masks #1193

Open
104ru opened this issue Mar 4, 2024 · 1 comment
Open

Add back IPv6 protocol support for recent rule masks #1193

104ru opened this issue Mar 4, 2024 · 1 comment

Comments

@104ru
Copy link

104ru commented Mar 4, 2024

Use Case

I am trying to implement rate limiting with iptables, which uses recent and mask options in iptables. The module allows such configuration for IPv4, but not IPv6. On IPv6 it would require rules like that:

-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m comment --comment "130 ipv6 ssh defence" -j SSHSCAN
-A SSHSCAN -p tcp -m recent --update --seconds 300 --hitcount 15 --name SSH --mask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff --rsource -m comment --comment "100 log ipv6 attempts" -j LOG --log-prefix "SSH SCAN blocked: " --log-level 7
-A SSHSCAN -p tcp -m recent --update --seconds 300 --hitcount 15 --name SSH --mask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff --rsource -m comment --comment "110 drop ipv6 attacker" -j DROP
-A SSHSCAN -p tcp -m recent --set --name SSH --mask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff --rsource -m comment --comment "120 accept ipv6 connections" -j ACCEPT

The problem is that the module does not support recent/mask for IPv6, only for IPv4. The mask type is defined as Optional[Pattern[/^\d+\.\d+\.\d+\.\d+$/]] and would not accept the IPv6 values.

Describe the Solution You Would Like

Change mask type allowing both IPv4 and IPv6 values.

Describe Alternatives You've Considered

Of course, there are alternative ways of rate limiting not using iptables, but that is the best fit for a few projects I've got.

Additional Context

Interestingly this limitation to just IPv4 values of the mask has been introduced in version 7 of the module. Before that IPv6 masks were accepted. Thus this request is not so much about adding a new feature as bringing back an old one.

@anthonysomerset
Copy link

I've just bumped into this issue exact same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants