<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Firewall on Evan Hoffman</title><link>https://evan.wtf/tags/firewall/</link><description>Recent content in Firewall on Evan Hoffman</description><generator>Hugo</generator><language>en-US</language><copyright>Evan Hoffman</copyright><lastBuildDate>Mon, 11 May 2009 16:39:22 +0000</lastBuildDate><atom:link href="https://evan.wtf/tags/firewall/index.xml" rel="self" type="application/rss+xml"/><item><title>iptables rules for rate-limiting SSH connections</title><link>https://evan.wtf/2009/05/11/iptables-rules-for-rate-limiting-ssh-connections/</link><pubDate>Mon, 11 May 2009 16:39:22 +0000</pubDate><guid>https://evan.wtf/2009/05/11/iptables-rules-for-rate-limiting-ssh-connections/</guid><description>&lt;p&gt;This is what I use on my CentOS boxes/VMs, it rate-limits the connections and also rate-limits the log messages (to prevent attacks that attempt to fill up the server&amp;rsquo;s disk).&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;iptables -F iptables -X iptables -N LOGDROP #Create the LOGDROP chain iptables -A LOGDROP -m limit --limit 1/s -j LOG --log-prefix &amp;quot;LOGDROP: &amp;quot; # Rate-limit the logging so the logs don't fill up the server iptables -A LOGDROP -j DROP iptables -I INPUT -p tcp --dport 22 -s 10.0.0.0/16 -j ACCEPT # Allow everything from the internal network iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set # create the &amp;quot;bucket&amp;quot; iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j LOGDROP # if there are more than 4 connection attempts in 60 seconds from a given address, log-drop it.&lt;/code&gt;&lt;/p&gt;</description></item></channel></rss>