Os 7 if模糊判断数字
2020-07-14 05:14
92 查看
判断允许192段位的ip访问,拒绝172段位的ip访问
创建一个放置脚本的目录:
[root@localhost ~]# mkdir /shell
编辑一个文档,写入要查询的ip:
[root@localhost ~]# vim ip.txt 192.168.136.1 192.168.136.2 192.168.136.3 172.168.136.1 172.168.136.2 172.168.136.3
编辑脚本:
[root@localhost ~]# vim /shell/if.sh #!/bin/bash ip=(`cat /root/ip.txt`) for i in ${ip[*]} do if [[ $i == '192'* ]] ;then echo " $i 允许通过" else iptables -A INPUT -s $i -j DROP echo " $i drop掉了" fi done
测试
[root@localhost ~]# cd /shell [root@localhost shell]# sh if.sh
相关文章推荐
- Os 7 if模糊判断ip
- Mybatis if test 判断数字时需要注意
- Mybatis if test 动态判断数字时需要注意的问题
- Doma 参数传入至sql文中 , 模糊查询 和if 判断
- if判断变量为字母或者数字
- Mybatis <if test> 判断数字时的问题
- shell脚本--if判断(数字条件、字符串条件)
- mybatis if test非空判断数字0为什么是false
- java小练习(输入一个数字,使用if语句判断匹配的数字)
- Mybatis if test 判断数字时需要注意
- Shell编程之if简单判断两个数字大小
- 猜数字游戏,判断输入的数字与系统产生的数字是否一致(Math.random()与if嵌套循环)
- [转]mybatis if test非空判断数字0为什么是false
- Mybatis if test 判断数字时需要注意
- R语言 如何用IF语句判断 一个数字的奇偶
- shell脚本--if判断(数字条件、字符串条件)
- mybatis 里面使用<if test=""> 判断,当后台传的值是数字字符串时,怎么处理
- if的嵌套-判断数字的整除
- js已知一个文本输入框,通过按钮点击,用if 判断输入框里的数字是否能被3整除
- Mybatis if test 判断数字时需要注意