IPTables add an IP to IPSet list

blacklistip addressipsetiptables

How to correctly add an IP address to ipset from an iptables rule?
Or isn't that possible at all?

This rule doesn't work for me: -A INPUT -m recent --name IP_LIST --set

Type of IP_LIST is hash:net
IP_LIST was created using command ipset create IP_LIST hash:net

But checking the same list for an IP to drop it, works:
-A INPUT -m set --match-set IP_LIST src -j DROP

Best Answer

So, since -j SET is what you wanted:

Within iptables, -m set is used when you want to compare a packet against an ipset (-m stands for match) it can be used multiple times within a single rule.

-j SET on the other hand is used to insert an entry into an ipset, it is a non-terminating target, meaning that rule traversal will continue.

You should read the iptables manpage for a full explanation of the expected syntax.