Mass change of IPs on Linode DNS
Has anyone made a script or anything already?
1 Reply
Here's a quick and dirty script I used the last time I did it:
#!/usr/bin/python
import api
instance = api.Api(key='yourkeyhere')
for domain in instance.domain_list():
if domain['TYPE'] == 'master':
print("Updating %s (%i)..." % (domain['DOMAIN'], domain['DOMAINID']))
for resource in instance.domain_resource_list(domainid=domain['DOMAINID']):
if resource['TYPE'] == 'AAAA' and resource['TARGET'] == '2001:470:1f06:f41::2':
print('Old AAAA Record Found: %s.%s (%i)' % (resource['NAME'], domain['DOMAIN'], resource['RESOURCEID']))
newresid = instance.domain_resource_create(domainid=domain['DOMAINID'], type='AAAA', name=resource['NAME'], target='2001:470:1f07:f41::dead:beef')
print(' Created resource %i' % newresid['ResourceID'])
oldresid = instance.domain_resource_delete(domainid=domain['DOMAINID'], resourceid=resource['RESOURCEID'])
print(' Deleted resource %i' % oldresid['ResourceID'])
elif resource['TYPE'] == 'A' and resource['TARGET'] == '67.18.176.246':
print('Old A Record Found: %s.%s (%i)' % (resource['NAME'], domain['DOMAIN'], resource['RESOURCEID']))
newresid = instance.domain_resource_create(domainid=domain['DOMAINID'], type='A', name=resource['NAME'], target='97.107.134.213')
print(' Created resource %i' % newresid['ResourceID'])
oldresid = instance.domain_resource_delete(domainid=domain['DOMAINID'], resourceid=resource['RESOURCEID'])
print(' Deleted resource %i' % oldresid['ResourceID'])