Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rookie question, how do you ban an ip range?


In your nginx, server section:

    deny 1.2.3.0/24;
And all 256 ips from 1.2.3.0 to 1.2.3.255 get banned. You can have multiple "deny" lines, or a file with "deny" and then include it.

It's better to do it at the firewall.


You can do it in a few places, but I use my network firewall for this I use PFSense at home, but there are many enterprise grade brands).

It's common to use the host's firewall as well (nftables, firewalld, or iptables).

You can do it at the webserver too, with access.conf in nginx. Apache uses mod_authz.

I usually do it at the network though so it uses the least amount of resources (no connection ever gets to the webserver). Though if you only have access to your webserver it's faster to ban it there than to send a request to the network team (depending on your org, some orgs might have this automated).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: