How to make IPV6 with api call?


#1

Hi to community

Hope I will find a newbie explanation about the disabling ipv6 via api.

As I see I can’t disable the IPV6 via dashboard, I need to make an API call. but honestly I dont know how to do it.

The doc is here : https://api.cloudflare.com/#zone-settings-get-ipv6-setting

Is there anybody here explain me how to do it?

Regards

Arda


#2

This is the API for ipv6 on/off
https://api.cloudflare.com/#zone-settings-change-ipv6-setting

That long curl command is how you do it from command line. Just be sure to change the funky number strings to your Zone ID and API key, plus your Cloudflare email address. Your Zone ID is on your Cloudflare Overview page.


#3

Hi,

Thanks for your help. I know this page. However I am not a coder and my friend who know php dont understand how to do it.

how to do this?

From my server console ( ubuntu )?

or a php file in my server.

Honestly I need a sample code which I can change zone id, api key…etc and upload to my server.

Hope you guys have time to send me a sample code and teach me how to use it myself as a non-techie guy like me

Thanks in advance.


#4

I believe this should do it:

curl -X PATCH “https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/settings/ipv6
-H “X-Auth-Email: [email protected]
-H “X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41”
-H “Content-Type: application/json”
–data ‘{“value”:“off”}’


#5

This should get your zone ID if you need it.

curl -X GET “https://api.cloudflare.com/client/v4/zones?name=example.com&status=active&page=1&per_page=20&order=status&direction=desc&match=all
-H “X-Auth-Email: [email protected]
-H “X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41”
-H “Content-Type: application/json”


#6

Thanks mate. I am not a coder. Can you explain what to do with this beautiful code? :slightly_frowning_face:

Where to type this and get the response?

Regards


#7

I have below info:

Zone id
Api key
Email address


#8

Curl is a command line utility. If you have a mac you can probably do it straight from the terminal. On a linux machine you can run it fro the command line.

In the second instance replace name=example.com with the domain you want to change and replace email and auth-key with your values it should return a response in the terminal with the zoneID for your zone.

In the first example replace 023e105f4ecef8ad9ca31a8372d0c353 with your zone ID and again replace the email and auth-key values with your own.

A tutorial on curl that might help (or hurt… it was clearly written by a geek). https://curl.haxx.se/docs/httpscripting.html


#9
  1. I have my zone id which I copied from my domain dashboard in cloudflare. Do I need to do the zone id step you did?

  2. For mac, in the terminal, is it ok just copy the code above and paste and enter right after the terminal window open?

3 Or I need to do above steps in my server console ( ubuntu )?

Regards


#10

If you have your zone ID you don’t need to look it up again (unless you just want to practice your newfound curl skills). You should be able to copy/ paste the code from the first example right into the terminal window and hit enter. Steps can be run from any machine… it’s changing a Cloudflare setting (no changes to the origin).


#11

so which fields I need to change with mine?
I have:

“myzoneID”
“myAPIkey”
“myemail”

Regards


#12

Mate ,

I tried this

curl -X PATCH “https://api.cloudflare.com/client/v4/zones/ZONEID/settings/ipv61”
-H “X-Auth-Email: MYEMAIL”
-H “X-Auth-Key: MYAPIKEY”
-H “Content-Type: application/json”
–data ‘{“value”:“off”}’

Used terminal and directly pasted and hit enter. It says - curl: (1) Protocol ““https” not supported or disabled in libcurl


#13

ugh… nothing is ever easy right? :wink:

I haven’t encountered this exact error before but take a look at this article: https://stackoverflow.com/questions/19015282/how-do-i-enable-https-support-in-libcurl


#14

Hey mate,

The problem is not https protocol, but the first code you shared above. Actually code is the same as in the api doc but when I copy it, there was a " 1 " right after the api link. so it is like

curl -X PATCH “https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/settings/ipv61”

but it should:

curl -X PATCH “https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/settings/ipv6”

Now it is working fine. I changed the ipv6 from on to off!!

Thanks a lot again mate

Cheers