禁用清单多久更新一次 (禁用 - CentOS7装置iptables防火墙)

文章编号:8115 更新时间:2024-02-18 分类:互联网资讯 阅读次数:

资讯内容

如何装置iptables防火墙?本篇文章重要引见了centos7.置iptables防火墙的方法,小编感觉挺不错的,如今分享给大家,也给大家做个参考。不只要装置防火墙的命令和说明,还有如何禁用/中止自带的服务,起追随小编上来看看吧

禁用清单多久更新一次禁用CentOS7装

1,CentOS7 自动的防火墙 不是iptables, 而是firewalle.

2,一些软件的端口号要开放来提供服务,如:22,80等罕用端口

3,提供web服务的须要

一、装置centos7,自行百度或许购置阿里云腾讯云易探云等云主机,选用centos7即可!

二、centos7 基本色能

三、CentOS7装置iptables防火墙:

0,CentOS7自动的防火墙不是iptables,而是firewalle.

检查: 关上/etc/sysconfig/目录后,并未发现iptables文档(或许会有iptables-config文档等,别混杂了)

[root@localhost ~]# cd /etc/sysconfig/

1, 装置 iptable 与 iptable-service

#先审核能否装置了iptables

[root@localhost ~]# service iptables status

#装置iptables

[root@localhost ~]# yum install -y iptables #理论状况下是装置好了的

yum install -y iptables* (网友介绍,看上方的评论,在这里,谢谢他/她)

#更新iptables

[root@localhost ~]# yum update iptables

#装置iptables-services

[root@localhost ~]# yum install iptables-services #理论状况下没有装置

2,禁用/中止自带的firewalld服务

#中止firewalld服务

[root@localhost ~]# systemctl stop firewalld

#禁用firewalld服务

[root@localhost ~]# systemctl mask firewalld

#检查iptables现有规定

[root@localhost ~]# iptables -L -n

#先准许一切,不然有或许会杯具

[root@localhost ~]# iptables -P INPUT ACCEPT

[root@localhost ~]# systemctl enable iptables.service # 设置防火墙开机启动

——————— 启动/封锁/重启 iptables ————————————

[root@localhost ~]# systemctl stop iptables

[root@localhost ~]# systemctl start iptables

[root@localhost ~]# systemctl restart iptables

# @1,手动减少端口号 (方法一)

[root@localhost ~]# vi /etc/sysconfig/iptables #性能防火墙端口

-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT-A INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT-A INPUT -m state –state NEW -m tcp -p tcp –dport 6379 -j ACCEPT

[root@localhost ~]# service iptables save #保留防火墙性能

################################### 详细性能说明 ######################################

@ 2,命令 减少端口号 ( 方法二 ):

参考:https://www.linuxidc.com/Linux/2017-10/147238.htm

一、装置iptable iptable-service

1,先审核能否装置了iptables

[root@localhost ~]# service iptables status

2,装置iptables

[root@localhost ~]# yum install -y iptables

3,更新iptables

[root@localhost ~]# yum update iptables

4,装置iptables-services

[root@localhost ~]# yum install iptables-services

二、禁用/中止自带的firewalld服务

1,中止firewalld服务

[root@localhost ~]# systemctl stop firewalld

2,禁用firewalld服务

[root@localhost ~]# systemctl mask firewalld

三、设置现有规定

#检查iptables现有规定 [root@localhost ~]# iptables -L -n #先准许一切,不然有或许会杯具 [root@localhost ~]# iptables -P INPUT ACCEPT #清空一切自动规定 [root@localhost ~]# iptables -F #清空一切自定义规定 [root@localhost ~]# iptables -X #一切计数器归0 [root@localhost ~]# iptables -Z #准许来自于lo接口的数据包(本地访问) [root@localhost ~]# 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 … ====> 按如实践要求:能否加上方的: ——————————————————————- #准许ping iptables -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

五、保留规定设定

#保留上述规定service iptables save

六、开启iptables服务

#注册iptables服务#相当于以前的chkconfig iptables onsystemctl enable iptables.service#开启服务systemctl start iptables.service#检查形态systemctl status iptables.service

疑问:处置vsftpd在iptables开启后,不可经常使用主动形式的疑问

1.首先在/etc/sysconfig/iptables-config中修正或许减少以下内容

#减少以下内容,留意顺序不能互换 IPTABLES_MODULES=”ip_conntrack_ftp” IPTABLES_MODULES=”ip_nat_ftp”

2.从新设置iptables设置

iptables -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT

以下为完整设置脚本

#!/bin/shiptables -P INPUT ACCEPTiptables -Fiptables -Xiptables -Ziptables -A INPUT -i lo -j ACCEPTiptables -A INPUT -p tcp –dport 22 -j ACCEPTiptables -A INPUT -p tcp –dport 21 -j ACCEPTiptables -A INPUT -p tcp –dport 80 -j ACCEPTiptables -A INPUT -p tcp –dport 443 -j ACCEPTiptables -A INPUT -p icmp –icmp-type 8 -j ACCEPTiptables -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPTiptables -P INPUT DROPiptables -P OUTPUT ACCEPTiptables -P FORWARD DROPservice iptables savesystemctl restart iptables.service

[root@localhost ~]# cat /etc/redhat-release # 检查centos版本

CentOS Linux release 7.2.1511 (Core)

1.封锁firewall

[root@localhost ~]# systemctl stop firewalld.service # 中止firewall

[root@localhost ~]# systemctl disable firewalld.service # 制止firewall开机启动

2.装置iptables

[root@localhost ~]# yum install iptables-services # 装置

[root@localhost ~]# systemctl restart iptables.service # 重启防火墙使性能失效

[root@localhost ~]# systemctl enable iptables.service # 设置防火墙开机启动

[root@localhost ~]# systemctl disable iptables.service # 制止防火墙开机启动

[root@localhost ~]# service iptable status –检查防火墙形态

[root@localhost ~]# servcie iptables stop –暂时封锁防火墙

[root@localhost ~]# service iptables start –暂时启动防火墙

[root@localhost ~]# service iptables restart –重启防火墙

[root@localhost ~]# chkconfig iptables off –终身封锁防火墙

[root@localhost ~]# chkconfig iptables on –终身开启防火墙

介绍阅读:

标签: centos7firewalldiptables防火墙iptables

本文地址: https://yihaiquanyi.com/article/519c126b11f8c54f4fff.html

上一篇:移动光猫乔接移动光猫衔接路由器视频教学...
下一篇:美国高防cera机房美国高防主机对DDoS攻打的...

发表评论