标签:
最小化安装 CentOS7 后,很多端口默认是不打开的,需要通过 firewall-cmd 把这些端口打开。
检查防火墙状态
# firewall-cmd --state
running
关闭防火墙
# systemctl stop firewalld # firewall-cmd --state not running
查看开放端口列表
# firewall-cmd --list-all
public (default, active)
interfaces: docker0 enp0s3
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
暂时开放http 服务
# firewall-cmd --add-service=http
永久开放http 服务
# firewall-cmd --add-service=http --permanent
永久关闭http 服务
# firewall-cmd --remove-service=http --permanent
让设定生效
# systemctl restart firewalld
获取FirewallD 的服务名称
# firewall-cmd --get-service amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https
查询服务的启用状态
# firewall-cmd --query-service http
yes
开放指定的端口
# firewall-cmd --add-port=80/tcp # firewall-cmd --list-all public (default) interfaces: sources: services: dhcpv6-client ftp ssh ports: 80/tcp masquerade: no forward-ports: icmp-blocks: rich rules:
标签:
原文地址:http://www.cnblogs.com/miaochw/p/5021676.html