• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

How to Disable Cloudflare Firewall Rule Using API

AnonyViet by AnonyViet
January 1, 2023
in Network
0

Use the API to start the Cloudflare Rule against DDOS.

Get Cloudflare Token API and ZoneID

First you need to get the Global API of your CloudFlare account:

At Menu Overview click Get your API token -> Select Global API Key -> View -> Enter Password -> Copy Token into Notepad to use slice. This is also called Authen Key

Get Cloudflare Token API
Get Cloudflare Token API

At Menu Overview Click on Zone ID: copy the sequence of numbers into Notepad to use later

zone id cloudflare

Get RULEs on Cloudflare account

It is best to set up the Rule on the interface first: Menu Security -> WAF -> Firewall Rule

set up cloudflare rules

I will create a Rule Block User-Agent as shown in the picture:

create a cloudflare firewall rule

Next, use the Curl command to get the ID and information of the established rules.

curl -X GET \
"https://api.cloudflare.com/client/v4/zones/[Zone ID]/firewall/rules" \
-H "X-Auth-Email: email đănh nhập Cloudflare" \
-H "X-Auth-Key: [API Token]"

Eg:

curl -X GET \
"https://api.cloudflare.com/client/v4/zones/9572d3eddf3475ca760b419a63e79536/firewall/rules" \
-H "X-Auth-Email: [email protected]" \
-H "X-Auth-Key: 89d37c93f93aac745180247542d8xxxxxxx96b"

Result:

