I'm not very good at programming but what I'd like to do is have a Python script that would do certain actions depending on whether a domain has its nameservers pointed to X or whether it has a CNAME record pointed to X specific IP.
So basically: if domain has CNAME pointed to X do Y if domain has nameservers pointed to X1 and X2 do Z.
Does anyone know how that could be done?
EDIT: I've tried the following (with proper tabs of course) only the result is always 'No' even though the CNAME does point to what I've set. I'm probably misunderstanding something somewhere.
domain = 'example.com'
answers = dns.resolver.resolve(domain,'CNAME')
for server in answers:
print(server.target)
if server.target == 'xdomain.org':
print("Yes")
else:
print("No")