commit 01ce4f7eb340319f10b60ff288ba4333a85bb54d Author: florian Date: Wed Jan 13 17:22:10 2021 +0100 initial version diff --git a/ipv6_reversedns.py b/ipv6_reversedns.py new file mode 100755 index 0000000..f9976fd --- /dev/null +++ b/ipv6_reversedns.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import socket + +def my_ipv6(): + # for udp no packet is sent + s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) + try: + # 2001:db8::/32 is used for documentation and example source code + s.connect(('2001:db8::', 1027)) + except socket.error: + return None + return s.getsockname()[0] + + +def main(): + returncode = 0 + state = 'OK' + my_ip = my_ipv6() + result = '' + try: + reversedns = socket.gethostbyaddr(my_ip) + result = f'{my_ip} resolves to {reversedns[0]}' + except Exception as error: + returncode = 2 + state = 'CRITICAL' + result = error + + + print(f'{returncode} reversedns_ipv6 - {state} {result}') + + +if __name__ == '__main__': + main() + +