472,146 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

How to get client IP address?

Don
How can I get the client's IP address from within an HTML page using embedded JS?

Thanks for your help,
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #1
9 18356
Don
On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:
How can I get the client's IP address from within an HTML page using embedded JS?

Thanks for your help,
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Sorry, I meant how can I do it using PHP on the server?

Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #2
Don wrote:
On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:

How can I get the client's IP address from within an HTML page using embedded JS?

Thanks for your help,
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


Sorry, I meant how can I do it using PHP on the server?

Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

run phpinfo it gives you, amongst other things the clients IP, Its in an
environment variable, sorry can't remember which one it is
Jul 17 '05 #3
Don wrote:
On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:
How can I get the client's IP address from within an HTML page
using embedded JS?

[snip]
Sorry, I meant how can I do it using PHP on the server?


Using the REMOTE_ADDR server variable:

$_SERVER['REMOTE_ADDR']

Be aware that the IP address might not be accurate due to proxying. Be
careful when using it.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 17 '05 #4
Michael Winter wrote:
Don wrote:
On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:
How can I get the client's IP address from within an HTML page
using embedded JS?

[snip]
Sorry, I meant how can I do it using PHP on the server?

Using the REMOTE_ADDR server variable:

$_SERVER['REMOTE_ADDR']

Be aware that the IP address might not be accurate due to proxying. Be
careful when using it.

Mike

True, only rely upon the IP for a session, Asychronous fun <g>
Jul 17 '05 #5
Michael Winter wrote:
Don wrote:
On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:
How can I get the client's IP address from within an HTML page
using embedded JS?

[snip]
Sorry, I meant how can I do it using PHP on the server?

Using the REMOTE_ADDR server variable:

$_SERVER['REMOTE_ADDR']

Be aware that the IP address might not be accurate due to proxying. Be
careful when using it.

Mike

Hell,

life is hard, I started off with procedural languages and some clown
comes up with objects, now the web requires me to go back to
asynchronous. Thank God my first job was as a sytems programmer, what
goes around comes around <g>
Jul 17 '05 #6
Don
On Thu, 17 Mar 2005 15:23:34 GMT, Michael Winter <m.******@blueyonder.co.invalid> wrote:
Don wrote:
On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:
How can I get the client's IP address from within an HTML page
using embedded JS?


[snip]
Sorry, I meant how can I do it using PHP on the server?


Using the REMOTE_ADDR server variable:

$_SERVER['REMOTE_ADDR']

Be aware that the IP address might not be accurate due to proxying. Be
careful when using it.

Mike

Thanks for your replies guys. It looks like I've got someone abusing my domain, and I want to ban
his IP. So, if IP's are changing all the time how can I accomplish this. Suppose maybe, I can ban
an IP range. Will that work?

Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #7
Don wrote:
On Thu, 17 Mar 2005 15:23:34 GMT, Michael Winter <m.******@blueyonder.co.invalid> wrote:

Don wrote:

On Thu, 17 Mar 2005 08:00:17 -0700, Don <no@adr.com> wrote:
How can I get the client's IP address from within an HTML page
using embedded JS?


[snip]

Sorry, I meant how can I do it using PHP on the server?


Using the REMOTE_ADDR server variable:

$_SERVER['REMOTE_ADDR']

Be aware that the IP address might not be accurate due to proxying. Be
careful when using it.

Mike


Thanks for your replies guys. It looks like I've got someone abusing my domain, and I want to ban
his IP. So, if IP's are changing all the time how can I accomplish this. Suppose maybe, I can ban
an IP range. Will that work?

Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Anyone with a dial-up connection (or even broadband) has got a dynamic
IP. It changes...
Jul 17 '05 #8
Don wrote:

[snip]
So, if IP's are changing all the time how can I accomplish this.
Suppose maybe, I can ban an IP range. Will that work?


[Conjecture. Practicality not assured. Regulars: feel free to flame away.]

In principle, yes. If you can't quite determine the range, you should
be able to use a regional registry (like ARIN or RIPE) to determine
the range held by the provider.

However, there is an obvious risk: if the necessary range involves a
major ISP or proxy, you're going to block a *lot* of people. In that
case, use the registry information to find the provider and determine
if the user's actions violate their terms of service. If so, make sure
your server has the correct time (record the discrepancy, if
necessary, including timezone) and wait for an attack to appear in
your logs. You can then send the record to the provider and they
should be able to trace who it is and terminate their account[1].

Reporting is probably a better route, assuming the attacker isn't
already spoofing their IP. If they find themselves banned, they might
then start spoofing and it will be difficult to try reporting then.

Good luck,
Mike
[1] Well, assuming the provider cares about violators. I've
encountered false abuse addresses, or at least unmonitored
mailboxes. There's not much you can do then unless the
provider has been leased their IP range from another
company.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 17 '05 #9
Don
On Thu, 17 Mar 2005 18:16:34 GMT, Michael Winter <m.******@blueyonder.co.invalid> wrote:
Don wrote:

[snip]
So, if IP's are changing all the time how can I accomplish this.
Suppose maybe, I can ban an IP range. Will that work?


[Conjecture. Practicality not assured. Regulars: feel free to flame away.]

In principle, yes. If you can't quite determine the range, you should
be able to use a regional registry (like ARIN or RIPE) to determine
the range held by the provider.

However, there is an obvious risk: if the necessary range involves a
major ISP or proxy, you're going to block a *lot* of people. In that
case, use the registry information to find the provider and determine
if the user's actions violate their terms of service. If so, make sure
your server has the correct time (record the discrepancy, if
necessary, including timezone) and wait for an attack to appear in
your logs. You can then send the record to the provider and they
should be able to trace who it is and terminate their account[1].

Reporting is probably a better route, assuming the attacker isn't
already spoofing their IP. If they find themselves banned, they might
then start spoofing and it will be difficult to try reporting then.

Good luck,
Mike
[1] Well, assuming the provider cares about violators. I've
encountered false abuse addresses, or at least unmonitored
mailboxes. There's not much you can do then unless the
provider has been leased their IP range from another
company.

Thanks Michael and everyone else for your help. I really appreciate your assistance.

Regards,
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by JezB | last post: by
4 posts views Thread by Andy | last post: by
14 posts views Thread by Ankit Aneja | last post: by
13 posts views Thread by James | last post: by
2 posts views Thread by WhatHappend | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.