IP Banning is already implemented over fail2ban and has the behaviour you wrote.
For whitelist, check this post: IP keeps getting Banned even though its whitelisted - #3 by johnny
IP Banning is already implemented over fail2ban and has the behaviour you wrote.
For whitelist, check this post: IP keeps getting Banned even though its whitelisted - #3 by johnny