1

How can I resolve the external IP of a computer in C++? The external IP being the address the server sees when you connect to it via HTTP, FTP etc.

No external libraries allowed.

Bart
  • 19,692
  • 7
  • 68
  • 77
user1581390
  • 1,900
  • 5
  • 25
  • 38

2 Answers2

2

Unfortunately, there is no single "external IP address". You will have to go through the network configuration to determine what interface will be handling the traffic to find the address, but even then you might be going through an external gateway that translates your address to something else.

For example, a software that properly analyses my network configuration to find out where traffic to stackoverflow.com would go will hopefully determine that this traffic goes to the physical network interface, using the address 10.1.2.1. It would also determine that the traffic is routed to a gateway at 10.1.1.1, but it would not be able to determine what the actual address of the traffic stream in the internet would be because it can't analyze the gateway (it's a different box).

Christian Stieber
  • 9,954
  • 24
  • 23
1

If you have a website, you could create a php file with this following in it:

<?php echo  $_SERVER["REMOTE_ADDR"]; ?>

Since you don't want to use "external" libraries, use the various Windows Internet functions to get this page.

Gunner
  • 5,780
  • 2
  • 25
  • 40