1. 开启端口
firewall-cmd --zone=public --add-port=80/tcp --permanent #开放80端口
命令含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效
centos7 防火墙常用操作
firewall-cmd --state
view status of firewalld service (systemctl status firewalld)
firewall-cmd --zone=public --list-all
gets all info for the “public” zone
firewall-cmd --list-all-zones
shows all info for all zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
adds port 80 to public zone
firewall-cmd --zone=public --add-service=http --permanent
adds service http to public zone
firewall-cmd --reload
run this after making changes
firewall-cmd --zone=public --remove-port=80/tcp --permanent
to remove port 80 from public zone
firewall-cmd --get-default-zone
shows default zone for firewall
firewall-cmd --get-active-zones
zones where network interfaces or sources are assigned
设置开机起动: systemctl enable httpd.service
firewall-cmd --state
view status of firewalld service (systemctl status firewalld)
firewall-cmd --zone=public --list-all
gets all info for the “public” zone
firewall-cmd --list-all-zones
shows all info for all zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
adds port 80 to public zone
firewall-cmd --zone=public --add-service=http --permanent
adds service http to public zone
firewall-cmd --reload
run this after making changes
firewall-cmd --zone=public --remove-port=80/tcp --permanent
to remove port 80 from public zone
firewall-cmd --get-default-zone
shows default zone for firewall
firewall-cmd --get-active-zones
zones where network interfaces or sources are assigned
设置开机起动: systemctl enable httpd.service