Monday, December 18, 2017

CentOS 7开放防火墙端口

CentOS 7使用firewalld代替了原来的iptables。下面记录如何使用firewalld开放CentOS 7端口:

开放端口(以80端口为例)

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含义:

–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

重启防火墙

firewall-cmd --reload

详细信息可以参考以下资料:

http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html

Leave a Reply

Your email address will not be published. Required fields are marked *