|
|

楼主 |
发表于 2007-12-1 22:31:19
|
显示全部楼层
可是我不会呀,我对linux还是新手:(
看了论坛里的很多关于iptables的贴,还是弄不太明白:(
最近我引用了liwei的脚本,并做了适当的修改,但是没看出什么效果来,麻烦指点:)
#!/bin/bash
# This is a script
# Edit by liwei
# establish a static firewall
# define const here
Open_ports="80 25 110 10 22" # 自己机器对外开放的端口
Allow_ports="53 80 20 21" # internet的数据可以进入自己机器的端口
#init
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
# The follow is comment , for make it better
iptables -P INPUT DROP
iptables -A INPUT -i ! eth0 -j ACCEPT
# define ruler so that some data can come in.
for Port in "$Allow_ports" ; do
iptables -A INPUT -i eth0 -p tcp --sport $Port -j ACCEPT
iptables -A INPUT -i eth0 -p udp --sport $Port -j ACCEPT
done
for Port in "$Open_ports" ; do
iptables -A INPUT -i eth0 -p tcp --dport $Port -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport $Port -j ACCEPT
done
# This is the last ruler , it can make you firewall better
iptables -A INPUT -i eth0 -p tcp -j REJECT --reject-with tcp-reset
iptables -A INPUT -i eth0 -p udp -j REJECT --reject-with icmp-port-unreachable |
|