When running the following script as user ec2-user
, I get the error message iptables v1.4.18: can't initialize iptables table filter: Permission denied (you must be root)
Script:
#!/bin/sh
# Offending IP as detected by mod_evasive
# Add the following firewall rule (block IP)
$IPTABLES -I INPUT -s $IP -j DROP
How can I run iptables
as a non-root user to block a IP address?
NB: This script is usually called by mod_evasive