<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[centos7防火墙firewalld拒绝某ip或者某ip段访问服务器任何服务]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[服务器技术]]></category>
<pubDate>Fri, 09 Jul 2021 07:30:14 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	安装firewall后（LINUX7系统一般情况下默认已安装），防火墙默认配置是只打开SSH端口的，也就是22端口，<br/>如果SSH的端口已更改成别的端口了，请切记一定在启动firewall前先修改对应服务策略中SSH的端口为你的SSH端口，<br/>文件路径：/usr/lib/firewalld/services/ssh.xml 把22改成你的远程端口号，然后再启动firewall防火墙，<br/>如果防火墙已经启动，你再想更改自己的SSH端口号，那么请先把自己要修改SSH端口号，先添加进防火墙放行端口中，否则修改SSH端口后就会导致你的SSH远程登录不上，<br/>另外启动防火墙后如果更改配置文件，请一定运行重新加载配置文件（firewall-cmd –reload）命令，<br/><div class="code"><br/>firewall-cmd –reload<br/></div><br/><br/>重新加载配置文件；<br/><div class="code"><br/>#查看firewall状态，LINUX7默认是安装并开启的；<br/>firewall-cmd --state<br/>#安装<br/>yum install firewalld<br/>#启动,<br/>systemctl start firewalld <br/>#设置开机启动<br/>systemctl enable firewalld<br/>#关闭<br/>systemctl stop firewalld<br/>#取消开机启动<br/>systemctl disable firewalld<br/>#禁止IP(123.56.161.140)访问机器<br/>firewall-cmd --permanent --add-rich-rule=&#039;rule family=ipv4 source address=&quot;123.56.161.140&quot; drop&#039;<br/>#禁止一个IP段，比如禁止123.56.*.*<br/>firewall-cmd --permanent --add-rich-rule=&#039;rule family=ipv4 source address=&quot;123.56.0.0/16&quot; drop&#039;<br/>#禁止一个IP段，比如禁止123.56.161.*<br/>firewall-cmd --permanent --add-rich-rule=&#039;rule family=ipv4 source address=&quot;123.56.161.0/24&quot; drop&#039;<br/>#禁止机器IP(123.56.161.140)从防火墙中删除<br/>firewall-cmd --permanent --remove-rich-rule=&#039;rule family=ipv4 source address=&quot;123.56.161.140&quot; drop&#039;<br/>#允许http服务(对应服务策略目录：/usr/lib/firewalld/services/)<br/>firewall-cmd --permanent --add-service=http<br/>#关闭http服务(对应服务策略目录：/usr/lib/firewalld/services/)<br/>firewall-cmd --permanent --remove-service=http<br/>#允许端口:3389<br/>firewall-cmd --permanent --add-port=3389/tcp<br/>#允许端口:1-3389<br/>firewall-cmd --permanent --add-port=1-3389/tcp<br/>#关闭放行中端口:3389<br/>firewall-cmd --permanent --remove-port=3389/tcp<br/>#查看firewall的状态<br/>firewall-cmd --state&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>#查看防火墙规则（只显示/etc/firewalld/zones/public.xml中防火墙策略，在配置策略前，我一般喜欢先CP，以后方便直接还原）<br/>firewall-cmd --list-all <br/>#查看所有的防火墙策略（即显示/etc/firewalld/zones/下的所有策略）<br/>firewall-cmd --list-all-zones <br/>#重新加载配置文件<br/>firewall-cmd --reload<br/>#更改配置后一定要重新加载配置文件：<br/>firewall-cmd --reload<br/></div>
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] centos7防火墙firewalld拒绝某ip或者某ip段访问服务器任何服务]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>