Yes, it would make more sense to ban them at the router I suppose, but either way should work. I'd look into your iptables rules. They shouldn't be denied access, you should be DROPping incoming requests from the IP ranges. They shouldn't be getting to your server at all, if they are, something is incorrect with your rules, or you need to reload the rules into iptables for them to take effect... Also, note you may have to use some type of hash of all the network ranges you are adding for performance reasons, large blocks may not work with single rules.
To list the current rules:
iptables -L
To restart iptables (may be different depening on distro and init.d vs systemd):
/etc/init.d/iptables restart
or
sysctl iptables restart
Many distros have a front end to iptables now, ufw for Ubuntu I believe, firewalld for Fedora, etc. You may have to explore what firewall is running.
Also, how are you loading all those IP ranges? It may be a good idea to use "hash:net" or "hash:ip" with your firewall. hash:ip is good for smaller number of IPs, does not work well with large subnets at all!!! Use "hash:net" for larger subnets / network ranges.
Once you load your IP ranges into a hash:net, you then issue a rule something like this:
firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -p tcp -m multiport --dports 0:65535 -m set --match-set myhashnet src -j DROP
(the above command assumes firewalld, and that your hash:net is called "myhashnet").
Just some pointers, good luck with it![]()
Bookmarks