I have an open socket connection, and I want to close it immediately if packet passing through contains certain string. I have tried the following using iptables:
sudo iptables -A INPUT -p tcp --dport 1342 -m string --algo bm --string ".." -j REJECT sudo iptables -A INPUT -p tcp --dport 1342 -m string --algo bm --string ".." -j DROP
But none of this works, it just freezes connection permanently. How to "cut" the connection permanently?
Note: as a testing application I have used simple netcat. Firstly, I connected client and listener, then sent the string containing forbidden one. After that, no response was received and no more lines could be sent over this connection, even when REJECT rule was used.