Greetings everyone.
I have made a small script that adds any IP in CF blacklist to prevent bot attacks for a website. It is working very well and Ι can even add IP ranges using /24 and so on. However, when I attempt to add ipv6 address, the API return an error with message - “invalid value for ip at position 0: filters.api.IPv6 IP addresses are not supported. We suggest using a /64 CIDR instead”.
I have tried adding /64 as well as /24 and others, but the API is still returning this error. So what’s the correct way to pass an ipv6 IP in the blacklist? I also tried converting ipv6 to 4, but some addresses cannot be converted.
Code used (Python):
url = “https://api.cloudflare.com/client/v4/accounts/…”
payload = ‘[{“ip”: "’ + ip +’", “comment”: “blocked from script.”}]’
headers = {
‘X-Auth-Email’: ‘[email protected]’,
‘X-Auth-Key’: ‘123…’,
‘Content-Type’: ‘application/json’}
response = requests.request(“POST”, url, headers=headers, data = payload)
print(response.text.encode(‘utf8’))