Get public facing IP address. Different websites giving different IP's

71 views Asked by At

I don't know too much about networking concepts, trying to get my public facing IP address programatically (powershell preferred)

Trying these different websites

Is there an alternative way to get the IP address shown by whatismyip.com website [for free]?

please don't go into "pay them you cheap pos"; It's a company project, and my boss man doesn't want to spend anything currently

I could use my local computer IP address, but we use a VPN (company wide), and hoping to get the address of this VPN provider

Edit: adding more clarity

I think I need the IP address of the VPN provider I am connected to. The browser/whatismyip is somehow able to get it. I need this address programmatically. Are there any free other APIs that provide this info?

1

There are 1 answers

6
Hugo Barona On

Given you want to use Powershell,

you can try to invoke a Web request to the api.ipify.org

(Invoke-WebRequest -uri "https://api.ipify.org/").Content

Or

Invoke-RestMethod https://api.ipify.org

The response will be your IP address.

If you want the VPN IP address, you can use the code below

(Get-NetAdapter -InterfaceDescription "Your VPN Connection Name").IPv4Address

To find the VPN connection name, assuming you are using Windows, you can check the VPN connections on the Network & internet settings.

More info here - https://support.microsoft.com/en-us/windows/connect-to-a-vpn-in-windows-3d29aeb1-f497-f6b7-7633-115722c1009c

Edited to include the option shared by @mklement0