2

I am using Python 3.7 socket to get the FQDN, fully qualified domain name. It works for some, e.g.

socket.getfqdn('indiana.edu')
'www.indiana.edu'

and doesn't work for others, e.g.

socket.getfqdn('google.com')
'lga34s18-in-f14.1e100.net'

Using lga34s18-in-f14.1e100.net in the browser gives the 404 error, url not found.

Ok, google.com is just one example. Here is another one:

socket.getfqdn('www.finastra.com')
'ec2-52-51-237-24.eu-west-1.compute.amazonaws.com'

And using url 'ec2-52-51-237-24.eu-west-1.compute.amazonaws.com' doesn't work, obviously. So they host their website on AWS, but why does socket return it as the FQDM, isn't 'finastra.com' the FQDM?

David Makovoz
  • 1,766
  • 2
  • 16
  • 27
  • 1
    Related reading: https://support.google.com/faqs/answer/174717?hl=en – dspencer Apr 06 '20 at 02:36
  • What are you trying to do? `google.com` is fully qualified, why push that into `getfqdn`? `getfqdn` is probably meant to resolve local names, i.e., `getfqdn("router') == "gateway.mynetwork"`. – Robert Apr 06 '20 at 03:36
  • Ok, a fair question. What i'm trying to do is to resolve some ip addresses I have to FQDN . I can't share those addresses, all I can say that they are supposed to resolve to some "simple" domain names, like google.com or finastra.com, but resolve to something similar to what I get for these two. Once it happened to those ip's, I decided to try google.com or finastra.com and discovered that they also produce some funny FQDNs. I hope this explains what I'm trying to do. – David Makovoz Apr 06 '20 at 04:07

1 Answers1

0

socket.getfqdn() calls socket.gethostbyaddr() (as stated in docs) to resolve the address. socket.gethostbyaddr() will issue a type A DNS request (if the domain is not on your hosts file) which will resolve to whatever the DNS of google.com or www.finastra.com is configured.

Using lga34s18-in-f14.1e100.net in the browser gives the 404 error, url not found.

This is because your browser sends a Host header which is filled with the hostname from the URL. A single webserver can serve content from different hosts. For example, the following request won't return a 404 Not Found:

curl ec2-52-51-237-24.eu-west-1.compute.amazonaws.com -H 'Host: www.finastra.com'

Removing -H 'Host: www.finastra.com' will cause the request to issue Host: ec2-52-51-237-24.eu-west-1.compute.amazonaws.com header and return 404 Not Found.

Community
  • 1
  • 1
DurandA
  • 1,095
  • 1
  • 17
  • 35