2 # on the virsh containers, DNS resolution using gethostbyaddr
3 # won't work fine, for the hosts under .pl.sophia.inria.fr
4 # although these IPs can be reversed from virtually everywhere else
6 # this has started with something around fedora35 so I am suspecting python-3.10
8 # in any case, here's a quick and dirty workaround, as I have bumped my head
9 # against the screen for two good hours and not found any single clue
10 # about how to deal with this properly
15 def workaround_gethostbyaddr(ip):
17 return socket.gethostbyaddr(ip)[0]
19 # if that fails, try again using the `host` command
20 # which - surprisingly enough - works quite fine
21 # inside the containers
22 command = f"host {ip} 8.8.8.8"
23 completed = subprocess.run(command, shell=True, capture_output=True)
24 pieces = completed.stdout.decode().split("domain name pointer ")
26 return pieces[1].replace(".\n", "")