firewall 开启查看关闭端口

ps:firewall是centos7系统自带的防火墙 ,centos6使用的是iptables(配置文件路径:/etc/sysconfig/iptables)

查看端口

firewall-cmd --zone=public --query-port=80/tcp

 开启端口

# --permanent 表示永久有效,没有这个参数重启后会失效
firewall-cmd --zone=public --add-port=80/tcp --permanent

删除端口

# --permanent 表示永久有效,没有这个参数重启后会失效
firewall-cmd --zone=public --remove-port=80/tcp --permanent

使firewall修改后生效 

firewall-cmd --reload

firewall在centos7中的配置文件(/etc/firewalld/zones/public.xml)

vi /etc/firewalld/zones/public.xml

firewalld服务

# 查看防火墙服务状态
systemctl status firewalld

# 启用防火墙服务
systemctl start firewalld

# 关闭防火墙服务
systemctl stop firewalld

# 重启防火墙服务
systemctl restart firewalld

# 开机启动防火墙服务
systemctl enable firewalld

# 关闭开机启动防火墙服务
systemctl disable firewalld

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章