• CentOS7防火墙


    [10gen] 
    
    name=10gen Repository 
    
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 
    
    gpgcheck=0 
    
    
    systemctl stop firewalld
    systemctl mask firewalld
    
    关闭虚拟机防火墙:
    关闭命令:  service iptables stop
    永久关闭防火墙:chkconfig iptables off
    两个命令同时运行,运行完成后查看防火墙关闭状态
    service iptables status
    1 关闭防火墙-----service iptables stop 
    2 启动防火墙-----service iptables start 
    3 重启防火墙-----service iptables restart 
    4 查看防火墙状态--service iptables status 
    5 永久关闭防火墙--chkconfig iptables off 
    6 永久关闭后启用--chkconfig iptables on
    
    CentOS7中执行
    service iptables start/stop
    会报错Failed to start iptables.service: Unit iptables.service failed to load: No such file or directory.
    在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,
    如果要添加范围例外端口 如 1000-2000
    语法命令如下:启用区域端口和协议组合
    firewall-cmd [--zone=<zone>] --add-port=<port>[-<port>]/<protocol> [--timeout=<seconds>]
    此举将启用端口和协议的组合。端口可以是一个单独的端口 <port> 或者是一个端口范围 <port>-<port> 。协议可以是 tcp 或 udp。
    实际命令如下:
    firewall-cmd --permanent --add-port=1000-2000/tcp
    执行可以成功
    用该命令查询firewall-cmd --permanent --query-port=1000/tcp
    
    当然你可以还原传统的管理方式。
    执行一下命令:
    systemctl stop firewalld
    systemctl mask firewalld
    
    并且安装iptables-services:
    yum install iptables-services
    
    设置开机启动:
    systemctl enable iptables
    
    systemctl stop iptables
    systemctl start iptables
    systemctl restart iptables
    systemctl reload iptables
    
    保存设置:
    service iptables save
    
    OK,再试一下应该就好使了
    
    开放某个端口 在/etc/sysconfig/iptables里添加
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
  • 相关阅读:
    使用knockout.js 完毕template binding
    站点建设价格为什么有高有低?站点建设该怎样选择?
    同余 模算术 中国剩余定理
    linux 命令之 apt-get
    [Leetcode]-Reverse Integer
    《Python入门》Windows 7下Python Web开发环境搭建笔记
    javascript之Ajax起步
    SQL server 2012 安装SQL2012出现报错: 启用 Windows 功能 NetFx3 时出错
    C# 反射具体解释
    java8_api_jni
  • 原文地址:https://www.cnblogs.com/OnlyDreams/p/7428661.html
Copyright © 2020-2023  润新知