zoukankan      html  css  js  c++  java
  • centos 防火墙配置

    1. 使用setup命令

    [1] 打开一个终端窗口,输入setup命令

    [root@localhost ~]# setup

    [2] 选择Firewall configuration, 选择Run Tool,进入防火墙配置界面

    [3] 勾选Enabled开启防火墙,不勾选则不开启,此处开启,并选择Customize进行自定义配置

    [4] 选择要开放的服务端口,此例选择FTP,WWW(HTTP)。默认SSH服务端口是开启的,用于SSH远程登陆,如果是远程配置Linux服务器,则一定要保持SSH服务端口打开,不要自断后路。

    [5] 配置好后一路Forward到最后保存即可,若还有其它的端口要开放,中间也有相应的自定义页面。最后到这个页面时选择Yes,覆盖原设置保存。

    2. 命令行方式

    [1] 编辑防火墙配置,21端口和80端口是增加的FTP服务与80服务端口

    [root@localhost ~]# vi /etc/sysconfig/iptables
    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.*filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    [2] 关闭防火墙服务(暂时关闭防火墙服务,重启后服务会自动开启)

    [root@localhost ~]# service iptables stop
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Unloading modules:                               [  OK  ]

    [3] 配置防火墙服务默认开机不启动 (如果服务器不需要防火墙)

    注:防火墙的基本操作命令:

    查询防火墙状态:

    [root@localhost ~]# service   iptables status<回车>

     

    停止防火墙:

    [root@localhost ~]# service   iptables stop <回车>

     

    启动防火墙:

    [root@localhost ~]# service   iptables start <回车>

     

    重启防火墙:

    [root@localhost ~]# service   iptables restart <回车>

     

    永久关闭防火墙:

    [root@localhost ~]# chkconfig   iptables off<回车>

     

    永久关闭后启用:

    [root@localhost ~]# chkconfig   iptables on<回车>

    [root@localhost ~]# chkconfig iptables off

  • 相关阅读:
    Codeforces Round #629 (Div. 3) (A ~ F)
    st表
    Educational Codeforces Round 81 (Rated for Div. 2)
    hihocoder#1996 : 01匹配
    P2056 [ZJOI2007]捉迷藏
    P2495 [SDOI2011]消耗战
    GUETOJ1335
    优先队列重载比较运算
    CCF认证201909-4 推荐系统
    P3178 [HAOI2015]树上操作
  • 原文地址:https://www.cnblogs.com/wuxl360/p/5594145.html
Copyright © 2011-2022 走看看