zoukankan      html  css  js  c++  java
  • CentOS 7.x 用shell增加、删除端口

    一、在/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

  • 相关阅读:
    数组的基本操作
    面向对象
    继承
    JavaBean规范
    JVM内存模型
    数组的排序
    this
    访问控制权限
    数组
    方法的重载
  • 原文地址:https://www.cnblogs.com/aipeli/p/10153540.html
Copyright © 2011-2022 走看看