Edit: It looks like this code only returns internal IPs. Is there a way of finding my external IP using C#?
So I've been using the 'standard' method of obtaining your own IP address:
IPAddress Own;
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
Own = ip;
}
}
The problem is the address this gives me is somewhere in the UK, and I'm in Australia - and obviously when I ask google for my own IP address I get something different from what this code gives me.
So why is this code not working? As I see it, it's a bit of a strange way to use a DNS server to resolve my own hostname (which isn't a URL, it's just a computer name...), but I trust that it's the right way. What could be going wrong?