Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- cfkey=
- cfuser=
- cfhost=
- zoneid=
- dnsrecid=
- dnsrecidipv6=
- cacheIP=`cat /tmp/ip_cloudflare`
- currentIP=`ifconfig pppoe-wan | grep 'inet addr' | cut -d ':' -f 2 | cut -d ' ' -f 1`
- currentIPv6=`ifconfig br-lan | grep 'inet6 addr' | cut -d '/' -f 1 | cut -d 'r' -f 2 | sed '2d' | cut -c3- | sed -n 1p`
- # Если текущий IP не равен кешированному тогда...
- if [ "$currentIP" != "$cacheIP" ]
- then
- #
- sleep 10
- currentIPa=`ifconfig pppoe-wan | grep 'inet addr' | cut -d ':' -f 2 | cut -d ' ' -f 1`
- currentIPv6a=`ifconfig br-lan | grep 'inet6 addr' | cut -d '/' -f 1 | cut -d 'r' -f 2 | sed '2d' | cut -c3- | sed -n 1p`
- echo "Updating CloudFlare DNS with" $currentIPa
- echo `date` "IP" $currentIPa >> /var/log/dns-update.log
- mkdir /tmp/cloudflare
- #
- # ipv4
- curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/$dnsrecid" \
- -H "X-Auth-Email: $cfuser" \
- -H "X-Auth-Key: $cfkey" \
- -H "Content-Type: application/json" \
- --data '{"id":"'$dnsrecid'","type":"A","name":"'$cfhost'","content":"'$currentIPa'","proxiable":true,"proxied":true}' \
- -o /tmp/cloudflare/cloudflare.domain.$cfhost
- # Кешируем текущий IP
- echo $currentIPa > /tmp/ip_cloudflare
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement