美文网首页
Centos7防火墙

Centos7防火墙

作者: o_p_q_o | 来源:发表于2019-05-14 16:15 被阅读0次

    Centos7 firewall 命令:

    • 查看已经开放的端口
    firewall-cmd --list-ports
    
    • 开启端口
    firewall-cmd --zone=public --add-port=80/tcp --permanent
    
    • 重启防火墙
    firewall-cmd --reload   #重启firewall
    
    • 关闭防火墙
    systemctl stop firewalld.service   #停止firewall
    systemctl disable firewalld.service   #禁止firewall开机启动
    

    iptables

    • 编辑防火墙配置文件
    vi /etc/sysconfig/iptables 
    
    # sampleconfiguration for iptables service
    # you can edit thismanually or use system-config-firewall
    # please do not askus to add additional ports/services to this default configuration
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT[0:0]
    :OUTPUT ACCEPT[0:0]
    -A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
    -A INPUT -p icmp -jACCEPT
    -A INPUT -i lo -jACCEPT
    -A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
    -A INPUT -j REJECT--reject-with icmp-host-prohibited
    -A FORWARD -jREJECT --reject-with icmp-host-prohibited
    COMMIT
    

    添加端口:-A INPUT -p tcp -m state --state NEW -m tcp--dport 9090 -j ACCEPT

    systemctlrestart iptables.service   #最后重启防火墙使配置生效
    systemctlenable iptables.service   #设置防火墙开机启动
    

    相关文章

      网友评论

          本文标题:Centos7防火墙

          本文链接:https://www.haomeiwen.com/subject/tcfeaqtx.html