Add custom firewall rules in cloudflare
for more efficient defense.
Add four rules for this project#
GitHub: cloudflare-block-bad-bot-ruleset
Copy the content in rules
In the cloudflare
backend, select your domain name→Security→WAF→Create firewall rule
, click Edit expression
and enter the regular expression,
And select the corresponding action in the Action column in the chart (such as JS Challenge),
Save and you're done
Fifth rule#
Next, we add an IP blacklist
, also create a new rule with Create firewall rule
Choose to block the IP addresses in the list
At this time, we need to add a CSV format IP list
in Manage lists
, download link:
Access code Xigp
https://www.123pan.com/s/Ic4eVv-NTS7v.html
Save and you're done
In addition
We can sort the five rules and set the weight according to the requirements
. Drag the left side of the category to sort
Combining the two ASN lists provided by hostloc and this GitHub project, I have integrated them all into one. That is the second rule in the chart "Based on known IDC ASN numbers (including Alibaba Cloud Shield)", we can directly paste the following regular expression
Click to expand
(ip.geoip.asnum in {10026 10453 11351 11426 11691 12076 1215 1216 1217 12271 12334 12367 12874 12876 12989 131090 131106 131138 131139 131140 131141 131293 131428 131444 131477 131486 131495 132196 132203 132509 132510 132513 132591 132839 133024 133199 133380 133478 133492 133746 133752 133774 133775 133776 133905 133929 134238 134327 134760 134761 134763 134764 134769 134770 134771 134835 134963 135061 135290 135300 135330 135377 135629 137693 137697 137699 137753 137784 137785 137787 137788 137876 137969 138366 138407 138607 138915 138949 138950 138952 138982 138994 139007 139018 139124 139144 139201 139203 139220 139316 139327 139726 139887 140096 140596 14061 140701 140716 140717 140720 140723 140979 141157 14117 141180 14140 142570 14576 14618 149167 15169 16276 16509 16591 16629 17043 174 17428 17707 177453 177549 17788 17789 17790 17791 18013 18228 18403 18450 18599 18734 18978 195 19527 197099 19740 197540 198047 198651 199490 199506 199524 199883 200756 201094 201978 202053 20207 202675 203087 204601 204720 20473 20552 20554 206092 206204 206791 206798 207319 207400 207590 208425 208556 20860 209 211914 212708 213251 213375 21704 21769 21859 21887 22773 22884 23468 23724 23885 23959 23969 24088 24192 24424 24429 24940 2497 25429 25697 25820 25935 25961 26160 262187 263022 263196 263639 263693 264344 264509 26496 265443 265537 266706 267784 26818 269939 270110 27715 28429 28431 28438 28725 29066 2914 29286 29287 29802 30083 30823 31122 31235 31400 31898 32097 32098 3223 32505 3255 32613 3269 328608 3326 3329 34081 34248 34549 3457 3462 34947 35070 35212 35320 35540 35593 35804 35816 35908 35916 3598 36351 36352 36384 36385 36444 36492 36806 37963 37969 38001 38197 38283 38365 38538 38587 38588 38627 39284 394699 395003 395936 395954 395973 398101 40065 40676 40788 41009 41096 41264 41378 4184 4190 42652 42905 43289 43624 43989 45011 45012 45062 45076 45085 45090 45102 45102 45102 45103 45104 45139 45458 45566 45576 45629 45753 45899 45932 4637 46484 46844 4694 47232 47285 4755 4785 4788 47927 48024 48024 4816 4826 48337 4835 48905 49327 49588 49981 50297 50340 5056 50837 51852 52000 52228 52341 53089 54463 54538 54574 54600 54854 54994 55158 55330 55720 55799 55924 55933 55960 55967 55990 55992 56005 56011 5610 56109 5617 56222 57613 577 58073 58199 58461 58466 58519 58543 58563 58593 58772 58773 58774 58775 58776 58844 58854 58862 58879 59019 59028 59048 59050 59051 59052 59053 59054 59055 59067 59077 59374 60068 60592 60631 60798 61154 61317 61348 61577 61853 62044 62240 62468 62785 62904 63018 63023 63075 63288 63314 63545 63612 63620 63631 63655 63677 63678 63679 63727 63728 63729 63835 63838 63888 63916 63949 64050 6471 6584 6830 6876 6877 6939 7029 7224 7303 7489 7552 7684 792 793 794 8068 8069 8070 8071 8074 8075 8100 8220 8560 8881 8987 9009 9299 9312 9370 9534 9678 9952 9984 792 793 794 1215 1216 1217 3457 3598 4184 4816 4835 6584 7224 8068 8069 8070 8071 8074 8987 9009 9984 10453 12076 13658 14140 14618 16276 16509 16591 17043 17428 18599 19527 20554 21704 23468 23885 24192 24424 24429 25697 25935 26160 26818 31122 31235 31898 32613 35070 35540 35593 36384 36385 36492 36806 37963 37969 38283 38365 38538 38587 38627 41264 43624 43989 45062 45090 45102 45139 45566 45576 47927 48337 48905 54463 54854 55924 55967 55990 55992 54994 56005 56011 58461 58466 58519 58563 58593 58844 58854 58862 59019 59048 59050 59067 59077 61577 62785 63075 63314 63545 63612 63631 63655 63677 63678 63679 63835 63838 63949 64050 131444 131486 131495 132203 132509 132591 133492 133774 133775 133776 134238 134417 134418 134420 134543 134649 134756 134763 134764 134769 134771 135061 135629 136160 136188 136190 136958 136959 136970 137218 137280 137539 137693 137697 137699 137784 137785 137788 138407 138950 138952 139007 139018 139201 139203 139220 202053 202675 204720 263022 263639 264344 264509 265443 394699 395936 395973} and not cf.client.bot)Reference
[Updated] Finally, the Cloudflare firewall rules are set up, now you can rest assured
https://hostloc.com/thread-960122-1-1.html (Source: Global Hosting Forum)[Cloudflare Block Bad Bot Ruleset][2]