您的位置:首页 > 其它

iptables,ebtables,arptables

2009-04-26 17:30 169 查看
还有多少tables可以来一下。

话说还是把本机防火墙配起来了,经历两次把自己关在门外后,开始小心翼翼了。

1 #!/bin/sh -e

2 IPTABLES="/sbin/iptables"

3 ARPTABLES="/sbin/arptables"

4

5 echo 1 > /proc/sys/net/ipv4/ip_forward

6 start(){

7 # flush

8 $IPTABLES -F

9

# set default policy

$IPTABLES -P INPUT ACCEPT

$IPTABLES -P OUTPUT ACCEPT

$IPTABLES -P FORWARD ACCEPT

# input chain

# state allow

$IPTABLES -A OUTPUT -m state --state INVALID -j REJECT

$IPTABLES -A INPUT -m state --state INVALID -j REJECT

$IPTABLES -A INPUT -p icmp -m limit --limit 20/minute --limit-burst 5 --icmp-type 8 -j ACCEPT

$IPTABLES -A INPUT -p icmp -m limit --limit 20/minute --limit-burst 5 --icmp-type 11 -j ACCEPT

$IPTABLES -A INPUT -p icmp -j REJECT --reject-with icmp-host-unreachable

#reject arping

$ARPTABLES -P INPUT DROP

$ARPTABLES -P OUTPUT DROP

$ARPTABLES -P FORWARD ACCEPT

$ARPTABLES -A INPUT --source-mac 00:d0:xx:xx:xx:xx -j ACCEPT

$ARPTABLES -A OUTPUT --destination-mac 00:d0:xx:xx:xx:xx -j ACCEPT

$ARPTABLES -A INPUT --opcode 2 -j ACCEPT

$ARPTABLES -A OUTPUT --opcode 1 -j ACCEPT

}

stop(){

$IPTABLES -F

$IPTABLES -P INPUT ACCEPT

$IPTABLES -P OUTPUT ACCEPT

$IPTABLES -P FORWARD ACCEPT

$ARPTABLES -F

$ARPTABLES -P INPUT ACCEPT

$ARPTABLES -P OUTPUT ACCEPT

$ARPTABLES -P FORWARD ACCEPT

}

case "$1" in

start)

start

;;

stop)

stop

;;

*)

echo "$0 {start|stop}"

exit 1

;;

esac

exit 0

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: