How to get client IP address assigned by ISP

M

Mike

Hi ASP Gurus,
Please help me solving my problem.
I am trying to get the clients IP address but I am not able to do it
successfully. I have tried:
Request.ServerVariables("http_user_agent")
Request.ServerVariable("remote_addr")

But I am getting something like '125.1.1*'

What do I need to get the IP address assigned my the ISP.

I'll appreciate any help you can provide.

Thanks, Mark
 
M

Mike

Thanks Mark for your quick response.
But when I go the website http://whatismyipaddress.com/ it does return my
correct IP address. There are other websites also which shows correct IP
address.
We are tring to capture this information and store it for some
troubleshooting later on.

How does other website caputures it?

Thanks, Mark
 
S

Steven

I wrote my own page and put it on my own domain, so if I go
to http://www.mydomain.com/ip it returns the WAN IP for the
connection. It gets it from the environment variable of what IP
you're connecting from (requesting the page with), REMOTE_ADDR.
But the reason I maid my own is so it was easier to parse, mine just
returned the IP.

Steven

Mike said:
Thanks Mark for your quick response.
But when I go the website http://whatismyipaddress.com/ it does return my
correct IP address. There are other websites also which shows correct IP
address.
We are tring to capture this information and store it for some
troubleshooting later on.

How does other website caputures it?

Thanks, Mark
 
M

Mike

I understand your concern.
But most of our users may not know how to spoof IP address.
Also I just want to finish the task given to me. I don't want to argue with
my seniors on this as I already argued a lot recently on other subjects.

Is there any way to get the IP address?

Thanks Mark
 
B

bruce barker

as stated, you can only get the nat transalated address, but this may be
close enough. it sounds like your server is behind a firewall (or load
balancer), so the ipaddres your are currently getting is the firewall's
ipaddress. you will need to configure your firewall to pass along the
original ipadress in a custom header. then you can just the address form the
custom header.


-- bruce (sqlwork.com)
 
G

Gregory A. Beamer \(Cowboy\) - MVP

When you hit whats my ip, you are not spoofing and you might have a natted
internal address, but that is the address of your cable or DSL modem
(assumption here).

The other website is tearing down the header, just as ASP.NET does. You can
examine all of the keys. But, as Mark pointed out, the IP is relatively
meaningless if you are trying to use it to identify people (it changes) or
block hackers (they spoof), which are the primary reasons for gathering IP.

If you are sold on this idea:
Request.UserHostAddress()

Not sure if it will be any better for you.


Mike said:
Thanks Mark for your quick response.
But when I go the website http://whatismyipaddress.com/ it does return my
correct IP address. There are other websites also which shows correct IP
address.
We are tring to capture this information and store it for some
troubleshooting later on.

How does other website caputures it?

Thanks, Mark
 
G

Gregory A. Beamer \(Cowboy\) - MVP

One thing I would consider is use Firefox and a add in like FireBug to see
the actual headers you are sending. You may be just sending 125.1.1*
 
G

Gregory A. Beamer \(Cowboy\) - MVP

Try:
Request.UserHostAddress()


Mike said:
I understand your concern.
But most of our users may not know how to spoof IP address.
Also I just want to finish the task given to me. I don't want to argue
with my seniors on this as I already argued a lot recently on other
subjects.

Is there any way to get the IP address?

Thanks Mark
 
J

John Saunders

Mike said:
I understand your concern.
But most of our users may not know how to spoof IP address.
Also I just want to finish the task given to me. I don't want to argue
with my seniors on this as I already argued a lot recently on other
subjects.

Is there any way to get the IP address?

My IP address is 192.168.0.3. Several hundred thousand other computers
probably have the exact same IP address at this very moment.
http://whatismyipaddress.com/ reports my address as 72.74.111.34. It gives
the exact same address for my home PC, in the other room.

Which one am I?
 
G

Gregory A. Beamer \(Cowboy\) - MVP

Use Firefox and Firebug and see what headers you are sending. That will give
you a better shot of determining where you need to pull the value from.

Also consider iterating through all keys sent on the request object and see
if one contains the IP you desire. There is no guarantee that this value
will be accurate, of course, but you will find it in there, if it is there.


Mike said:
I tried even that with same result.

Mark
 
G

Gregory A. Beamer \(Cowboy\) - MVP

Yes. I would argue with my boss first, as this requirement is completely
worthless IMO. But there are times you do "stupid" stuff, with proper
documentation, or you find a new job.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top