Last active
October 13, 2023 00:07
-
-
Save emtudo/fe0c178b8a285a3f40552cc16e921cd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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