From the iptables manual:
recent Allows you to dynamically create a list of IP addresses and then match against that list in a few different ways. For example, you can create a "badguy" list out of people attempting to connect to port 139 on your firewall and then DROP all future packets from them without considering them.
[...]
Steve’s ipt_recent website (http://snowman.net/projects/ipt_recent/) also has some examples of usage.
I think that's what you were looking for ;)