Jump to content

Error while getting Hostname from IP


Recommended Posts

Hi community

I got an error, while runing this code

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $aResult, $sResult, $sIp

TCPStartup()
$sIp = TCPNameToIP("MyHostname.fr")
$sResult = _TCPIpToName($sIp)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "_TCPIpToName()", "@error = " & @error & @CRLF & "@extended = " & @extended)
Else
    MsgBox($MB_SYSTEMMODAL, "MyHostname.fr really is: ", $sResult)
EndIf

$sIp contains the expected IP but IP to Name leads me to error

@error = 4

@extended = 0

I am runing this script on Win10, ws2_32.dll exists in C:\Windows\System32

Also read @MS : https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-gethostbyaddr than gethostbyaddr is not anymore used and should be replaced by getnameinfo

Any help appreciated

Regards

Edited by Ebola57
Link to comment
Share on other sites

Can you try the same script using "autoitscript.com" as hostname ?

I think your hostname is not registred in the Reverse lookup Zone of your DNS server

Try the command nslookup IP (where IP is the IP address of the host) to see if the issue is related to autoit or not.

 

Edited by jguinch
Link to comment
Share on other sites

Using "autoitscript.com" leads to success, resulst is "server1.autoitscript.com"

nslookup MyIp
Serveur :   server.domain.fr
Address:  ServerIP

*** server.domain.fr ne parvient pas à trouver MyIp : Non-existent domain
Pinging expected domain leads to a correct resolving IP

Link to comment
Share on other sites

OK, so it's not an Autoit issue, it's a reverse DNS issue.

What kind of host is it ? an internal host or public host ? If it's an internal host, ask to your IT best friend to add an entry in the reverse lookup zone on your internal DNS server

 

 

Edited by jguinch
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...