#!/bin/bash
echo "1)放行端口
2)封锁端口
3)放行ip
4)封锁ip"
AWK(){
while true
do
read -ep "是否继续输入(y/n)|(Y/N)?:" yn
if [ $yn == n ]||[ $yn == N ];then
exit
elif [ $yn == y ]||[ $yn == Y ];then
break
else
echo "请输入(y|Y/N|n)"
fi
done
}
read -ep "请输入你的操作:" name
case $name in
1)
while true
do
read -ep "请输入要放行的端口:" duan
echo "正在放行...."
iptables -I INPUT -p tcp --dport $duan -j ACCEPT
sleep 3
echo "放行规则添加成功"
AWK
done
;;
2)
while true
do
read -ep "请输入要放行的端口:" duan
echo "正在放行...."
iptables -I INPUT -p tcp -dport $duan -j DROP
sleep 3
echo "放行规则添加成功"
AWK
done
;;
3)
while true
do
read -ep "请输入要封锁的IP地址": IP
echo "正在放行...."
iptables -I INPUT -s $IP -j ACCEPT
sleep 3
echo "放行规则添加成功"
AWK
done
;;
4)
while true
do
read -ep "请输入要封锁的IP地址": IP
echo "正在封锁...."
iptables -I INPUT -s $IP -j DROP
sleep 3
echo "封锁成功"
AWK
done
;;
*)
echo "输入有误,退出脚本"
exit
esac
————————————————
版权声明:本文为CSDN博主「人生匆匆」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/a13568hki/article/details/102737248