centos7开放端口设置
Posted 还行少年
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7开放端口设置相关的知识,希望对你有一定的参考价值。
1.防火墙操作
启动防火墙: systemctl start firewalld
[root@localhost ~]# systemctl start firewalld.service
查看状态: systemctl status firewalld
[root@localhost ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since 一 2021-05-17 16:51:19 CST; 4s ago
Docs: man:firewalld(1)
Main PID: 9189 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─9189 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
5月 17 16:51:18 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall .....
5月 17 16:51:19 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall d...n.
5月 17 16:51:20 localhost.localdomain firewalld[9189]: WARNING: AllowZoneDrifting is enab....
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#
2.开放指定端口
查看端口状态
[root@localhost ~]# firewall-cmd --zone=public --query-port=80/tcp //查看80端口状态
no
开放80端口
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent //开放TCP80端口,永久生效
success
[root@localhost ~]# firewall-cmd --reload //重载使其生效
success
再次查看端口状态
[root@localhost ~]# firewall-cmd --zone=public --query-port=80/tcp
yes
关闭指定端口
关闭80端口
[root@localhost ~]# firewall-cmd --zone=public --remove-port=80/tcp --permanent //关闭端口,永久生效
success
[root@localhost ~]# firewall-cmd --reload //重载使其生效
success
查看端口状态
[root@localhost ~]# firewall-cmd --zone=public --query-port=80/tcp
no
以上是关于centos7开放端口设置的主要内容,如果未能解决你的问题,请参考以下文章