zoukankan      html  css  js  c++  java
  • Linux系统修改防火墙配置

    修改Linux系统防火墙配置需要修改 /etc/sysconfig/iptables 这个文件
    1 vim /etc/sysconfig/iptables

    在vim编辑器,会看到下面的内容

    复制代码
     1 # Firewall configuration written by system-config-firewall
     2 # Manual customization of this file is not recommended.
     3 *filter
     4 :INPUT ACCEPT [0:0]
     5 :FORWARD ACCEPT [0:0]
     6 :OUTPUT ACCEPT [0:0]
     7 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
     8 -A INPUT -p icmp -j ACCEPT
     9 -A INPUT -i lo -j ACCEPT
    10 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    11 -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
    12 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
    13 -A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT
    14 -A INPUT -j REJECT --reject-with icmp-host-prohibited
    15 -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    16 COMMIT
    复制代码

    需要开放端口,请在里面添加一条一下内容即可:

    1 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT

    其中 1521 是要开放的端口号,然后重新启动linux的防火墙服务。

    Linux下停止/启动防火墙服务的命令(root用户使用):

    1 service iptables stop --停止
    2 
    3 service iptables start --启动

    写在最后:

    复制代码
    1 #永久性生效,重启后不会复原
    2 chkconfig iptables on    #开启
    3 
    4 chkconfig iptables off    #关闭
    5 
    6 #即时生效,重启后复原
    7 service iptables start    #开启
    8 
    9 service iptables stop    #关闭
    复制代码

    一、service方式

    查看防火墙状态:

    [root@centos6 ~]# service iptables status

    iptables:未运行防火墙。

    开启防火墙:

    [root@centos6 ~]# service iptables start

    关闭防火墙:

    [root@centos6 ~]# service iptables stop

    二、iptables方式

    先进入init.d目录,命令如下:

    [root@centos6 ~]# cd /etc/init.d/

    [root@centos6 init.d]#

    然后

    查看防火墙状态:

    [root@centos6 init.d]# /etc/init.d/iptables status

    暂时关闭防火墙:

    [root@centos6 init.d]# /etc/init.d/iptables stop

    重启iptables:

    [root@centos6 init.d]# /etc/init.d/iptables restart

  • 相关阅读:
    fastDFS与nginx整合2
    fastDFS分布式文件系统
    NIO编程
    Nginx正向代理与反向代理
    JAVA序列化
    FileUpload问题
    测试覆盖率实现技术
    Hutool 功能特色:
    自建右键服务器
    20191123-SWITCH后面跟的参数不能为string类型
  • 原文地址:https://www.cnblogs.com/pypua/p/10999108.html
Copyright © 2011-2022 走看看