[CentOS] Easy way to reject all incoming packets except from certain IPs?

Wed Feb 1 00:38:18 UTC 2006
Troy Engel <tengel at fluid.com>

Preston Crawford wrote:
> Is there an easy way to reject all incoming packets except those that
> come from certain IPs? I can't find any way via iptables or via the GUI

See this great iptables example:

http://oceanpark.com/notes/firewall_example.html

In your case it'll be a whole lot simpler, all you'll need are the
initial drop rules for all traffic, then a rule or two to allow XYZ ip in.

-te

pseudo:

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -F INPUT
iptables -F OUTPUT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# your IPs below
iptables -A INPUT -i eth0 -s x.y.z.s/32 -j ACCEPT


-- 
Troy Engel | Systems Engineer
Fluid, Inc | http://www.fluid.com