<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Ops运维 | Mr`kang Blog｜小豆子]]></title> 
<link>https://www.cnmysql.com/index.php</link> 
<description><![CDATA[关注服务器运维技术、DB优化、Docker虚拟化、自动化运维、工作积累]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Ops运维 | Mr`kang Blog｜小豆子]]></copyright>
<item>
<link>https://www.cnmysql.com/post//</link>
<title><![CDATA[ iptables 屏蔽IP]]></title> 
<author>kangyang &lt;kangyang315@qq.com&gt;</author>
<category><![CDATA[黑客攻防]]></category>
<pubDate>Mon, 15 Sep 2014 06:50:22 +0000</pubDate> 
<guid>https://www.cnmysql.com/post//</guid> 
<description>
<![CDATA[ 
	<span style="font-family: 宋体;"><span style="font-size: 12px;"><br/> IPdeny 下载以国家代码编制好的 IP 地址列表，比如下载 cn.zone：<br/>有了国家的所有 IP 地址，要想屏蔽这些 IP 就很容易了，直接写个脚本逐行读取 cn.zone 文件并加入到 iptables 中：<br/><div class="code"><br/>#!/bin/bash<br/># Block traffic from a specific country<br/># written by vpsee.com<br/><br/>COUNTRY=&quot;cn&quot;<br/>IPTABLES=/sbin/iptables<br/>EGREP=/bin/egrep<br/><br/>if &#91; &quot;$(id -u)&quot; != &quot;0&quot; &#93;; then<br/>&nbsp;&nbsp; echo &quot;you must be root&quot; 1&gt;&amp;2<br/>&nbsp;&nbsp; exit 1<br/>fi<br/><br/>resetrules() &#123;<br/>$IPTABLES -F<br/>$IPTABLES -t nat -F<br/>$IPTABLES -t mangle -F<br/>$IPTABLES -X<br/>&#125;<br/><br/>resetrules<br/><br/>for c in $COUNTRY<br/>do<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;country_file=$c.zone<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IPS=$($EGREP -v &quot;^#&#124;^$&quot; $country_file)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for ip in $IPS<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;blocking $ip&quot;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $IPTABLES -A INPUT -s $ip -j DROP<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;done<br/>done<br/><br/>exit 0<br/></div><br/><br/>以上脚本可以延伸成防ddos攻击！<br/><br/></span><br/></span><br/>Tags - <a href="https://www.cnmysql.com/tags/ddos/" rel="tag">ddos</a> , <a href="https://www.cnmysql.com/tags/iptables/" rel="tag">iptables</a>
]]>
</description>
</item><item>
<link>https://www.cnmysql.com/post//#blogcomment</link>
<title><![CDATA[[评论]  iptables 屏蔽IP]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.cnmysql.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>