Getting external IP Address

G

Guest

Hi, im using this code to get a computers IPAddress

Net.Dns.GetHostEntry(Net.Dns.GetHostName()).AddressList(0)

but that only gets the Lan IPAddress....how can i get the internet IP address?
 
G

Guest

sorry about the double post....i got an error the first time i tried to post,
but apparently it went through anyway
 
J

james

iwdu15 said:
sorry about the double post....i got an error the first time i tried to
post,
but apparently it went through anyway


No worries. Can't specifically answer your question, because the problem is,
it depends how you connect.
If you go through any kind of router/nat setup, the external address is
effectively unknown to your PC. It sends requests to it's default gateway
which then processes them. There are lots of websites out there (such as
www.whatsmyip.net) that can pick up the external address, so maybe you need
to look at somehow sending a request to one of these and processing it?
 
G

Guest

yea...i saw alot of things on that after doing a google search....i was
wondering, would connecting a socket to the same computer then checking the
remote end point work? i just want to avoid using any websites incase they
are unavailable for some reason....
 
J

james

iwdu15 said:
yea...i saw alot of things on that after doing a google search....i was
wondering, would connecting a socket to the same computer then checking
the
remote end point work? i just want to avoid using any websites incase they
are unavailable for some reason....

Do you mean connecting to "yourself"? I don't think so, as it would be
clever enough to realise that it is within the local segment... the gateway
(and beyond) is only accessed when the computer doesn't "know" how to get to
the destination you give it - so anything on the same subnet will connect
"directly" (for want of a better phrase), whereas anything else will go to
the gateway...
Now, I guess you could try pinging a completely random address and not worry
if it's there or not, and see if the reply (from the gateway and whatever
it's gateway is) gives any information as to the external address? I'm not
sure it will, but perhaps worth a go - effectively you need to work out how
to do a traceroute... then it shouldn't matter if the remote site is up or
down.
I don't have code for doing that however, but a google may turn up
something...
James.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top