curl -X GET \"https://api.cloudflare.com/client/v4/zones/9572d3eddf3475ca760b419a63e79536/firewall/rules" \ -H "X-Auth-Email: [email protected]" \ -H "X-Auth-Key: 89d37c93f93aac745180247542d8xxxxxxx96b" { "result": [
    {
     {
      "id": "aa345072f8244340b3264167ba51662b",
      "paused": true,
      "description": "Block User-Agent",
      "action": "block",
      "priority": 46,
      "filter": {
        "id": "efcd9a8a55f34fea8e43a98765e463d2",
        "expression": "(http.user_agent contains \"DDoS\") or (http.user_agent contains \"Darryl\") or (http.user_agent contains \"censys\") or (http.user_agent contains \"shodan\") or (http.user_agent contains \"shodan\")",
        "paused": true
      },
      "created_on": "2022-06-16T06:09:59Z",
      "modified_on": "2022-08-18T12:12:42Z"
    }

Cần ghi lại các thông tin sau để có thể tự động bật/tắt các Rule bằng API của Cloudflare

  • “id”: “aa345072f8244340b3264167ba51662b”, : <RULE_ID>
  • “paused”: false, : false là Rule đang được bật, true là Rule đang tắt
  • “description”: “Block User-Agent”,  : Đặt tên cho Rule
  • “id”: “efcd9a8a55f34fea8e43a98765e463d2”, : <FILTER_ID>

Bật Rule Firewall Cloudflare bằng API

Sau khi đã có đầy đủ thông tin về ID Rule, ID Filter, chúng ta dùng lệnh PUT để cập nhật trạng thái cho Rule Firewall Cloudflare

Cấu trúc của lệnh PUT như sau:

curl -X PUT \
"https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/firewall/rules/<RULE_ID>" \
-H "X-Auth-Email: email đănh nhập Cloudflare" \
-H "X-Auth-Key: [API Token]"\ -H "Content-Type: application/json" \ -d '{ "paused": false, "description": "Name the Rule", "action": "allow", "priority": 1, " filter": { "id": "", "expression": "(http.user_agent contains \"DDoS\"), "paused": false, "description": "Name the Rule" } }'

For example, to turn this Rule on, we adjust the value of paused are from true Fort false. That is, switch from off to on. Remember yes 2 value paused Please.

curl -X PUT "https://api.cloudflare.com/client/v4/zones/9572d3eddf3475ca760b419a63e79536/firewall/rules/aa345072f8244340b3264167ba51662b" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: 89d37c93f93aac745180247542d8xxxxxxx96b" \
     -H "Content-Type: application/json" \
     --data '{
     "action": "block",
     "priority": 46,
     "paused":false,
     "description": "Block User-Agent",
     "filter": {
    "id": "efcd9a8a55f34fea8e43a98765e463d2",
    "expression": "(http.user_agent contains \"DDoS\") or (http.user_agent contains \"Darryl\") or (http.user_agent contains \"censys\") or (http.user_agent contains \"shodan\") or (http.user_agent contains \"shodan\")",
    "paused": false,
    "description": "Block User Agent"
  }
  }'

Results are returned “success”: trueis success.

curl -X PUT "https://api.cloudflare.com/client/v4/zones/9572d3eddf3475ca760b419a63e79535/firewall/rules/aa345072f8244340b3264167ba51662b" \
         -H "X-Auth-Email: [email protected]" \
         -H "X-Auth-Key: 89d37c93f93aac745180247542d8xxxxxxx96b" \
     -H "Content-Type: application/json" \
     --data '{
         "action": "block",
         "priority": 47,
         "paused":false,
         "description": "Block User-Agent",
         "filter": {
    "id": "efcd9a8a55f34fea8e43a98765e463d2",
    "expression": "(http.user_agent contains \"DDoS\") or (http.user_agent contains \"Darryl\") or (http.user_agent contains \"censys\") or (http.user_agent contains \"shodan\") or (http.user_agent contains \"shodan\")",
    "paused": false,
    "description": "Block User Agent"
  }
  }'
{
  "result": {
    "id": "aa345072f8244340b3264167ba51662b",
    "paused": false,
    "description": "Block User-Agent",
    "action": "block",
    "priority": 47,
    "filter": {
      "id": "efcd9a8a55f34fea8e43a98765e463d2",
      "expression": "(http.user_agent contains \"DDoS\") or (http.user_agent contains \"Darryl\") or (http.user_agent contains \"censys\") or (http.user_agent contains \"shodan\") or (http.user_agent contains \"shodan\")",
      "paused": false
    },
    "created_on": "2022-08-18T12:05:32Z",
    "modified_on": "2022-08-30T15:11:46Z",
    "index": 1
  },
  "success": true,
  "errors": [],
  "messages": []
}

In the next article, we will study Enable Rule Cloudflare automatically when CPU is high and Disable Rule automatically when CPU is low. Avoid the case of DDoS crashing the Server.

The article achieved: 5/5 – (101 votes)

Tags: APICloudflareDisableFirewallRule
Previous Post

SOS feature on iPhone 14 via satellite saved a person’s life stranded in Alaska

Next Post

Summarizing the DDos Event on AnonyViet’s goal

AnonyViet

AnonyViet

Related Posts

Guide to self -creation socket5 on Ubuntu
Network

Guide to self -creation socket5 on Ubuntu

May 28, 2025
How to create a separate mtproto proxy to use Telegram when blocked
Network

How to create a separate mtproto proxy to use Telegram when blocked

May 25, 2025
Script backup database and website on telegram
Network

Script backup database and website on telegram

May 2, 2025
Create 64GB RAM 16 core for free on Google IDX
Network

Create 64GB RAM 16 core for free on Google IDX

April 13, 2025
What is VPS running Vietnamese software? What is the reason for installing Vietnamese software on VPS?
Network

What is VPS running Vietnamese software? What is the reason for installing Vietnamese software on VPS?

February 17, 2025
Create Ronin wallet to play pixels on VPS Windows
Network

Create Ronin wallet to play pixels on VPS Windows

February 17, 2025
Next Post
Summarizing the DDos Event on AnonyViet’s goal

Summarizing the DDos Event on AnonyViet's goal

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
Discover the glowing effect next to the iPhone ios 18 screen

Discover the glowing effect next to the iPhone ios 18 screen

June 8, 2025
[Godot Shooter] #2: Creating characters & shooting bullets

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025
Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
Discover the glowing effect next to the iPhone ios 18 screen

Discover the glowing effect next to the iPhone ios 18 screen

June 8, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET https://kubet88.yoga/ bj88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET https://kubet88.yoga/ bj88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply