How to get your public IP address in-game

Is there a way to get your IP address in-game. As in the .exe is running and it needs to get the computer public IP address.

The reason I need this is cuz if you have 1 server, ez you know it’s IP address and you can just have it as a variable. BUT if you have 1000 or more servers, it starts being nigh-impossible to do that. Mostly since you’d have to make 1 program for each server, even 10 servers would already be a hassle.

So, is there way to do it, and if there is could someone explain it to me? SOmeone said you can use c++ to run windows commands, but this is a linux server. And if there is a way could you develop further, as in what would I need to do to make a c++ class to do this and expose it to blueprints.

If it is a linux server you can call the command curl to any webpage that gives your public IP, like ipconfig.org. In C it could be something like:
FILE *f = popen(“curl -s ipconfig.org”, “r”);
and read f as one line.