检查服务器端口并开通端口

检查端口

[root@wb ~]# firewall-cmd --query-port=80/tcp --zone=public
no
[root@wb ~]# firewall-cmd --query-port=22/tcp --zone=public
no
[root@wb ~]# firewall-cmd --query-port=30930/tcp --zone=public
yes

设置端口

[root@wb ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success

配置生效

firewall-cmd --reload

查看开通的所有端口

firewall-cmd --zone=public --list-ports

批量开通端口

firewall-cmd --zone=public --add-port=100-500/tcp --permanent

检查防火墙

[root@wb ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-02-12 12:58:13 UTC; 7min ago
     Docs: man:firewalld(1)
 Main PID: 502 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─502 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Feb 12 12:58:12 wb systemd[1]: Starting firewalld - dynamic firewall daemon...
Feb 12 12:58:13 wb systemd[1]: Started firewalld - dynamic firewall daemon.

关闭防火墙

[root@wb ~]# systemctl stop firewalld

开通防火墙

[root@wb ~]# systemctl start firewalld

你可能感兴趣的:(linux)