CentOS 7.x 用shell增加、删除端口
2023-09-14 08:58:43 时间
一、在/usr/local/sbin/下创建port文件,不要扩展名,并给权限 chom 777 port
#!/bin/bash num=$# ok=0 if [ ${num} == 1 ]; then if [ $1 == 'list' ]; then firewall-cmd --zone=public --list-ports exit 0 fi fi if [ ${num} != 2 ]; then echo 'error:you must input two parmas, first is add or remote, second is port number' exit 0 fi case $1 in add) firewall-cmd --zone=public --add-port=$2/tcp --permanent #firewall-cmd --zone=public --add-port=$2/udp --permanent ok=1 ;; remove) firewall-cmd --zone=public --remove-port=$2/tcp --permanent #firewall-cmd --zone=public --remove-port=$2/udp --permanent ok=1 ;; *) echo 'first params must be "add" or "remove"' ;; esac if [ ${ok} == 1 ]; then firewall-cmd --reload firewall-cmd --zone=public --list-all fi exit 0
二、用法
#port add 8080
#port remove 8080
#port list
相关文章
- yum命令安装软件时,出现--centos 7 安装apache 出现 Could not resolve host: mirrorlist.centos.org; 未知的错误"--CentOS网络设置 couldn't resolve host 'mirrorlist.centos.org问题解决
- 更改CentOS 6.3 yum源为国内 阿里云源
- virtualbox虚拟机上安装centOS的网络配置(安装centos时选择桥接网络)
- 在Centos 6 64bit 上安装 Hyperic HQ 5.8.2.1 中文版
- 各种官网系统镜像文件(Windows 7 ,Windows 10,Ubuntu 18.6,Centos 6.8 ,Centos 7.6 )
- 学习centos之快速搭建LNMP环境
- CentOS报错:Could not retrieve mirrorlist http://mirrorlist.centos.org
- Linux Shell脚本自动化编程实战-shell变量(一)
- Linux Shell脚本自动化编程实战- shell函数
- Linux Shell脚本自动化编程实战- shell并发
- centOS安装telnet服务和xinetd服务和iptables和linux运行级别
- 如何在windows上安装centos单系统,以及安装事项和 centOS Linux和centOS Stream区别
- centos防火墙操作firewalld and systemctl 打开linux端口的shell脚本
- [shell]Shell经常使用特殊符号
- 腾讯云CentOS 安装MediaWiki
- 18.第六章 Shell脚本编程基础入门 -- 编程基础和shell脚本语言的基本用法(一)
- 【Linux之Shell脚本实战】猜拳小游戏shell脚本
- 【Linux之Shell脚本实战】Centos最小化安装环境配置脚本
- centos 7 搭建ceph集群——筑梦之路
- CentOS curl命令
- MYSQL提权之反弹SHELL——数据库提权属于webshell到管理员的纵向提权,本质还是利用udf提权,无非是在mysql自定义函数中使用了反弹shell而已
- centos下安装mongodb 通过shell脚本
- centos搭建集群
- CentOS下使用yum快速安装memcached
- Centos 7 安装convert命令
- shell - 08 - Shell文本处理三剑客 - sed -编辑命令详解