I have a server coded in C. After the accept(), I want to get the IP address from the sockaddr.
But the IP address I get is the one from the VM I’m on : 10.0.x.x, not the internet IP. The VM is hosted on a computer that has a real IP, which is the one I would like to get.
The port forwarding has been done.
Example : I have 2 computers running the same VM, so they have the same VM local IP (10.0.x.x). The first VM launches the server, the second uses telnet to connect using the real server’s IP (147.x.x.x). The connection is established correctly, but the IP I get in the sockaddr is the VM one.
Do you know how to resolve it?
You’ll need a “third party” outside, e.g. a (web) server that will just return/print the remote IP of the active connection. That way you’re able to get your “internet ip” when behind a local NAT.