python从ip获取主域名

I need to get primary domain name from ip. I have some doubts about how functions like gethostbyaddr and getfqdn work.

在以下示例中,我将反向IP随机域,然后尝试重新获得域名:

import socket

domain = 'heroku.com'

# get ip from domain
ip = socket.gethostbyname(domain)
print('ip =', ip)

# get domain from ip
print(socket.gethostbyaddr(ip))
print(socket.getfqdn(ip))

# OUTPUT
# ip = 50.19.85.154
# ('ec2-50-19-85-154.compute-1.amazonaws.com', ['154.85.19.50.in-addr.arpa'], ['50.19.85.154'])
# ec2-50-19-85-154.compute-1.amazonaws.com

It seems both gethostbyaddr and getfqdn are returning the public DNS of one of the load balanced ec2 on AWS. My question is why they don't return the domain heroku.com which is probably the domain registered on Route53?

Another example with google.com:

import socket

domain = 'google.com'

# get ip from domain
ip = socket.gethostbyname(domain)
print('ip =', ip)

# get domain from ip
print(socket.gethostbyaddr(ip))
print(socket.getfqdn(ip))

# OUTPUT
# ip = 216.58.208.174
# ('mil07s10-in-f14.1e100.net', ['174.208.58.216.in-addr.arpa', 'lhr25s09-in-f14.1e100.net', 'lhr25s09-in-f174.1e100.net'], ['216.58.208.174'])
# mil07s10-in-f14.1e100.net

Here again it seems they are returning the public DNS of some machine on GCP. How can I get the real primary domain name from an ip address (heroku.com and google.com in these examples)?