开放端口
#!/bin/bash
systemctl status firewalld > /dev/null;
echo "input port:$1"
if [ $? -eq 0 ]
then
echo "now open port :"
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --query-port=$1/tcp > /dev/null
if [ $? -ne 0 ]
then
firewall-cmd --zone=public --add-port=$1/tcp --permanent > /dev/null
firewall-cmd --reload > /dev/null
echo "new open port :"
firewall-cmd --zone=public --list-ports
else
echo "port $1 is alread opened!"
fi
fi