ubuntu iptables配置脚本代码怎么写?今天小编就给大家分享一篇关于写ubuntu iptables配置脚本代码的详细教程吧,感兴趣的朋友跟小编一起来了解一下吧!
bash/shell Code复制内容到剪贴板
- #!/bin/bash
-
- case "$1" in
-
- start)
- echo -n "Staring to write your Iptbales:..."
-
- /sbin/iptables -F
- /sbin/iptables -X
- /sbin/iptables -Z
- /sbin/iptables -A INPUT -i lo -j ACCEPT
- /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- /sbin/iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j DROP
- /sbin/iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
- /sbin/iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
- /sbin/iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
- /sbin/iptables -P INPUT DROP
- echo "OK"
- ;;
-
- stop)
- echo -n "Stop iptables...."
-
- /sbin/iptables -P INPUT ACCEPT
- /sbin/iptables -F
- /sbin/iptables -X
- /sbin/iptables -Z
- echo "OK"
- ;;
-
- *)
- echo "Usage: $0 {start|stop}"
- ;;
-
- esac