Created
February 28, 2019 12:56
-
-
Save gamcoh/f9b6b71ba12ebfe0a6aa62e8d381b90b to your computer and use it in GitHub Desktop.
Change OVH DNS
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
# -*- encoding: utf-8 -*- | |
import ovh | |
# Instantiate. Visit https://api.ovh.com/createToken/?GET=/me | |
# to get your credentials | |
client = ovh.Client( | |
endpoint='ovh-eu', | |
application_key='<your application key>', | |
application_secret='<your application secret>', | |
consumer_key='<your consumer key>' | |
) | |
TARGET_IP = 'YOUR IP' | |
def main(): | |
domains = client.get('/domain/zone') | |
for domain in domains: | |
zoneInfos = client.get('/domain/zone/{}'.format(domain)) | |
# if it is registered on cloudflare | |
if 'ovh' not in zoneInfos['nameServers'][0]: | |
continue | |
records = client.get('/domain/zone/{}/record'.format(domain), fieldType='A') | |
for record in records: | |
client.put('/domain/zone/{}/record/{}'.format(domain, record), target=TARGET_IP) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment