SitePoint Sponsor |
|
User Tag List
Results 1 to 11 of 11
Thread: How to block Access by IP Number
-
Nov 12, 2002, 16:13 #1
- Join Date
- Mar 2001
- Location
- In God's Country!
- Posts
- 1,317
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to block Access by IP Number
I was saw somewhere how to block access to a web site according to someone's IP number.
I have a guy who is harrasing me since we are competitors and I don't want him accessing my business site from his home, or his work.
I have his IP numbers from both locations through e-mails he has sent me in the past.
Anybody know how to do this? If I remember correctly, I think it was a javascrip that had the ability to accomplish this.
-
Nov 12, 2002, 16:22 #2
- Join Date
- Nov 2002
- Posts
- 423
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can redirect the user on server-side depending on his IP. If you use ASP it should be something like this:
[VBS]
If Request.ServerVariables("REMOTE_ADDR") = "234.234.234.234" Then
Response.Redirect "http://different-site.com"
End If
[/VBS]
Keep in mind that your friend may have different IP every time he is online
-
Nov 13, 2002, 11:04 #3
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A PHP equivalent to asp-hosting's example would be
PHP Code:if ($_SERVER['REMOTE_ADDR'] == '234.234.234.234')
header("Location: dont_bug_me_dude.htm");
Code:var ip = "<!--#echo var="REMOTE_ADDR"-->"; if (ip == '234.234.234.234' || ip == '234.234.234.235') window.location.replace("dont_bug_me_dude.htm");
Code:<noscript> <meta http-equiv="refresh" content="0;URL=turn_on_javascript_you_fool.htm" /> </noscript>
-
Nov 15, 2002, 17:39 #4
- Join Date
- Mar 2001
- Location
- In God's Country!
- Posts
- 1,317
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks guys!
I would have replied earlier, but for some reason I didn't get notification from the board that someone had replied.
This individual is on Road Runner. Do they have a different IP number everytime they "go online", since it's a connection that's always on?
I don't know much about it, but it seems that a high speed connection wouldn't be like a regular dial-up in terms of the IP number possibly being different everytime they go on the net.
I'm just doing straight html, so maybe I'd better stick with javascript.Last edited by Rockrz; Nov 15, 2002 at 17:42.
-
Nov 15, 2002, 19:23 #5
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well acutally, most users with a basic Roadrunner account (or any cable connection) are assigned an IP from a DHCP server. This means that they obtain a non-used IP address everytime they connect. Yes, cable connections are 'always on', but only while the computer is on. I haven't personally rebooted in weeks, so I have had the same IP since then. However, if I reboot, I may get a different IP, I also may get the same. Now, most ISPs that offer broadband will give you a static IP if you pay a bit more than the basic package.
Now, one thing that typically stays constant is the user's MAC address (well, it DOES stay constant, but some routers can spoof other MAC addresses), but I'm not sure if those can be read server-side. I'll research it a bit.
-
Nov 15, 2002, 23:55 #6
- Join Date
- Mar 2001
- Location
- In God's Country!
- Posts
- 1,317
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks, I'd appreciate any help I could get on this.
This guy is a real pain.
I know even if I could block his IP, he could go to another machine with a different connect (like at a friend's house) and get right on).
I just thought I'd try & redirect his IP number to a generic page that looks like something your webhost would put up if you were overdue on your hosting bill.
Then he'd think I was having a hard time paying my bills, which is what I want him to think (actually, I just want him to keep his nose out of my business)
-
Nov 16, 2002, 03:52 #7
- Join Date
- Aug 2002
- Location
- Burpengary, Australia
- Posts
- 4,495
- Mentioned
- 0 Post(s)
- Tagged
- 1 Thread(s)
You could go really hardcore and block his whole ISP by blocking the IP 234.234.*.*
That could be a little drastic but I know someone who blocked an entire ISP from an IRC channel because 1 person was being a real turd.
-
Nov 19, 2002, 08:57 #8
- Join Date
- Mar 2001
- Location
- In God's Country!
- Posts
- 1,317
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm still unclear of the exact javascript code to use in order to block someone's IP address.
-
Nov 19, 2002, 09:42 #9
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Rockrz
I'm still unclear of the exact javascript code to use in order to block someone's IP address.
-
Nov 20, 2002, 22:17 #10
- Join Date
- Mar 2001
- Location
- In God's Country!
- Posts
- 1,317
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, I did.
I don't know anything about php, so all I have to use is:
if ($_SERVER['REMOTE_ADDR'] == '234.234.234.234')
header("Location: dont_bug_me_dude.htm");
Is that in the HEAD of my page?
And nothing else is needed around it?
_________________________________________
I can't use:
var ip = "<!--#echo var="REMOTE_ADDR"-->";
if (ip == '234.234.234.234' || ip == '234.234.234.235')
window.location.replace("dont_bug_me_dude.htm");
because all my pages are straight HTML
I saw a straight javascript once, but didn't save it.
I should have because it was a simple script placed in the HEAD of a webpage.
I'll go back & serach some of the script resource sites I have booked marked again....
Thanks!
-
Nov 20, 2002, 22:23 #11
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Rockrz
Is that in the HEAD of my page?
And nothing else is needed around it?
The SSI method doesn't require any HTML changes, but just an extension change to all your files from .htm or .html to .shtml. Most servers should support SSI. Make a test.shtml and try it out...
Bookmarks