放行封锁port和ip脚本

标题放行封锁port和ip脚本

#!/bin/bashecho " 1.放行的端口 2.封锁的端口 3.放行ip 4.封锁ip " read -ep "请选择你的操作:" menucase $menu in 1) while true; do read -ep "请输入要放行的端口:" port iptables -I INPUT -p tcp --dport $port -j ACCEPT iptables -I INPUT -p tcp --dport $port -j ACCEPT echo "$port放行成功" break done ; ; 2) while true; do read -ep "请输入要封锁的端口:" port iptables -I INPUT -p tcp --dport $port -j REJECT iptables -I INPUT -p tcp --dport $port -j REJECT echo "$port封锁成功" break done ; ; 3) while true; do read -ep "请输入要放行ip:" ip iptables -I INPUT -s $ip -j ACCEPT echo "$ip放行成功" break done ; ; 4) while true; do read -ep "请输入要封锁的ip:" ip iptables -I INPUT -s $ip -j DROP echo "$ip封锁成功" break done ; ; *) echo "输入有误!!!" esac

    推荐阅读