Tools/Message Filters
select e-mail account that receives the SPAM (unsure how to make filter for all)
New (button)
set name for example: Delete if sender IP or hostname contains
set radio button "Match any of the following"
set new rule: Customize...
set header variable: Received
(because when you click SPAM mail in inbox, "More" button, "View source", you could see following line for example:
Received: from [198.23.211.171] (port=54178 helo=spam.domain.here)
then in filters set next column to "contains"
next column to 198.23.211.
(that should match all IPs 198.23.211.0-198.23.211.254 - use only if you are receiving many messages from single SPAM range (IP differs only in last octet: x.x.x.0-x.x.x.254))

It can also be done via addon, but it needs knowledge of regex. see here and here