iptables FTP脚本

#!/bin/sh
echo " enable ip forward...."
echo 1 >/proc/sys/net/ipv4/ip_forward
modprobe ip_tables
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
echo " firwall starting...."

iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

echo "disable forwarding...."
iptables -P FORWARD DROP
echo " enable lan to internet...."
iptables -A FORWARD -s 192.168.0.0/24 -p tcp -d 0/0 -i eth0 -j ACCEPT
echo " enable internet to lan ftp server...."
iptables -A FORWARD -s 0/0 -p tcp -d 192.168.0.7/24 --dport ftp -i eth1 -j ACCEPT
iptables -A FORWARD -p tcp -d 192.168.0.0/24 ! --syn -i eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE 
posted @ 2015-07-12 17:30  李庆喜  阅读(152)  评论(0编辑  收藏  举报