安装firewall后(LINUX7系统一般情况下默认已安装),防火墙默认配置是只打开SSH端口的,也就是22端口,
如果SSH的端口已更改成别的端口了,请切记一定在启动firewall前先修改对应服务策略中SSH的端口为你的SSH端口,
文件路径:/usr/lib/firewalld/services/ssh.xml 把22改成你的远程端口号,然后再启动firewall防火墙,
如果防火墙已经启动,你再想更改自己的SSH端口号,那么请先把自己要修改SSH端口号,先添加进防火墙放行端口中,否则修改SSH端口后就会导致你的SSH远程登录不上,
另外启动防火墙后如果更改配置文件,请一定运行重新加载配置文件(firewall-cmd –reload)命令,

firewall-cmd –reload

重新加载配置文件;

#查看firewall状态,LINUX7默认是安装并开启的;
firewall-cmd --state
#安装
yum install firewalld
#启动,
systemctl start firewalld
#设置开机启动
systemctl enable firewalld
#关闭
systemctl stop firewalld
#取消开机启动
systemctl disable firewalld
#禁止IP(123.56.161.140)访问机器
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="123.56.161.140" drop'
#禁止一个IP段,比如禁止123.56.*.*
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="123.56.0.0/16" drop'
#禁止一个IP段,比如禁止123.56.161.*
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="123.56.161.0/24" drop'
#禁止机器IP(123.56.161.140)从防火墙中删除
firewall-cmd --permanent --remove-rich-rule='rule family=ipv4 source address="123.56.161.140" drop'
#允许http服务(对应服务策略目录:/usr/lib/firewalld/services/)
firewall-cmd --permanent --add-service=http
#关闭http服务(对应服务策略目录:/usr/lib/firewalld/services/)
firewall-cmd --permanent --remove-service=http
#允许端口:3389
firewall-cmd --permanent --add-port=3389/tcp
#允许端口:1-3389
firewall-cmd --permanent --add-port=1-3389/tcp
#关闭放行中端口:3389
firewall-cmd --permanent --remove-port=3389/tcp
#查看firewall的状态
firewall-cmd --state
#查看防火墙规则(只显示/etc/firewalld/zones/public.xml中防火墙策略,在配置策略前,我一般喜欢先CP,以后方便直接还原)
firewall-cmd --list-all
#查看所有的防火墙策略(即显示/etc/firewalld/zones/下的所有策略)
firewall-cmd --list-all-zones
#重新加载配置文件
firewall-cmd --reload
#更改配置后一定要重新加载配置文件:
firewall-cmd --reload

centos7防火墙firewalld拒绝某ip或者某ip段访问服务器任何服务的更多相关文章

  1. fedora/centos7防火墙FirewallD详解

    1 使用 FirewallD 构建动态防火墙 1.1 “守护进程” 1.2 静态防火墙(system-config-firewall/lokkit) 1.3 使用 iptables 和 ip6tabl ...

  2. CentOS7防火墙firewalld 和 CentOS6防火墙iptables的一些配置命令

    CentOS7 防火墙 一.防火墙的开启.关闭.禁用.查看状态命令 (1)启动防火墙:systemctl start firewalld (2)关闭防火墙:systemctl stop firewal ...

  3. Centos7 防火墙 firewalld 实用操作

    一.前言 Centos7以上的发行版都试自带了firewalld防火墙的,firewalld去带了iptables防火墙.其原因是iptables的防火墙策略是交由内核层面的netfilter网络过滤 ...

  4. CentOS7防火墙firewalld使用

    1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status f ...

  5. 5分钟理解Centos7防火墙firewalld

    版权声明:本内容为原创内容,转载请声明出处. 原文地址:http://www.excelib.com/article/287/show firewalld简介 Centos7中默认将原来的防火墙ipt ...

  6. CentOS7 防火墙firewalld详细操作

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disab ...

  7. CentOS7防火墙firewalld

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disab ...

  8. Centos7 防火墙firewalld配置

    开启80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent  出现success表明添加成功 移除某个端口 firewall-cmd ...

  9. CentOS7防火墙firewalld设置

    添加80端口  重启后永久生效 firewall-cmd --zone=public --add-port=80/tcp --permanent   查看防火墙状态 systemctl status ...

随机推荐

  1. C#获取时间戳的几种方式

    Console.WriteLine(Convert.ToDouble(DateTime.UtcNow.Ticks - 621355968000000000) / (10 * 1000 * 1000)) ...

  2. sql 查询条件为拼接字符串 不能使用IN 使用patindex查询结果集

    题目: 求组织机构ID在('5dc8de20-9f2f-465e-afcc-f69abecaee50','63549b63-1e0d-4269-98f4-013869d7f211','f7316bf3 ...

  3. 5.装饰模式 Decorator (单一职责)

    结合: Android设计模式 006 装饰者模式  [B站]对整个重构的细节讲的容易懂 Android的设计模式-装饰者模式   [简书]结合安卓源码讲的还可以,让我对context有更深入的理解 ...

  4. 两千星 .NET5 框架 Furion 亮点分析(一)

    让 .NET 开发更简单,更通用,更流行. Furion 介绍 Furion 是基于 .NET5 平台下打造的现代化 Web 框架.旨在 让 .NET 开发更简单,更通用,更流行.. Furion 非 ...

  5. [leetcode]222. Count Complete Tree Nodes完全二叉树的节点数

    /* 满二叉树的特点是2^n-1,对于完全二叉树,一个node如果左右子树深度相同,那么 是一个满二叉树.如果不是,那就把node算上,继续往下看,下边的可能是满二叉树 由于完全二叉树中有一些子满二叉 ...

  6. Mac如何下载软件

    1.App Store  2.软件官网   3.Mac软件网站  4.搜狗微信 个人首选App Store,里面的软件安全可靠,其次就是官网,必不得已才去其他网站下载,毕竟不是App Store或官网 ...

  7. Java学习日报7.17

    控制台运行

  8. 求你别再用swagger了,给你推荐几个在线文档生成神器

    前言 最近公司打算做一个openapi开放平台,让我找一款好用的在线文档生成工具,具体要求如下: 必须是开源的 能够实时生成在线文档 支持全文搜索 支持在线调试功能 界面优美 说实话,这个需求看起来简 ...

  9. CMS、G1收集器

    目录 CMS.G1收集器 1.CMS收集器 1.1.原理 1.2.不足 2.G1收集器 2.1.特点 2.2.执行过程 CMS.G1收集器 1.CMS收集器 CMS(Concurrent Mark S ...

  10. linux based bottlerocket-os

    linux based bottlerocket-os 概要 aws开源,专注与运行容器的linux os 参看 https://github.com/bottlerocket-os