centos7 编写防火墙增加和删除端口脚本
2017-10-23 10:27
387 查看
#!/bin/bash num=$# ok=0 if [ ${num} != 2 ] then echo 'error:you must input two parmas, first is add or remove, second is port number' exit 0 fi case $1 in add) status=$(firewall-cmd --zone=public --add-port=$2/tcp --permanent) echo "add port status:${status}" ok=1 ;; remove) status=$(firewall-cmd --zone=public --remove-port=$2/tcp --permanent) echo "remove port status:${status}" ok=1 ;; *) echo 'you must input two parmas, first is add or remove' ;; esac if [ ${ok} == 1 ] then status=`firewall-cmd --reload` echo "reload firewall status:${status}" ports=`firewall-cmd --list-ports` echo "ports list:${ports}" fi exit 0
相关文章推荐
- centos 增加端口 修改防火墙
- centos 增加端口 修改防火墙
- CentOS7使用firewalld打开关闭防火墙与端口
- CentOS防火墙开启、关闭以及开放指定端口
- 添加/删除端口(或程序)到防火墙外
- Linux:centos7防火墙开放端口
- CentOS 设置防火墙端口
- CentOS7使用firewalld打开关闭防火墙与端口
- centos中创建自动备份Mysql脚本任务并定期删除过期备份
- 编写iptables脚本实现IP地址、端口过滤
- CentOS 7 开放防火墙端口命令(与7以前的命令不同)
- CentOS防火墙开启、关闭与开放指定端口
- Centos 7和 Centos 6开放查看端口 防火墙关闭打开
- CentOS 配置防火墙操作实例(启、停、开、闭端口):
- CentOS 7 开放防火墙端口命令
- CentOS 7.x 防火墙开放端口相关用法记录
- 关闭selinux和防火墙开启状态增加3306端口
- CentOS7 下一个利用安全日志和防火墙防止暴力破解的SHELL脚本
- centos 端口、防火墙篇