Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/bin/sh
  2. cfkey=
  3. cfuser=
  4. cfhost=
  5. zoneid=
  6. dnsrecid=
  7. dnsrecidipv6=
  8. cacheIP=`cat /tmp/ip_cloudflare`
  9. currentIP=`ifconfig pppoe-wan | grep 'inet addr' | cut -d ':' -f 2 | cut -d ' ' -f 1`
  10. currentIPv6=`ifconfig br-lan | grep 'inet6 addr' | cut -d '/' -f 1 | cut -d 'r' -f 2 | sed '2d' | cut -c3- | sed -n 1p`
  11.  
  12. # Если текущий IP не равен кешированному тогда...
  13. if [ "$currentIP" != "$cacheIP" ]
  14. then
  15. #
  16.  
  17. sleep 10
  18.  
  19. currentIPa=`ifconfig pppoe-wan | grep 'inet addr' | cut -d ':' -f 2 | cut -d ' ' -f 1`
  20. currentIPv6a=`ifconfig br-lan | grep 'inet6 addr' | cut -d '/' -f 1 | cut -d 'r' -f 2 | sed '2d' | cut -c3- | sed -n 1p`
  21.  
  22. echo "Updating CloudFlare DNS with" $currentIPa
  23. echo `date` "IP" $currentIPa >> /var/log/dns-update.log
  24. mkdir /tmp/cloudflare
  25. #
  26.  
  27. # ipv4
  28. curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/$dnsrecid" \
  29. -H "X-Auth-Email: $cfuser" \
  30. -H "X-Auth-Key: $cfkey" \
  31. -H "Content-Type: application/json" \
  32. --data '{"id":"'$dnsrecid'","type":"A","name":"'$cfhost'","content":"'$currentIPa'","proxiable":true,"proxied":true}' \
  33. -o /tmp/cloudflare/cloudflare.domain.$cfhost
  34.  
  35.  
  36. # Кешируем текущий IP
  37. echo $currentIPa > /tmp/ip_cloudflare
  38.  
  39. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement