CentOS7安装iptables防火墙

CentOS下防火墙配置指南 通过配置适当的防火墙规则,可以提高服务器的安全性,保护计算机网络免受未经授权的访问。在CentOS操作系统下,iptables是一个常用的防火墙工具,它允许我们配置和管理网络流量。SSH默认使用22号端口。在配置防火墙之前,我们可以先查看当前的防火墙规则。该命令将显示当前的防火墙规则,包括输入、输出和转发规则。该命令将当前的防火墙规则保存到/etc/sysconfig/iptables文件中。该命令将启动iptables服务,并加载之前保存的防火墙规则。该命令将清空所有的防火墙规则,恢复到默认状态。 阅读详情
CentOS7默认的防火墙不是iptables,而是firewalle.


安装iptable iptable-service



#先检查是否安装了iptables

service iptables status


#安装iptables

yum install -y iptables


#升级iptables

yum update iptables 


#安装iptables-services
yum install iptables-services


禁用/停止自带的firewalld服务


#停止firewalld服务

systemctl stop firewalld


#禁用firewalld服务

systemctl mask firewalld


设置现有规则


#查看iptables现有规则

iptables -L -n


#先允许所有,不然有可能会杯具

iptables -P INPUT ACCEPT


#清空所有默认规则

iptables -F


#清空所有自定义规则

iptables -X


#所有计数器归0

iptables -Z


#允许来自于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


#允许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 on

systemctl 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/bash
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
service iptables save

systemctl restart iptables.service


SNAP新手避坑指南:手把手教你搞定Sentinel-2影像的镶嵌与重采样(附详细参数) 本文为SNAP新手提供Sentinel-2影像处理的详细指南,重点讲解镶嵌与重采样的关键步骤和参数设置。通过实际案例和常见问题解决方案,帮助用户避免常见错误,高效完成遥感影像处理任务。 阅读详情

相关推荐

别再只盯着轨迹线了!FLUENT DPM后处理实战:从粒子采样到直方图报告的完整流程

本文详细介绍了FLUENT DPM后处理的完整流程,从粒子采样到直方图报告的实战技巧。通过设置采样面、分析.dpm文件数据以及创建加权直方图,帮助工程师获取粒子速度、粒径分布等定量信息,提升多相流模拟的深度分析能力。特别适合需要超越轨迹线分析的CFD工程师。

weixin_28730353的博客 283

Centos7配置firewalld防火墙规则

linux ,Centos ,防火墙

紫水木鱼的博客 2794

【python】epub的电子书繁体字与简体字转换

中文繁体与简体转换

xiexianyou666的博客 3093

Centos7防火墙iptables安装及设置图文并茂【实现防火墙管理功能】

一、安装iptables Centos7系统默认是使用firewall作为防火墙,为了更好兼容老的系统配置,将防火墙设置为iptables(用原来centos6.5的配置即可直接用)。 查看firewall防火墙状态:systemctl status firewalld 关闭防火墙 关闭firewall防火墙: systemctl stop firewalld 3. 关闭防火墙开机自启动 关闭开机自启动: systemctl disable firewalld 兄弟们我这里重启系统(reb

土豆是狗的博客 8504

麒麟V10 SP3国产化环境部署MySQL 8.0全流程实战

本文详细介绍了在国产化操作系统麒麟V10 SP3上部署MySQL 8.0的全流程实战指南。从环境准备、冲突排查到安装包处理、服务配置与安全加固,提供了详细的命令和技巧,帮助用户顺利完成MySQL 8.0的部署与优化,适用于国产化环境下的数据库应用。

weixin_29231027的博客 274

Deepface实战避坑:人脸识别模型VGG-Face、Facenet、ArcFace怎么选?附各模型性能与速度实测对比

本文深入对比了DeepFace框架中VGG-Face、Facenet和ArcFace三种主流人脸识别模型的性能与适用场景,提供了详细的实测数据和选型建议。通过分析各模型在CPU/GPU环境下的推理速度、内存占用和准确率表现,帮助开发者根据实际需求(如门禁系统、相册分类或视频流分析)选择最优模型,并给出工程化部署的避坑指南和优化技巧。

weixin_42625070的博客 305

CentOS 安装 iptables 防火墙

CentOS 安装 iptables 防火墙 CentOS 默认使用的是 firewall 作为防火墙,这里改为iptables防火墙。 一、关闭删除 firewall systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #取消firewall开机启动 二、安装 iptables # 一键安装 iptables yum install iptables-services -y # 设置防火墙开

nukix 2272

Android实现TextToSpeech控件实现语音播报--朗读文字 (附完整源码)

Android实现TextToSpeech控件实现语音播报--朗读文字 (附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 1129

CentOS7 安装iptables防火墙和配置

文章目录一)、关闭,禁用系统默认的firewall防火墙二)、安装iptables防火墙1)、先检查是否安装了iptables2)、安装iptables3)、升级iptables4)、安装iptables-services5)、编辑防火墙文件6)、重启防火墙使配置文件生效7)、设置iptables防火墙为开机自启 centos7默认是使用firewalld作为防火墙 查看iptables防火墙现有...

IceStreamLab 1616

基于最小二乘法(LS)和最小均方误差(MMSE)算法的导频信道估计

导频信道估计在无线通信系统中起着至关重要的作用,它用于估计无线信道的特性,以便在接收端进行正确的信号解调和解码。最小二乘法(LS)和最小均方误差(MMSE)是两种常用的导频信道估计算法,它们在估计精度和计算复杂度之间取得了良好的平衡。首先,我们提取当前的导频符号,然后将接收到的信号与导频符号相乘得到接收导频信号。最小二乘法是一种经典的导频信道估计算法,它通过最小化接收信号与预测信号之间的均方误差来估计信道。下面将详细介绍基于LS和MMSE算法的导频信道估计,并提供相应的MATLAB代码实现。

pytorchCode的博客 689

29、5G PUCCH格式及资源配置详解

本文详细解析了5G通信系统中的物理上行控制信道(PUCCH)的不同格式及其资源配置方案。PUCCH负责传输上行控制信息(UCI),包括混合自动重传请求(HARQ)确认信息、调度请求(SR)和信道状态信息(CSI)等。文章从PUCCH的基本概念出发,深入分析了格式0到格式4的特点、编码调制方式、干扰随机化机制以及适用场景,并探讨了PUCCH资源集的配置方法和上行控制信令在PUSCH上的传输机制。通过对比不同格式的传输能力、干扰随机化方式和频率跳变能力,为读者提供了选择合适PUCCH格式的决策依据。最后,文章总

oil88的博客 253

CentOS之——CentOS7安装iptables防火墙

CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptable iptable-service #先检查是否安装了iptables service iptables status #安装iptables yum install -y iptables #升级iptables yum update iptables #安装iptables-services yum

冰河的专栏 4万+

OpenCv —— 检测车牌号(附完整源码)

OpenCv —— 检测车牌号

5601

centOS7安装iptables防火墙

centOS7安装iptables防火墙 注意:centOS7默认自带的防火墙为firewall防火墙,需先停用firewall防火墙 1、关闭firewall: firewall-cmd --state 【#查看firewall防火墙状态】 systemctl stop firewalld.service 【#停止firewall】 systemctl disable fir...

qq_44718431的博客 279

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

CentOS 7.5上安装iptables防火墙

CentOS 7.x版本已没有了iptables防火墙了,默认自带的是firewalle,但用哪个好呢?个人觉得,用你自己能够把控得住的。 ## 安装iptables软件 [root@master ~]# yum install iptables iptables-service -y #安装iptables软件 [root@master ~]# systemctl st...

dggwtsab530713的博客 1037

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Linux——CentOS 7 安装iptables防火墙

CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptableiptable-service #先检查是否安装了iptables service iptables status #安装iptables yum install -y iptables #升级iptables yum update iptables #安装iptables-services yu...

Hern(宋兆恒) 1086

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

linux yum安装iptables,CentOS7安装和配置iptables防火墙

从CentOS7(RHEL7)开始,官方的标准防火墙设置软件从iptables变更为firewalld。需禁用自带的firewalld服务,同时安装iptables服务。在使用Docker时,启用centos7默认的firewall,启动端口映射时,防火墙规则不生效。docker默认使用了iptables防火墙机制。所以需要关闭firewall使用iptables解决。1.关闭默认的firewal...

weixin_30068877的博客 2828

CentOS7安装iptables防火墙的方法

CentOS7默认的防火墙不是iptables,而是firewalle.iptables规则    书写规则的语法格式为:    iptables [-t table] command  chains [creteria]  -j  action    -t table就是表名,filter/nat/mangle三个表中的一个,默认是filter表    command告诉程序如何做,比如:插入一...

qq_42033352的博客 266
上一篇: zookeeper集群的搭建
下一篇: Java设计模式(一):单例模式,防止反射和反序列化漏洞
Lena-Yang
博客等级 码龄20年 164粉丝 67原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值