Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to allow certain IPs to a site running under my apache server ( 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 using an iptables rule. What would that set of rules be?

share|improve this question
#access control

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

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


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