Is there a way to compare that an FQDN and IP address are equivalent? RRS feed

  • Question

  • I know how to do this the hard way. 

    But I was wondering if there was a single function that can compare if an FQDN and IP address are equal.      


    Thursday, March 6, 2014 4:33 PM


  • Hi,

    From your description, Iknow that you want to compare if an FQDN and IP address are equal.

    Then the easiest way to do this is to use the socket.gethostbyname().

    The socket.gethostbyname() will translate a host name to IPv4 address format. The IPv4 address is returned as a string, such as  ''.

    Then after using the socket.gethostbyname(), you will get the IP_address1, Then you can compare to the IP_address1 to your IP address to see if there are equal.

    For more information, please try to refer to:
    #socket.gethostbyname(): .

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 7, 2014 2:11 AM