Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to allow certain IPs to a site running under my apache server (my.site.com). I know I can do it using Allow from 192.168.0 but I'm wondering if it is possible doing it through iptables and at the same time log the requests made to my.site.com using an iptables rule. What would that set of rules be?

share|improve this question

2 Answers 2

#access control

iptables -A INPUT -p tcp --dport 80 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j DROP

#loggin
iptables -A INPUT -p tcp --dport 80 -m string --to 200 --string "GET /" --algo kmp -j LOG
iptables -A INPUT -p tcp --dport 80 -m string --to 200 --string "POST /" --algo kmp -j LOG
share|improve this answer

The string match extension will allow you to do some filtering on the contents of a packet, but you're really better off doing it in httpd.

share|improve this answer
    
Thanks. Any particular reason why not doing it in httpd? –  user57477 Oct 18 '10 at 16:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.