Mathew Neznaev
Mathew Neznaev

Reputation: 21

How to filter packets via iptables by regular expression?

everybody!

I need to filter packets by regular expression using iptables, but this command:

$ sudo iptables -I FORWARD -m string --string "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" --algo regex -p sctp -j DROP

Causes this error:

iptables: No chain/target/match by that name.

As somebody said to me, it happens because regex algo is too slow for this chain. I've tried to use it in other chains but got the same error

Is this method even possible? How can I do it?

Thanks for help!

Upvotes: 1

Views: 1203

Answers (1)

ubercracker
ubercracker

Reputation: 61

https://github.com/smcho-kr/kpcre/

You can find iptables regex extension module here. After you install the module, you won't get the error message.

Upvotes: 1

Related Questions