Block All Country IPs Except Google,Yandex,Bing Bots

What exactly do I need to do to block all country IPs except, my country IPs, Google Yandex Bing Bots?

Many of the IP addresses of search engines like Google are writing differently on the sites. Also can these search engines’ IPs change?

Please help me.
Thanks to Cloudflare.

You can try a Firewall Rule that’s structured something like this:

If COUNTRY not equal to YOURS, and NOT KNOWN BOT, then Block.

I expect there will some gotchas, as this is a pretty heavy handed block.

2 Likes

So,

Field -Country
Operation - Does not equal
Value - my country

AND

Field - Known Bots
Operation - Equals
Value - On

Then BLOCK.

is this right? By the way, Are bots in KNOWN BOTS updated sometimes?

The Known Bots should have an operation of Does Not Equal. That way Google, Yandex, and Bing bots won’t get get blocked:

Block IF NOT your country, AND NOT a bot.

Blocks foreigners who aren’t bots.
Allows foreigners who are bots.
Allows locals who aren’t bots.
Allows locals who are bots.

2 Likes

For the known bots option, I can’t make a choice as it does not equal. As it appears in the picture. How should I make a change?

It basically should be

(ip.geoip.country ne "US") and (not cf.client.bot)

However keep in mind, cf.client.bot encompasses more than the mentioned crawlers, so that configuration will not only allow Yandex, Bing, and Google but all crawlers which are recognised by Cloudflare.

4 Likes

I got it. I never thought it would be so easy. Good that Cloudflare is alive. :man_dancing:
Well, Also, is there a way to block the spam bots coming from my own country? After all, my site is serving this country. I can’t prevent Country Ip.

How do I solve this? My last question :slight_smile:

You can play with cf.threat_score, but there is no guarantee Cloudflare tracks all of them. A site-wide captcha is probably not an option, so you could either implement a comment captcha or try to find another metric by which you can recognise them.

1 Like

Thanks a lot. Boss :slight_smile:

This topic was automatically closed after 30 days. New replies are no longer allowed.