diff --git a/src/example.config.py b/src/example.config.py index 7ac37fc..8775ce6 100644 --- a/src/example.config.py +++ b/src/example.config.py @@ -20,7 +20,7 @@ ''' api_endpoint = 'https://dns.api.gandi.net/api/v5' -#your domain with the subdomains in the zone file/UUID +#your domain with the subdomains in the zone file/UUID domain = 'mydomain.tld' #enter all subdomains to be updated, subdomains must already exist to be updated @@ -29,13 +29,13 @@ #300 seconds = 5 minutes ttl = '300' -''' -IP address lookup service +''' +IP address lookup service run your own external IP provider: + https://github.com/mpolden/ipd + -e.g. +e.g. + https://ifconfig.co/ip + http://ifconfig.me/ip + http://whatismyip.akamai.com/ @@ -43,3 +43,9 @@ + many more ... ''' ifconfig = 'choose_from_above_or_run_your_own' + + +''' +Target domain you wish to update your domain to. +''' +target_domain = 'target_domain_you_wish' diff --git a/src/gandi-live-dns.py b/src/gandi-live-dns.py index 55e5757..ea8d6d9 100755 --- a/src/gandi-live-dns.py +++ b/src/gandi-live-dns.py @@ -15,7 +15,14 @@ import requests, json import config import argparse +import socket +def get_DomainIp(target_domain): + ''' Get IPv4 of target domainself. + This is the IP address of another domain you wish to update your own domain to + ''' + ipaddress = socket.gethostbyname(target_domain) + return ipaddress def get_dynip(ifconfig_provider): ''' find out own IPv4 at home <-- this is the dynamic IP which changes more or less frequently @@ -89,7 +96,7 @@ def update_records(uuid, dynIP, subdomain): -def main(force_update, verbosity): +def main(force_update, verbosity, d2dmode): if verbosity: print "verbosity turned on - not implemented by now" @@ -97,11 +104,14 @@ def main(force_update, verbosity): #get zone ID from Account uuid = get_uuid() - - #compare dynIP and DNS IP - dynIP = get_dynip(config.ifconfig) + + #compare dynIP and DNS IP + if d2dmode: + dynIP = get_DomainIp(config.target_domain) + else: + dynIP = get_dynip(config.ifconfig) dnsIP = get_dnsip(uuid) - + if force_update: print "Going to update/create the DNS Records for the subdomains" for sub in config.subdomains: @@ -118,13 +128,8 @@ def main(force_update, verbosity): parser = argparse.ArgumentParser() parser.add_argument('-v', '--verbose', help="increase output verbosity", action="store_true") parser.add_argument('-f', '--force', help="force an update/create", action="store_true") + parser.add_argument('-d', '--d2d', help="domain to domain mode", action="store_true") args = parser.parse_args() - - - main(args.force, args.verbose) - - - - + main(args.force, args.verbose, args.d2d)