`
sooxin
  • 浏览: 263490 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

CentOS 7.0关闭默认防火墙启用iptables防火墙

 
阅读更多

操作系统环境:CentOS Linux release 7.0.1406(Core) 64位
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。

1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

2、iptables防火墙(这里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 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-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
:wq! #保存退出

备注:这里使用80和8080端口为例。***部分一般添加到“-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动

分享到:
评论

相关推荐

    CentOS 7.0关闭默认防火墙启用iptables防火墙.docx

    CentOS 7.0关闭默认防火墙启用iptables防火墙.docx

    CentOS 7.0关闭默认防火墙启用iptables防火墙的设置方法

    主要介绍了CentOS 7.0关闭默认防火墙启用iptables防火墙的设置方法,需要的朋友可以参考下

    CentOS 7.0启用iptables防火墙.docx

    首先,由于 CentOS 7.0 默认使用 firewallD,所以在启用 iptables 之前,我们需要关闭 firewallD 服务。这可以通过以下两条命令完成: 1. `systemctl stop firewalld.service` - 此命令会立即停止 firewallD 服务。...

    Linux软防火墙ACL匹配的优化点.docx

    此外,我们还可以使用 CentOS 7.0 关闭默认防火墙启用 iptables 防火墙。 在优化 iptables 的性能时,我们需要注意的是,不要根据规章将规章分到一个组,而要以匹配元素为分组基准。这是因为匹配元素的数量是固定的...

    CentOS 7.0编译安装lnmp教程(Nginx1.6.0+MySQL5.6.19+PHP5.5.14)

    CentOS 7.0默认使用firewall,但我们将切换到iptables。执行以下命令关闭并禁用firewall: ```bash systemctl stop firewalld.service systemctl disable firewalld.service ``` 安装iptables服务,并编辑...

    虚拟机部署zabbix详细笔记

    - **关闭默认防火墙并启用iptables:** - 停止并禁用firewall服务。 - 安装iptables服务,并配置规则以允许必要的端口,如HTTP(80)、MySQL(3306)等。 - 关闭SELINUX,以避免安全策略限制导致的问题。 - **软件源...

    CentOS服务器部署指南1

    在本篇"CentOS服务器部署指南1"中,我们将探讨如何在CentOS操作系统上进行基本的服务器配置,包括防火墙设置、软件安装以及关键服务的启用。以下是对这些步骤的详细说明: 首先,我们来讨论防火墙设置。在CentOS中...

    centos主从同步

    CentOS 7使用firewalld,需要关闭firewalld并启用iptables,开放873端口以允许Rsync通信。 **二、Sersync配置(源服务器)** Sersync是一款针对Linux系统的实时增量文件同步工具,可以实现文件的实时监控和同步。...

    dubbo-zookeeper集群搭建

    4. **重启并启用iptables服务**: ```bash systemctl restart iptables.service systemctl enable iptables.service ``` #### 五、安装ZooKeeper集群 1. **解压ZooKeeper**: ```bash tar -zxvf zookeeper-...

Global site tag (gtag.js) - Google Analytics