Wrong IP address returned from domain registered at No-IP

0

I want to connect a client and a server through the internet (using C++ and winsock2), so I registered a domain name for the server on No-IP, so that the client could determine it's IP address without both having to be on the same LAN. But when the client uses getaddrinfo() to determine the server IP address from the domain name, getaddrinfo() always returns 8.23.224.90 (which is not the server's IP address). Ping statistics also show that the domain name's IP address 8.23.224.90. After I googled the problem for a long time I eventually found this on the No-IP website:

"The IP addresses 8.23.224.90 and 50.19.220.154 are the direct locations for our web redirect servers. If you have a hostname setup as a web redirect, port 80 redirect or have an offline page enabled, these are the IPs that will be assigned to your host."

Currently this is how the client gets the IP address from domain name "hostname". What should I add/change to get the real IP address? Thanks in advance...

int hostname_to_ip(char *hostname, char *ip) {

    struct addrinfo hints, *servinfo, *p;
    struct sockaddr_in *h;

    memset(&hints,0,sizeof(hints));
    hints.ai_family=AF_INET;
    hints.ai_socktype=SOCK_STREAM;

    getaddrinfo(hostname,NULL,&hints,&servinfo);
    for (p=servinfo; p!=NULL; p=p->ai_next) {
        h=(struct sockaddr_in*)p->ai_addr;
        strcpy(ip,inet_ntoa(h->sin_addr));
    }

}

Awais Chishti

Posted 2014-11-06T10:49:49.177

Reputation: 43

Answers

1

I'm not aware of No-Ip Plus configuration panel but I guess this is close the be the same as the free part.

It is logic to redirect on No-Ip server if your DNS is configured to use a web feature. Make sure option such as "Port 80 Redirect" or "Web Redirect" isn't checked.

What you want instead is "DNS Host (A)" (Redirect your DNS to an IPv4).

Your change may take some minutes to be effective (the default TTL is 1 minute, so expect at least one minute before trying again)

0xCDCDCDCD

Posted 2014-11-06T10:49:49.177

Reputation: 26