A remote computer has two address: LAN and VPN
I tried to get LAN IP address by following code:
hostent *host = gethostbyname(hostname);
if (host) strcpy(ip, inet_ntoa(*((struct in_addr *)host->h_addr)));
So, sometime it return LAN, but sometime VPN. I know that there’re many address in h_addr_list field, but how can I know which address is local?
I tried to use GetAdaptersInfo(), it has field to determine local ip or not, but just return ip address of my computer. I don’t know how to get ip for remote computer.
Anyone give me some advices, please!
After playing around with this problem, I realize that the adapters on remote string could not be public due to security issue. Thus, we don’t have an exactly way to know which IP address is VPN.
Moreover, VPN address is created by VPN server. Therefore, that VPN address could be anything, even similar to our local IP. In other words, we cannot guess VPN address any way.