将公司所有阿里云ecs外网ip添加到cloudflare waf白名单里:

    1. #!/bin/bash
    2. # Author:
    3. # cloudflare Email
    4. CFEMAIL="bob.huo@orderplus.com"
    5. # cloudflare API key
    6. CFAPIKEY="f6f44711479c292***08959ed3060a8f3"
    7. # cloudflare Zones ID
    8. # ZONESID_orderplus="5d586460e***93969c4f23800f226b4"
    9. # ZONESID_chimpone="ba6a1d4408c***0450e112fbb1f6d3"
    10. ZONESID="5d586460e93***957cb69c00f226b4"
    11. # /tmp/attack/ips.txt ip白名单
    12. IPADDR=$(</tmp/ips.txt)
    13. for IPADDR in ${IPADDR[@]}; do
    14. echo $IPADDR
    15. curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONESID/firewall/access_rules/rules" \
    16. -H "X-Auth-Email: $CFEMAIL" \
    17. -H "X-Auth-Key: $CFAPIKEY" \
    18. -H "Content-Type: application/json" \
    19. --data '{"mode":"whitelist","configuration":{"target":"ip","value":"'$IPADDR'"},"notes":"aliyun_server_ip"}'
    20. done
    21. #
    22. #rm -rf /tmp/attack/ips.txt
    23. ~