def getMyIPv6(config, verbose = 0):
'''Returns our current IPv6 address, detected as given by the configuration'''
def local():
- out = subprocess.check_output(["ip", "addr"])
+ device = config["IPv6"].get("device")
+ out = subprocess.check_output(["ip", "addr", "show"] + ([] if device is None else ["dev", device]))
for line in out.decode('utf-8').split('\n'):
m = re.search('inet6 ([a-fA-F0-9:]+)/64 ([a-zA-Z0-9 ]*)', line)
if m is not None:
# web: Call a website to detect the current, external IPv4 address.
method = web
-# The server to query for web-based IPv4 detection (if enabled).
+# The server to query for web-based IPv4 detection (method = web).
# Default: same as the global server in the default section.
# This server should NOT have an AAAA record, or it may return the IPv6 address instead!
server = ipv4.ns.example.com
# local: Try to detect the global IPv6 address based on the configuration of the local network interfaces.
method = none
-# The server to query for web-based IPv6 detection.
+# The server to query for web-based IPv6 detection (method = web).
# Default: same as the global server in the default section.
# This server should NOT have an A record, or it may return the IPv4 address instead!
server = ipv6.ns.example.com
+# The network device of which to use the IPv6 address for local detection (method = local).
+# If left unset, pick any device.
+device = eth0