i wonder if anyone with a keen eye can help me. It appears podman adds multiple PTR records which prevents stops me from using socket.gethostbyaddr as it only returns the last answer in alpine. I decided to try dnspython, however, i cannot seem to get it to return any PTR's:
Note: podman DNS is 10.89.0.1. i statically configured for testing but by default it would pick this up from resolv.conf
#dnspython 2.2.1
resolver = dns.resolver.Resolver()
resolver._nameservers=['10.89.0.1']
print(resolver._nameservers)
lookup = 'database'
ips = resolver.query(lookup, 'A')
for ip in ips:
ip = str(ip)
print(f"database IP:{ip}")
try:
answer = resolver.resolve_address(ip)
print(answer)
except Exception as e:
print("error:",e)
when i run this code i get:
['10.89.0.1'] database IP:10.89.0.223 error: The DNS response does not contain an answer to the question: 223.0.89.10.in-addr.arpa. IN PTR
If i complete a capture, i see the response come back as expected :
Domain Name System (response)
Transaction ID: 0xc291
Flags: 0x8100 Standard query response, No error
Questions: 1
Answer RRs: 3
Authority RRs: 0
Additional RRs: 0
Queries
223.0.89.10.in-addr.arpa: type PTR, class IN
Name: 223.0.89.10.in-addr.arpa
[Name Length: 24]
[Label Count: 6]
Type: PTR (domain name PoinTeR) (12)
Class: IN (0x0001)
Answers
<Root>: type PTR, class IN, database_1
<Root>: type PTR, class IN, database
<Root>: type PTR, class IN, 6a5f9e86a946
[Request In: 1057]
[Time: 0.000069000 seconds]
Can anyone help me understand why the python code is not performing as expected?
I get the correct response when using DIG
dig +short @10.89.0.1 PTR 223.0.89.10.in-addr.arpa.
database_1.
database.
6a5f9e86a946.
dig +short @10.89.0.1 -x 10.89.0.223
database_1.
database.
6a5f9e86a946.
Thanks in advance for your help.
tried the same query using dig