Global IP Address

J

JimSchacht

Hello everyone,
i'm only slightly familiar with asp.net but i'm very familiar with
c#/vb.net and i'm writing an application that needs to know my machines
Global IP address. I'm behind a NAT enabled router so i know it's different
than my local ip address. i'd like to do this via an httprequest.
 
B

bruce barker

you have to ask the router, as only the router has the mapping information.
the router may or may not have an api for this.

note: unless it is a static map in the router, it can change on every
network connection.

-- bruce (sqlwork.com)
 
D

David

Hello everyone,
i'm only slightly familiar with asp.net but i'm very familiar with
c#/vb.net and i'm writing an application that needs to know my machines
Global IP address. I'm behind a NAT enabled router so i know it's different
than my local ip address. i'd like to do this via an httprequest.

When you say "my machine" in this case do you mean your local web server
(in which case presumably you're port forwarding in addition to NAT), or
do you mean the web client?

In any case, the only reliable way to do this is to keep a small app in
a known location on the internet someplace that will return the
information you want. Then from your local machine you can send out a
request to the known machine, which then returns the IP address in html,
or xml, or a web service, or whatever. There's a bunch of sites that do
that right now, but a) it might not be a good idea to rely on the
stability of others' sites, and b) it's probably a little rude to use
their services without asking.

I do wish one of the major player would stick up a web service someplace
that would do this and promises to be around a long time. It would be
pretty useful IMHO.

Another poster mentioned asking the router, which is absolutely correct
and might work fine in your situation since you're dealing with a known
router. If you don't know where your app is going to live though, for
example if it's something you're distributing to others, this won't work
because you won't know where the NAT router is.

Lastly, you might want to rethink whether you really need this info for
your app.
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top