LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 842|回复: 2

请大家iptables指正,谢谢!

[复制链接]
发表于 2003-9-28 17:29:23 | 显示全部楼层 |阅读模式
首先说一下我的环境:redhat9.0 eth0:61.163.221.99 外网
eth1:169.254.1.189 内网  想实现代理169.254.1.0/24上网只开启收发邮件(smtp,pop3),telnet,ssh,ftp,http,snat,dnat,防IP欺骗,防洪水攻击,防PING死和游戏及QQ,BQQ等功能。下面是我的IPTABLES实例,请各位不吝指证,且说明应该怎么修改,谢谢!
touch /etc/rc.d/firewall
chmod 700 /etc/rc.d/firewall
vi /etc/rc.d/rc.local
加上一句:/etc/rc.d/firewall
vi /etc/rc.d/firewall
echo "1" >/proc/sys/net/ipv4/ip_forward
/sbin/modprobe iptable_filter
/sbin/modprobe ip_tables
/sbin/modprobe iptable_nat
/sbin/iptables -F -t nat
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
iptables -t nat -A POSTROUTING -o eth0 -s 169.254.1.0/24 -j SNAT --to 61.163.221.99 #SNAT
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 61.163.221.99 --dport 8000 -j DNAT --to 169.254.1.139:8000  #DNAT
iptables -A INPUT -s 169.254.1.0/24 -i eth0 -j DROP #IP欺骗
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT #DDOS
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT #FLOOD
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT #PING死

#SSH SERVER
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1020:1023 -d any/0 --dport 22 -j ACCEPT   
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 22 -d 61.163.221.99 --dport 1020:1023 -j ACCEPT

#TELNET
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 23 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 23 -d 61.163.221.99 --dport 1024:65535 -j ACCEPT   

#FTP
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 21 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 21 -d 61.163.221.99 --dport 1024:65535 -j ACCEPT
ptables -A INPUT -i eth0 -p tcp -s any/0 --sport 20 -d ptables -A INPUT -i eth0 -p tcp -s any/0 --sport 20 -d 61.163.221.99 --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp ! --syn -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 20 -j ACCEPT  --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp ! --syn -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 20 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 1024:65535 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 1024:65535 -d 61.163.221.99 --dport 1024:65535 -j ACCEPT


#SMTP
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 25 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 25 -d 61.163.221.99 --dport 1024:65525 -j ACCEPT

#POP3
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 110 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 110 -d 61.163.221.99 --dport 1024:65535 -j ACCEPT

#HTTP
iptables -A OUTPUT -o eth0 -p tcp -s 61.163.221.99 --sport 1024:65535 -d any/0 --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 80 -d 61.163.221.99 --dport 1024:65535 -j ACCEPT

#UDP
iptables -A OUTPUT -o eth0 -p udp -s any/0 -d any/0 -j ACCEPT
iptables -A INPUT -i eth0 -p udp ! --syn -s any/0 -d any/0 -j ACCEPT
发表于 2003-9-29 10:17:13 | 显示全部楼层
等待的人不只是一个,呵呵~~
发表于 2003-9-29 16:03:42 | 显示全部楼层
建议分开测试。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表