zoukankan      html  css  js  c++  java
  • (转载)Linux下IPTABLES防火墙的设定

    (转载)http://www.jefflei.com/post/1760.html

    1.iptables防火墙启动和停止

    启动iptables防火墙时命令行输入 #service iptables start

    [root@host.jefflei.com ~]# service iptables start
    应用 iptables 防火墙规则:                                  [确定]
    载入额外 iptables 模块:ip_conntrack_netbios_ns             [确定]

    要停止iptables命令行输入 #service iptables stop

    [root@host.jefflei.com ~]# service iptables stop
    清除防火墙规则:                                            [确定]
    把 chains 设置为 ACCEPT 策略:filter                        [确定]
    正在卸载 Iiptables 模块:                                   [确定]

    2.查看iptables的状态

    命令行输入 #service iptables status

    [root@host.jefflei.com ~]# service iptables status
    表格:filter
    Chain INPUT (policy ACCEPT)
    num   target      prot opt source                destination
    1     RH-Firewall-1-INPUT   all  --  0.0.0.0/0            0.0.0.0/0           
    
    Chain FORWARD (policy ACCEPT)
    num   target      prot opt source                destination
    1     RH-Firewall-1-INPUT   all  --  0.0.0.0/0            0.0.0.0/0           
    
    Chain OUTPUT (policy ACCEPT)
    num   target      prot opt source                destination         
    
    Chain RH-Firewall-1-INPUT (2 references)
    num   target      prot opt source                destination
    1     ACCEPT      all  --  0.0.0.0/0            0.0.0.0/0
    2     ACCEPT      icmp --  0.0.0.0/0            0.0.0.0/0            icmp type 255
    3     ACCEPT      esp  --  0.0.0.0/0            0.0.0.0/0
    4     ACCEPT      ah   --  0.0.0.0/0            0.0.0.0/0
    5     ACCEPT      udp  --  0.0.0.0/0            224.0.0.251          udp dpt:5353
    6     ACCEPT      udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:631
    7     ACCEPT      tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:631
    8     ACCEPT      all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    9     ACCEPT      tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
    10    ACCEPT      tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:23
    11    ACCEPT      tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:80
    12    ACCEPT      tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:110
    13    ACCEPT      tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:443
    14    REJECT      all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

    *上面的输出显示了防火墙处于开启状态,并打开了22,23,80,110, 443端口

    3.查看iptables规则集

    要查看系统中现有的iptables规则集,可以运行以下命令:

    iptables --list

    4.清除原有防火墙规则.

    不管你在安装linux时是否启动了防火墙,如果你想配置属于自己的防火墙,那就清除现在filter的所有规则.

    [root@host.jefflei.com  ~]# iptables -F 清除预设表filter中的所有规则链的规则
    [root@host.jefflei.com  ~]# iptables -X 清除预设表filter中使用者自定链中的规则

    查看本机关于IPTABLES的设置情况

    iptables -L -n

    现在和安装linux时没有启动防火墙一样了.这些防火墙配置重起就会失去作用,当需要保存时使用如下命令

    /etc/rc.d/init.d/iptables save

    这样就可以写到/etc/sysconfig/iptables文件里了.写入后记得把防火墙重起一下,才能起作用.

    service iptables restart

    4.开机后自启动防火墙的设定

    命令行输入 #ntsysv

    [root@host.jefflei.com ~]# ntsysv

    在gui中选上iptables后。确认

    5.简单配置防火墙规则

    [root@host.jefflei.com ~]# setup

    选择 防火墙配置–》定制–》在“其他端口”中输入要开放的端口, 例:1723

  • 相关阅读:
    web10 动态action的应用
    web09 struts2配置 struts2入门
    web 08 struts2入门 struts2配置 struts包
    web07-jdbcBookStore
    web06-PanduanLogin
    web05-CounterServlet
    web04-LoginServlet
    web03-OutputInfo
    web02-welcomeyou
    web01-helloworld
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3239177.html
Copyright © 2011-2022 走看看