CentOS6/7-防火墙管理
#CentOS6
#开放端口运行外部访问(不指定源IP)
iptables -I INPUT -p tcp --dport -j ACCEPT
iptables -I INPUT -p tcp --dport -j ACCEPT
iptables -I INPUT -p tcp --dport -j ACCEPT #定向开放本地端口允许访问
iptables -I INPUT -s 10.86.87.0/ -p tcp --dport -j ACCEPT #然后保存:
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status #防火墙启停
/etc/init.d/iptables start
/etc/init.d/iptables stop 禁止linux向外建立新连接(INPUT 向内)
、iptables -I OUTPUT -m state --state NEW -j DROP #拒绝IP所有请求
iptables -I INPUT -s 10.86.87.123 -j DROP
service iptables save
iptables -L
修改iptables配置文件添加防火墙策略
vi /etc/sysconfig/iptables # sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [:]
:FORWARD ACCEPT [:]
:OUTPUT ACCEPT [:]
-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 -j ACCEPT
-A INPUT -p tcp -m state –-state NEW -m tcp –dport -j ACCEPT
-A INPUT -p tcp -m state –-state NEW -m tcp –dport -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
注意点:新开放的端口一定要在端口22后面
>>> CentOS 7.0默认使用的是firewall作为防火墙
#CentOS7常用命令
systemctl start firewalld.service ##启动服务
systemctl stop firewalld.service ##关闭服务
systemctl restart firewalld.service ##重启服务
systemctl status firewalld.service ##显示服务的状态
systemctl enable firewalld.service ##在开机时启用服务
systemctl disable firewalld.service ##在开机时禁用服务
systemctl is-enabled firewalld.service ##查看服务是否开机启动
systemctl list-unit-files|grep enabled ##查看已启动的服务列表
systemctl --failed ##查看启动失败的服务列表
#CentOS7使用iptables防火墙配置(推荐!!)
1、关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、设置 iptables service
yum -y install iptables-services
#如果要修改防火墙配置,如增加防火墙端口3306,tomcat8080,nginx80端口
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 [:]
:FORWARD ACCEPT[:]
:OUTPUT ACCEPT[:]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
#保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
CentOS6/7-防火墙管理的更多相关文章
- centos6.5用户管理
一.centOS6.5用户管理命令 useradd 新增用户 userdel 删除用户 passwd 修改用户密码 二.命令的使用 useradd useradd admin userdel us ...
- Django Linux环境下部署CentOS7+Python3+Django+uWSGI+Nginx(含Nginx返回400问题处理、防火墙管理)
本文将介绍如何在Linux系统上部署Django web项目,本次部署基于下面的架构: CentOS7+ Python3.5 + Django1.11 + uWSGI + Nginx 亲测可行!!按照 ...
- centos7防火墙管理的变化
当我们在centos7中输入service iptables status 查看系统的防火墙状态,会出现如下错误: 网上查阅才知道centos7的防火墙管理工具变了,原来的iptables已经不用了, ...
- linux的防火墙管理
换oricle-linux7系统后,发现iptables的管理方法有不小的改动,记录一下遇到的问题. iptables linux系统已经默认安装了iptables和firewalld两款防火墙管理工 ...
- linux入门系列10--firewalld防火墙管理
上一篇文章学习了用户及文件相关权限,本篇继续学习防火墙技术. 防火墙作为公网与内网之间的保护屏障,对系统至关重要.防火墙又分为硬件防火墙和软件防火墙,主要功能都是依据设置的策略对穿越防火墙的流量进行过 ...
- linux系统中firewalld防火墙管理工具firewall-config(GUI图形用户界面)
firewall-config是firewalld防火墙管理工具的GUI(图形用户界面)版本,几乎可以实现所有以命令行来执行的操作. firewall-config的界面如下图(在终端直接运行fire ...
- 关于centOS 7的服务启动,端口查询,防火墙管理
端口的查询与开启 CentOS 7 默认没有使用iptables,所以通过编辑iptables的配置文件来开启80端口是不可以的CentOS 7 采用了 firewalld 防火墙 如要查询是否开启8 ...
- CentOS7防火墙管理firewalld
学习apache安装的时候需要打开80端口,由于centos 7版本以后默认使用firewalld后,网上关于iptables的设置方法已经不管用了,想着反正iptable也不太熟悉,索性直接搬官方文 ...
- Centos6.5 防火墙开放端口
0. 说明 centos6.5处于对安全的考虑,严格控制网络进去.所以在安装mysql或者使用tomcat,需要开放端口3306或8080. 通常的解决办法有两个.一个是直接关闭防火墙(非常不推荐): ...
- centos6.8防火墙模块未加载
使用阿里云服务器下的centos6.8系统,开启或关系或查询防火墙的状态时,提示防火墙模块未加载. 解决办法: modprobe ip_tables #加载ip_tables模块 modprobe i ...
随机推荐
- Cydia Tweak--Cydia Substrate
http://www.jianshu.com/p/8982e9670fc6 Cydia Substrate.MobileHooker MSHookMessageEx MSHookFunction Mo ...
- 【转】jpg png区别和使用
为什么想整理这方面的类容,我觉得就像油画家要了解他的颜料和画布.雕塑家要了解他的石材一样,作为网页设计师也应该对图片格式的特性有一定了解,这样才能更好的表达你的创意和想法. 除此之外,我们在平时工作中 ...
- 2018.8.1 Java中的反射和同步详解
为何要使用同步? java允许多线程并发控制,当多个线程同时操作一个可共享的资源变量时(如数据的增删改查), 将会导致数据不准确,相互之间产生冲突,因此加入同步锁以避免在该线程没有完成操作之前,被其他 ...
- sql学习之创建表空间创建用户并授权
--创建表空间语法:create tablespace [name]create tablespace hclTest--设置参数datafile 'F:/orcale/hclTest'--设置表空间 ...
- Multigrid for Poisson’s Equation
泊松方程如何用多重网格求解 来源:佐治亚理工学院 教授:Prof. Richard Vuduc 主页:http://vuduc.org/index.php 教授内容:http://vuduc.org/ ...
- File类,递归
File类 File文件和目录路径名的抽象表示形式.即,Java中把文件或者目录(文件夹)都封装成File对象. File类包含 路径 path E:\... 目录 direct ...
- 根据值设置select的选中项
$('.selector').attr("checked", true); <s:iterator value="jobSelect" id=" ...
- ios数据持久化--CoreData框架的介绍和使用
1.Core Data 是数据持久化存储的最佳方式 2.数据最终的存储类型可以是:SQLite数据库,XML,二进制,内存里,或自定义数据类型 在Mac OS X 10.5Leopard及以后的版本中 ...
- linux下后台运行jar包
#当前窗口退出 项目关闭$ java -jar test.jar #当前窗口关闭 项目关闭$ nohup java -jar test.jar &#当前窗口关闭 项目不关闭$ nohup ja ...
- MySQL为何不建议使用null列
Preface Null is a special constraint of columns.The columns in table will be added null cons ...