CentOS 7.0 firewall防火墙关闭firewall作为防火墙,这里改为iptables防火墙
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤:
1.先检查是否安装了: iptables service iptables status
2.安装iptables: yum install -y iptables
3.升级iptables(安装的最新版本则不需要): yum update iptables
4.安装iptables-services: yum install iptables-services
5.禁用/停止自带的firewalld服务
(1).查看firewalld运行状态: systemctl start firewalld
(2).停止firewalld服务: systemctl stop firewalld
(3).禁用firewalld服务 systemctl mask firewalld
6.设置现有规则
(1).查看iptables现有规则: iptables -L -n
(2).先允许所有,不然有可能会杯具: iptables -P INPUT ACCEPT
(3).清空所有默认规则 iptables -F
(4).清空所有自定义规则 iptables -X
(5).所有计数器归0 iptables -Z
(6).允许来自于lo接口的数据包
(本地访问)iptables -A INPUT -i lo -j ACCEPT :
开放22端口iptables -A INPUT -p tcp --dport 22 -j ACCEPT :
开放21端口(FTP):iptables -A INPUT -p tcp --dport 21 -j ACCEPT
开放80端口(HTTP)iptables -A INPUT -p tcp --dport 80 -j ACCEPT:
开放443端口(HTTPS)iptables -A INPUT -p tcp --dport 443 -j ACCEPT:
允许pingiptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT:
允许接受本机请求之后的返回数据 RELATED,是为FTP设置的iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT:
#
其他入站一律丢弃: iptables -P INPUT DROP
所有出站一律绿灯: iptables -P OUTPUT ACCEPT
:
所有转发一律丢弃: iptables -P FORWARD DROP
其他参考规则如下:
如果要添加内网ip信任(接受其所有TCP请求)
iptables -A INPUT -p tcp -s 45.96.174.68 -j ACCEPT
过滤所有非以上规则的请求
iptables -P INPUT DROP
要封停一个IP,使用下面这条命令:
iptables -I INPUT -s ***.***.***.*** -j DROP
要解封一个IP,使用下面这条命令:
iptables -D INPUT -s ***.***.***.*** -j DROP
7.保存规则设定,将会在/etc/sysconfig/路径下生产iptables文件。
保存上述规则: service iptables save
8.开启iptables服务
(1).注册iptables服务,相当于以前的chkconfig: iptables on
systemctl enable iptables.service
(2).开启服务
systemctl start iptables.service
(3).查看状态
systemctl status iptables.service
参考iptables完整配置如下:
/**********下面是systemctl的一些命令*******************************/
观察iptables和firewalld使用的两组命令,发现三个常用的命令:service、chkconfig、systemctl。
systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。
任务:
旧指令:
新指令:
1.使某服务自动启动
chkconfig --level 3 httpd on
systemctl enable httpd.service
2.使某服务不自动启动
chkconfig --level 3 httpd off
systemctl disable httpd.service
3.检查服务状态
service httpd status
systemctl status httpd.service(服务详细信息)
systemctl is-active httpd.service(仅显示是否 Active)
4.显示所有已启动的服务
chkconfig --list
systemctl list-units --type=service
5.启动某服务
service httpd start
systemctl start httpd.service
6.停止某服务
service httpd stop
systemctl stop httpd.service
7.重启某服务
service httpd restart
systemctl restart httpd.service
CentOS 7.0 firewall防火墙关闭firewall作为防火墙,这里改为iptables防火墙的更多相关文章
- CentOS 7中firewall防火墙详解和配置以及切换为iptables防火墙
官方文档介绍地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Gui ...
- CentOS 7.4中firewall防火墙详解和配置以及切换为iptables防火墙
转载:https://blog.csdn.net/xlgen157387/article/details/52672988 一.firewall介绍 CentOS 7中防火墙是一个非常的强大的功能,在 ...
- CentOS 7中firewall防火墙详解和配置以及切换为iptables防火墙--转载
最近在linux(这里用到的是Centos7的64位版本)安装nginx时,在开放80端口时用iptables设置端口 和重启服务发现提示未找到文件,在网络上收集查找后发现在Centos7中iptab ...
- Ubuntu使用iptables配置防火墙提示:unrecognized service(Ubuntu配置iptables防火墙)
Ubuntu默认安装是没有开启任何防火墙的. 当使用service iptables status时发现提示iptables:unrecoginzed service.意思是无法识别的服务. 以下方法 ...
- CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
firewall:systemctl start firewalld.service#启动firewallsystemctl stop firewalld.service#停止firewallsyst ...
- CentOS 7.0关闭默认firewall防火墙启用iptables防火墙
操作系统环境:CentOS Linux release 7.0.1406(Core) 64位CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤. 1.关闭f ...
- Linux学习之八--关闭firewall防火墙安装iptables并配置
CentOS 7之后默认使用的是firewall作为防火墙,这里改为iptables防火墙,并开启80端口.3306端口. 1.关闭firewall: systemctl stop firewalld ...
- CentOS 7.0,启用iptables防火墙
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止fir ...
- centos7 关闭firewall安装iptables并配置
一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...
随机推荐
- ubuntu下手动配置apache2.4.12
(apache2也可以使用 sudo apt-get install apache2来安装,下面来讲解下如何手动安装配置apache2) 在安装apache2之前,先要安装apache2的依赖项,ap ...
- 【3】数据筛选3 - BeautifulSoup4
#目录 1. 开发前准备 2. 不同解析器对比 3. BeautifulSoup4 初始化和节点对象的认识 4. BS4 案例操作:初始化对象文档 5. 节点查 ...
- 离职 mark
昨天(2019 年 5 月 17 日),从 离职. 从 2018 年 7 月 14 日早 10 点余分到 2019 年 5 月 17 日早 10 点余分,一共 308 天整.这就是我出学校的第一份工作 ...
- Spring security 5 Authorize Configuration
1. Spring Security 核心请求,认证配置类 WebSecurityConfigurerAdapter protected void configure(HttpSecurity htt ...
- 常量Constant
常量通常指的是一个固定的值,例如:1.2.3.’a’.’b’.true.false.”helloWorld”等. 在Java语言中,主要是利用关键字final来定义一个常量. 常量一旦被初始化后不能再 ...
- 设置idea快速生成doc comment
在eclipse中快速生成方法的doc comment快捷键是Alt+Shift+J, 而在idea中没有对应的快捷键,但是能实现相似的功能. 1.在方法上面输入/** 然后回车就可以生成注释了. 2 ...
- 【01】bootstrap基本信息
[01]基本信息 中文官网:http://www.bootcss.com/ 英文官网:https://github.com/twbs/bootstrap/ 支持IE8+ CND : htt ...
- https://segmentfault.com/a/1190000012844836---------关于SpringBoot上传图片的几种方式
关于SpringBoot上传图片的几种方式 https://segmentfault.com/a/1190000012844836
- [codeVS1404] 字符串匹配
时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 给你两个串A,B,可以得到从A的任意位开始的子串和B匹配的长度. ...
- BZOJ(6) 1084: [SCOI2005]最大子矩阵
1084: [SCOI2005]最大子矩阵 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3566 Solved: 1785[Submit][Sta ...