标签:shel txt 判断 ash one ble else 编写 echo
1.编写txt里面放入ip
[root@localhost ~]# vim ip.txt 192.168.177.1
192.168.177.2
192.168.177.3
192.168.177.4
192.168.177.5
192.168.177.6
172.168.177.8
127.0.0.1
2.编写脚本
[root@localhost ~]# vim if.sh
#!/bin/bash
ip=(`cat /root/ip.txt`)
for i in ${ip[*]}
do
if [[ $i == "192"* ]]; then
echo "$i is ok"
else
iptables -A INPUT -s $i -j DROP &> /dev/null
echo "$i drop"
fi
done
3.测试
[root@localhost ~]# sh if.sh
标签:shel txt 判断 ash one ble else 编写 echo
原文地址:https://www.cnblogs.com/wendyluo/p/13173648.html