zoukankan      html  css  js  c++  java
  • CentOS7防火墙的基本使用

    查看防火墙状态:systemctl status firewalld.service
    关闭防火前墙:systemctl stop firewalld.service
    开启防火前墙:systemctl start firewalld.service
    如下图所示:

      

    绿的running表示防火墙开启。
    白的dead表示防火墙已经关闭。
    执行开机禁用防火墙自启命令:systemctl disable firewalld.service
    执行防火墙随系统开启启动命令:systemctl enable firewalld.service

    CentOS 6.X 是iptables,可以使用vim /etc/sysconfig/iptables修改配置即可。
    可以使用命令关闭/开启/查看防火墙:

    (1)重启后永久性生效:
      开启:chkconfig iptables on        关闭:chkconfig iptables off
    (2)即时生效,重启后失效:
      开启:service iptables start        关闭:service iptables stop      重启:service iptables restart      查看防火墙状态:service iptables status

    本博主的是CentOS 7.X 防火墙使用的是firewalld,我们可以使用命令的方式来添加端口(修改后需要重启firewalld服务):
    例如添加80端口:

    [root@itheima zones]# pwd
    /etc/firewalld/zones
    [root@itheima zones]# firewall-cmd --permanent --add-port=80/tcp  
    success
    [root@itheima zones]# service firewalld restart
    Redirecting to /bin/systemctl restart firewalld.service
    [root@itheima zones]

    CentOS 7X默认使用的是firewall作为防火墙,要想使用iptables必须重新设置一下,步骤如下:
    1、直接关闭防火墙firewall

    systemctl stop firewalld.service        #停止firewall
    systemctl disable firewalld.service     #禁止firewall开机启动

    2、设置iptables-service

    yum -y install iptables-services

    3、如果要修改防火墙配置,例如增加防火墙端口3306

    vi /etc/sysconfig/iptables

    增加规则

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

    保存退出后

    systemctl restart iptables.service      #重启防火墙使配置生效
    systemctl enable iptables.service       #设置防火墙开机启动

    最后重启系统使设置生效即可。

    systemctl start iptables.service        #打开防火墙
    systemctl stop iptables.service         #关闭防火墙
  • 相关阅读:
    笔记2-斐波那契数列
    笔记1-排序
    C++ 顶层const和底层const ?
    C++指针常量与常量指针的区别?
    C++指针和引用的区别?
    函数指针, 指针函数?
    手机横竖屏问题
    Swift
    Swift 渐变色
    Swift guard 关键字
  • 原文地址:https://www.cnblogs.com/chenmingjun/p/9936388.html
Copyright © 2011-2022 走看看