centos7安装防火墙firewalld

centos7已经将防火墙改为firewalld,默认的centos7 minimal是不自带firewalld,下面来安装吧

# yum install -y firewalld
# systemctl start firewalld
# systemctl enable  firewalld

那我们访问原来的elasticsearch的head插件,发现已经不可以访问了

输入图片说明

注:elasticsearch需要开放9200,9300两个端口

# firewall-cmd --add-port=9200/tcp --permanent  #永久开放9200端口
# firewall-cmd --add-port=9300/tcp --permanent  #永久开放9300端口
# firewall-cmd --reload  #重新加载
# firewall-cmd --list-all #查看防火墙配置
public (default)
  interfaces:
  sources:
  services: dhcpv6-client ssh
  ports: 9200/tcp 9300/tcp
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

再访问head插件

输入图片说明

然后我们再禁用此端口

# firewall-cmd --remove-port=9200/tcp --permanent
# firewall-cmd --add-port=9300/tcp --permanent 
# firewall-cmd --reload  #重新加载
#  firewall-cmd --list-all #查看防火墙配置,可知9200端口已经被禁用
public (default)
  interfaces:
  sources:
  services: dhcpv6-client ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

再次访问head插件

输入图片说明

80端口一般是我们开放http服务的端口,下面我们来看看怎么配置吧

# ss -lpt | grep http  #查看http端口,由此可知nginx在占用
LISTEN     0      128        *:http                     *:*                     users:(("nginx",pid=1363,fd=6),("nginx",pid=1359,fd=6))

查看防火墙可配置的服务

# firewall-cmd --get-services
RH-Satellite-6 amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec iscsi-target 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 rsyncd samba samba-client smtp ssh telnet tftp tftp-client transmission-client vdsm vnc-server wbem-https

对外公开http服务

# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload

直接访问ip

输入图片说明

禁用http服务

# firewall-cmd  firewall-cmd --remove-service=http --permanent
# firewall-cmd --reload
# firewall-cmd --list-services
dhcpv6-client ssh

直接访问ip

输入图片说明

转载于:https://my.oschina.net/weidedong/blog/760867

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值