Centos 7 使用(Service iptables stop/start)关闭/打开防火墙 Failed to stop iptables.service: Unit iptables.service not loaded.

  背景: 

    测试部署NetCore 项目到linux 系统时,窗口显示项目部署成功;但是本机无法访问(linux 在虚拟机上[ centos 7.6] );  如下图↓

    

   能够相互ping  通,(Xshell 连接正常。),在centos 上 也能正常访问,后来记起在进行linux   安装成功后,没有关闭防火墙,初步猜测是由于没有关闭防火墙导致,那关闭防火墙不就可以了?

 二、操作

   1、打开linux 终端,输入:  service  iptables stop   ,就提示 标题展示的异常;

  

   2、然后输入:systemctl stop firewalld   (暂时关闭防火墙)

      查看防火墙状态:systemctl status firewalld   

  

  

  成功了!!!!

  三、回顾总结

    经过查找发现:在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理 ; 如果想要使用 service iptables start/stop 命令,需要下载     iptables-services 

    1、在 Centos 7 下下载 iptables-services 时,需要执行以下命令

      systemctl stop firewalld     --关闭防火墙  

      systemctl mask firewalld   

       yum install iptables-services   --安装iptables-services

       systemctl enable iptables    --设置开机启动

      service iptables save       --保存

    2、操作linux 防火墙命令:      

1:查看防火状态
    systemctl status firewalld
    service  iptables status

2:暂时关闭防火墙
    systemctl stop firewalld
    service  iptables stop

3:永久关闭防火墙
    systemctl disable firewalld
    chkconfig iptables off

4:重启防火墙
    systemctl enable firewalld
    service iptables restart  

5:永久关闭后重启(未测试)
    chkconfig iptables on

查找资料:1、https://www.cnblogs.com/jxldjsn/p/10794171.html

     2、https://blog.csdn.net/c233728461/article/details/52679558/

 如有不合理之处,请大家多多指教。

    如果您觉得本文对您有帮助,欢迎点击“收藏”按钮!(/:微笑)欢迎转载,转载请注明出处。

猜你喜欢

转载自www.cnblogs.com/skyheaving/p/12283656.html
今日推荐