torwill
08-07-2004, 02:23 AM
Hello,
Is it possible to use iptables to block IP's which are referred from certain URL's?
Thank you.
Is it possible to use iptables to block IP's which are referred from certain URL's?
Thank you.
![]() | View Full Version : block ip's based on "referrer" torwill 08-07-2004, 02:23 AM Hello, Is it possible to use iptables to block IP's which are referred from certain URL's? Thank you. Loon 08-07-2004, 05:11 AM I guess you could try something like this: <?php $deny = 'somedomain.com'; $host = $_SERVER['REMOTE_ADDR']; $refr = $_SERVER['HTTP_REFERER']; if(eregi($deny, $refr)) { exec('/sbin/iptables -I INPUT -s '.$host.' -j DROP'); } ?> But it wouldn't be all that reliable, not everybody reveals a HTTP_REFERER for a start rsferreira 08-07-2004, 11:23 AM If the idea is to block http access by referer, maybe this could be useful: http://accessreferer.sourceforge.net/mod_access_referer.html rsferreira 08-07-2004, 11:25 AM Originally posted by Loon I guess you could try something like this: <?php $deny = 'somedomain.com'; $host = $_SERVER['REMOTE_ADDR']; $refr = $_SERVER['HTTP_REFERER']; if(eregi($deny, $refr)) { exec('/sbin/iptables -I INPUT -s '.$host.' -j DROP'); } ?> But it wouldn't be all that reliable, not everybody reveals a HTTP_REFERER for a start Athough logic is ok, I don't think PHP will be able to run the iptables binary... At least it shouldn't be able to ;). |