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

    1. 使用setup命令

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

    [root@localhost ~]# setup

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

    image

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

    image

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

    image

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

    image

    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 ~]# chkconfig iptables off
     
     
  • 相关阅读:
    吴太银:华为消费者云服务Cassandra使用场景与最佳实践
    使用FileZilla连接Linux
    debug 与 release
    删除cocos2dx项目模版
    [转]C/C++控制台输出时设置字体及背景颜色
    iphone调试的一些问题
    [转]Refactoring Game Entities with Components
    使用QT + cocos2dx制作工具
    [转]printf输出字体颜色
    Error: No module named books
  • 原文地址:https://www.cnblogs.com/phpdragon/p/4178761.html
Copyright © 2011-2022 走看看