AI智能
改变未来

CentOS 防火墙常用基本命令


功能 命令
查看防火墙状态 firewall-cmd –state 或者systemctl status firewalld
开启 systemctl start firewalld
关闭 systemctl stop firewalld
重启 systemctl restart firewalld
开机自启动 systemctl enable firewalld.service
永久关闭 systemctl disable firewalld.service
查看防火墙开放的端口 firewall-cmd –permanent –zone=public –list-ports
开放8080端口 firewall-cmd –zone=public –add-port=8080/tcp –permanent
取消8080端口 firewall-cmd –zone=public –remove-port=9200/tcp –permanent
重新加载防火墙规则 firewall-cmd –reload
验证新增加端口是否生效 firewall-cmd –zone=public –query-port=8080/tcp

1.查看防火墙状态:

firewall-cmd –state 

2.防火墙

systemctl start firewalld    开启

systemctl stop firewalld    关闭

systemctl restart firewalld  重启

systemctl status firewalld   状态

3.查看防火墙开放的端口

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

5.开放8080端口

firewall-cmd –zone=public –add-port=8080/tcp –permanent

6.取消8080端口

firewall-cmd –zone=public –remove-port=9200/tcp –permanent

7.重新加载防火墙规则

firewall-cmd –reload

8.验证新增加端口是否生效

firewall-cmd –zone=public –query-port=8080/tcp

9.防火墙开机自启动,永久关闭

systemctl enable firewalld.service

systemctl disable firewalld.service

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » CentOS 防火墙常用基本命令