Using .NET, is there a way to retrieve the external IP of a PC if they are connected to a VPN and using the VPN as the internet gateway? My end goal is to detect if the client PC is truly on the network or if they are at a remote location.
EDIT: After reading some of these answers, I should be a little more specific. I guess what I’m looking for is a programmatic way of bypassing the VPN to check the true external IP of the laptop. Is this possible?
Also, if you are at the client, you could run ROUTE PRINT on windows and parse the output searching for the VPN specific entries. Try running the command when connected to the VPN and when connected directly and find the differences. Besides the physical adapters you should see a VPN adapter and all external routes going through it. If you want to bypass the VPN to get the external IP, which you would probably do by accessing and external server, you would have to add a route to that server through the ethenet adapter. But I have used VPN clients that block that, meaning that all traffic must go through the VPN, so this might not work for you.