码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS7 防火墙 firewall-cmd

时间:2015-12-05 16:06:20      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

最小化安装 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:

 

CentOS7 防火墙 firewall-cmd

标签:

原文地址:http://www.cnblogs.com/miaochw/p/5021676.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!