将公司所有阿里云ecs外网ip添加到cloudflare waf白名单里:
#!/bin/bash
# Author:
# cloudflare Email
CFEMAIL="bob.huo@orderplus.com"
# cloudflare API key
CFAPIKEY="f6f44711479c292***08959ed3060a8f3"
# cloudflare Zones ID
# ZONESID_orderplus="5d586460e***93969c4f23800f226b4"
# ZONESID_chimpone="ba6a1d4408c***0450e112fbb1f6d3"
ZONESID="5d586460e93***957cb69c00f226b4"
# /tmp/attack/ips.txt ip白名单
IPADDR=$(</tmp/ips.txt)
for IPADDR in ${IPADDR[@]}; do
echo $IPADDR
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONESID/firewall/access_rules/rules" \
-H "X-Auth-Email: $CFEMAIL" \
-H "X-Auth-Key: $CFAPIKEY" \
-H "Content-Type: application/json" \
--data '{"mode":"whitelist","configuration":{"target":"ip","value":"'$IPADDR'"},"notes":"aliyun_server_ip"}'
done
#
#rm -rf /tmp/attack/ips.txt
~