以前的腳本是用save模式,現在把命令附加到一個文件里面,這樣的話,可以方便的二次修改什么的
腳本基本是這樣的,大家可以跟自己的情況再次修改~ 增加功能什么的。



代碼如下:
#!/bin/bash
while true
do
clear
echo "----------------------menu----------------------"
echo "(1) service iptables restart"
echo "(2) iptables add"
echo "(3) iptables delete"
echo "(4) iptables stop"
echo "(5) iptables save(不推薦使用這種模式)"
echo "(6) iptables status"
echo "(7) iptables ACL list"
echo "(0) exit"
echo "會在當前的目錄下生成一個fw.sh文件"
echo "-------------------------------------------------"
echo -n "enter you chose[0-7]:"
read num
if [ ${num} -lt 0 -o ${num} -gt 7 ]
then
echo "this is not between 0-7"
else
if [ "${num}" == "1" ]
then
service iptables restart&
else
if [ "${num}" == "2" ]
#######################################################
then
while [ "1" == "1" ]
do
clear
echo "----------------------add ACL----------------------"
echo "(1) 針對源IP放行添加"
echo "(2) 針對服務器端口放行添加"
echo "(3) 針對有端口和服務的ACL添加(這里要參數IP和端口 例如 0/0 80)"
echo "(4) 自定義添加"
echo "(5) 退回上一級"
echo "-------------------------------------------------"
echo -n "enter you chose[0-4]:"
read aclnum
if [ "${aclnum}" == "1" ]
then
read ip
iptables -A INPUT -s ${ip} -p tcp --dport 22 -j ACCEPT
新聞熱點
疑難解答