centos7下部署iptables环境纪录(关闭默认的firewalle)

技术颜良 技术颜良     2022-10-07     422

关键词:

 

CentOS7默认的防火墙不是iptables,而是firewall.
由于习惯了用iptables作为防火墙,所以在安装好centos7系统后,会将默认的firewall关闭,并另安装iptables进行防火墙规则设定

下面介绍centos7关闭firewall安装iptables,并且开启80端口、3306端口的操作记录:
[[email protected] ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

1、关闭firewall:

1
2
[[email protected] ~]# systemctl stop firewalld.service            //停止firewall
[[email protected] ~]# systemctl disable firewalld.service        //禁止firewall开机启动

2、安装iptables防火墙

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[[email protected] ~]# yum install iptables-services            //安装
[[email protected] ~]# vim /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 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
 
[[email protected] ~]# systemctl restart iptables.service                  //最后重启防火墙使配置生效
[[email protected] ~]# systemctl enable iptables.service                  //设置防火墙开机启动
 
[[email protected] ~]# iptables -L                 //查看防火墙规则,默认的是-t filter,如果是nat表查看,即iptables -t nat -L

二、关闭SELINUX

1
2
3
4
5
6
7
[[email protected] ~]# vim /etc/selinux/config
#SELINUX=enforcing           //注释掉
#SELINUXTYPE=targeted           //注释掉
SELINUX=disabled              //增加
 
 
[[email protected] ~]# setenforce 0       //使配置立即生效

linux下搭建wordpress个人站点

WordPress是基于在LAMP环境下搭建。这里用的是CentOS7wordpress对php和mysql有版本要求。wordpress版本4.7.4的数据库mariadb-5.5.52,php-5.4.16LAMP:Linux+Apache+Mysql(MariaDB)+PHP的组合。在环境部署前需要把iptables和selinux关闭,否则你配置好之后发现会... 查看详情

centos7.0如何关闭默认防火墙开启iptables?~

操作系统环境:CentOSLinuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld.service#禁止firewall开机启动firewall- 查看详情

centos7.0关闭默认防火墙启用iptables防火墙

CentOS7.0关闭默认防火墙启用iptables防火墙http://www.linuxidc.com/Linux/2015-05/117473.htm操作系统环境:CentOS Linuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfi 查看详情

centos7防火墙关闭和启用iptables防火墙

操作系统环境:CentOS Linuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld.service#禁止firewall开机启动fir 查看详情

centos7.0关闭默认防火墙启用iptables防火墙

操作系统环境:CentOS Linuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld.service#禁止firewall开机启动fir 查看详情

centos7配置iptables规则(代码片段)

...对流入、流出、流经服务的数据包进行精细的控制,而在centos7中将iptables给取消掉了,我们需要自行安装,下面介绍iptables的安装及使用。    一、安装iptables    1、查看iptables是否安装      命令:systemctlstatusip... 查看详情

centos7.0关闭默认防火墙启用iptables防火墙

本文从http://www.linuxidc.com/Linux/2015-05/117473.htm转载 操作系统环境:CentOSLinuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfirewalld.service#停止firewa 查看详情

centos7.0关闭默认防火墙启用iptables防火墙

http://www.linuxidc.com/Linux/2015-05/117473.htm  操作系统环境:CentOS Linuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfirewalld.service#停 查看详情

centos7.0关闭默认防火墙启用iptables防火墙

源地址:http://www.linuxidc.com/Linux/2015-05/117473.htm操作系统环境:CentOS Linuxrelease7.0.1406(Core)64位CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。1、关闭firewall:systemctlstopfirewalld.service#停止firewal 查看详情

centos7下安装部署zabbix3.4

Zabbix安装:环境:系统环境:CentOS7Zabbix版本:Zabbix3.4安装步骤:关闭防火墙和SELINUXsystemctlstopfirewalld&&setenforce0安装zabbix相关软件包rpm-ivhhttps://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4 查看详情

centos7下openldap统一认证的主从环境部署记录

...centos6.x系统上是通过slapd.conf配置部署OpenLDAP主从环境的,centos7上默认是动态部署的,通过yum安装发现无slapd.conf文件。下面记录下Centos7.4系统下OpenLDAP主从环境配置记录:1)服务器基本信息192.168.10.213openldap-master192.168.10.214open 查看详情

超详细部署kubernetes教程

Kubeadm部署k8s单点master1、环境准备:主机名IP说明宿主机系统master10.0.0.17Kubernetes集群的master节点CentOS7.9node110.0.0.27Kubernetes集群的node节点CentOS7.9#所有master和node节点执行:#关闭防火墙、iptables和selinuxsystemctlstopfirewalld&& 查看详情

centos7下yum安装zabbix的部署(代码片段)

一.环境准备OS:CentOS7.264bitZabbix版本:3.0.12MySQL版本:5.6hostnameip主机用途zabbix-server10.0.0.44服务端zabbix-agent10.0.0.45代理端1.关闭防火墙2.关闭selinux3.服务端安装zabbix-server#下载zabbix的rpm仓库包rpm-vhihttp://repo.zabbix.com/zabb 查看详情

centos7安装lamp环境

一、配置防火墙,开启80端口、3306端口CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。1、关闭firewall:systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld.service#禁止firewall开机启动2、安装iptables防火墙yuminstalli... 查看详情

centos7使用kubeadm部署k8s(单机/集群)(代码片段)

一、环境准备1.初始化环境关闭防火墙systemctlstopfirewalld&&systemctldisablefirewalld关闭swapswapoff-a&&sed-i'/swap/s/^\\(.*\\)$/#\\1/g'/etc/fstab关闭selinuxsetenforce0&&sed-i's/^SELINUX=.*/SELINUX=disabled/'/etc/selinux/config时间... 查看详情

devstack部署(代码片段)

...内存过小,会出现各种问题。(整个devstack-Openstack-Ocata+CentOS7.31611需要占用3.4G内存)OSCentOS7.31611NET建议创建两个网络,一个用于连接外网用于做管理性工作;一个供neutron使用OpenStack版本Ocata部署准备关闭防火墙关闭selinux编辑/etc/... 查看详情

centos7.2安装部署ceph及添加pg

前期准备:准备三台CentOS7.2系统,每台机器三块硬盘,关闭selinux,关闭iptables,做好时间同步,做好本地域名解析,并对每台机器做互信。192.168.10.101ceph-node1192.168.10.22ceph-node2192.168.10.33ceph-node3每台机器上有三个osd,整个集群共九... 查看详情

centos7关闭firewalld开启iptables

1:关闭系统高级防火墙firewalld systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld.service#禁止firewall开机启动  2:编辑iptables配置文件vi/etc/sysconfig/iptables必备iptables-IINPUT-ptcp--dport22-jACCEPTipt 查看详情