• centos 7 临时和永久关闭Selinux 防火墙


    1. 临时和永久关闭Selinux

    [root@localhost ~]# getenforce
    Enforcing

    [root@localhost ~]# setenforce 0
    [root@localhost ~]# getenforce
    Permissive

    永久关闭:

    [root@localhost ~]# vim /etc/sysconfig/selinux

    SELINUX=enforcing 改为 SELINUX=disabled

    #注释掉
    #SELINUXTYPE=targeted 
    重启服务reboot

    2.firewalld服务

    1. firewalld服务启用/停用

    启动一个服务:systemctl start firewalld.service
    关闭一个服务:systemctl stop firewalld.service
    重启一个服务:systemctl restart firewalld.service
    显示一个服务的状态:systemctl status firewalld.service
    在开机时启用一个服务:systemctl enable firewalld.service
    在开机时禁用一个服务:systemctl disable firewalld.service
    查看服务是否开机启动:systemctl is-enabled firewalld.service
    查看已启动的服务列表:systemctl list-unit-files|grep enabled
    查看启动失败的服务列表:systemctl --failed

    2.配置firewalld-cmd

    查看版本: firewall-cmd –version
    查看帮助: firewall-cmd –help
    显示状态: firewall-cmd –state
    查看所有打开的端口: firewall-cmd –zone=public –list-ports
    更新防火墙规则: firewall-cmd –reload
    查看区域信息: firewall-cmd –get-active-zones
    查看指定接口所属区域: firewall-cmd –get-zone-of-interface=eth0
    拒绝所有包:firewall-cmd –panic-on
    取消拒绝状态: firewall-cmd –panic-off
    查看是否拒绝: firewall-cmd –query-panic

    3.端口管理:

    添加: firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent 永久生效,没有此参数重启后失效)
    重新载入:firewall-cmd --reload
    查看:firewall-cmd --zone= public --query-port=80/tcp
    删除:firewall-cmd --zone= public --remove-port=80/tcp --permanent

    正式环境下,看需要选择是否使用防火墙,这里为了方便后续配置,就先将其关闭:

    关闭防火墙 systemctl stop firewalld
    禁止开机自启systemctl disable firewalld
    查看防火墙状态systemctl status firewalld



    作者:姬艾思
    链接:https://www.jianshu.com/p/cbf8e0009bc0
    来源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
  • 相关阅读:
    窥探算法之美妙——详细讲解寻找最长重复字符串的原理
    窥探算法之美妙——寻找数组中最小的K个数&python中巧用最大堆
    窥探算法之美妙——统计整数二进制中1的个数
    第一次向开源项目贡献代码的历程
    编写高质量代码--改善python程序的建议(八)
    Mysql数据类型TINYINT(1)与BOOLEAN踩坑记
    Mysql Hash索引和B-Tree索引区别(Comparison of B-Tree and Hash Indexes)
    详解计算机中的Byte、bit、字、字长、字节
    什么是不忘初心
    最简单的JS实现json转csv
  • 原文地址:https://www.cnblogs.com/lyss/p/12122904.html
Copyright © 2020-2023  润新知