Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
API_KEY="SUA CHAVE SECRETA AQUI"
API_EMAIL="seu email"
ZONE_ID="ZONA DNS"
DOMINIO="dominio.com"
#Lista os registros, necessário para pegar o id para alterar a zona DNS
#curl -X GET "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \
DNS_ID1="ID DO DNS, PEGA NA LISTA A CIMA"
DNS_ID2="ID DO DNS, PEGA NA LISTA A CIMA"
DNS_ID3="ID DO DNS, PEGA NA LISTA A CIMA"
DNS_ID4="ID DO DNS, PEGA NA LISTA A CIMA"
#Atualiza IPV6
ipv6=`ifconfig eth0 | grep "inet6: 2804:" | cut -d/ -f1 | cut -d: -f2- | cut -d ' ' -f2 | tail -n 1`
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_ID3}" \
-H "X-Auth-Email:${API_EMAIL}" \
-H "Content-Type: application/json" \
-H "X-Auth-Key:${API_KEY}" \
--data '{"type":"AAAA","name":"'${DOMINIO}''","content":"'${ipv6}'","ttl":1}'
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_ID4}" \
-H "X-Auth-Email:${API_EMAIL}" \
-H "Content-Type: application/json" \
-H "X-Auth-Key:${API_KEY}" \
--data '{"type":"AAAA","name":"www.'${DOMINIO}''","content":"'${ipv6}'","ttl":1}'
#Atualiza IPV4
#ipv4=`curl ifconfig.me/ip`
#curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_ID1}" \
# -H "X-Auth-Email:${API_EMAIL}" \
# -H "Content-Type: application/json" \
# -H "X-Auth-Key:${API_KEY}" \
# --data '{"type":"A","name":"'${DOMINIO}''","content":"'${ipv4}'","ttl":1,"proxied":true}'
#
#curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_ID2}" \
# -H "X-Auth-Email:${API_EMAIL}" \
# -H "Content-Type: application/json" \
# -H "X-Auth-Key:${API_KEY}" \
# --data '{"type":"A","name":"www.'${DOMINIO}''","content":"'${ipv4}'","ttl":1,"proxied":true}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.