Commit 690c094e authored by Andreas Kempe's avatar Andreas Kempe
Browse files

Add nsupdate invocation with requested IP.

TODO: Add support for IPv6 records.
parent a1efc97a
#!/usr/bin/env python3
import socket
import argparse
import os
import socket
import ssl
import ip_query_pb2
......@@ -20,14 +21,27 @@ def request_address(address, port, cert):
return answer.address
def nsupdate(domain_server, domain, ip):
res = os.system('''nsupdate -k key.key -p 2223 <<EOF
server {}
update delete {}
update add {} 600 A {}
send'''.format(domain_server, domain, domain, ip))
if res != 0:
print('Got an error when updating the domain!')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='LysNS IP update client.')
parser.add_argument('server', type=str, help='Server address.')
parser.add_argument('port', type=int, help='Server port.')
parser.add_argument('cert', type=str, help='Public certificate for the server.')
parser.add_argument('domain_server', type=str, help='The address of the DNS server you wish to update.')
parser.add_argument('domain', type=str, help='The domain record you wish to update.')
parser.add_argument('--ipv6', action='store_true', help='Perform an IPv6 update.')
args = parser.parse_args()
address = request_address(args.server, args.port, args.cert)
print('Got {} from the server.'.format(address))
nsupdate(args.domain_server, args.domain, address)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment