{"id":1171,"date":"2017-11-08T18:29:56","date_gmt":"2017-11-08T13:29:56","guid":{"rendered":"http:\/\/alexeyka.zantsev.com\/?p=1171"},"modified":"2017-11-08T18:37:22","modified_gmt":"2017-11-08T13:37:22","slug":"openbsd-pf-limit-incoming-connections-per-time-period","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=1171","title":{"rendered":"OpenBSD PF: limit incoming connections per time period"},"content":{"rendered":"<p>In iptables there is a nice module called <a href=\"http:\/\/ipset.netfilter.org\/iptables-extensions.man.html#lbAY\" rel=\"noopener\" target=\"_blank\">hashlimit<\/a>.<\/p>\n<p>Being in love with OpenBSD and PF, I decided to find if this wonderful firewall has the same feature.<\/p>\n<p>As a minimal example, you can use this rule to allow =< 2 SSH connections per 60 seconds:\n\n\n<pre>\r\npass in on $ext_if proto tcp from any to any port 22 keep state (max-src-conn-rate 2\/60)\r\n<\/pre>\n<p>Note that you have to use parentheses, even using just one option (max-src-conn-rate), otherwise you&#8217;ll get an error while parsing the ruleset.<br \/>\nKeep in mind that one of <em>keep state<\/em>, <em>modulate state<\/em>, or <em>synproxy state<\/em> must be specified explicitly to apply this option to a rule.<\/p>\n<p>For more information read the <a href=\"http:\/\/man.openbsd.org\/pf.conf.5#max-src-conn\" rel=\"noopener\" target=\"_blank\">documentation<\/a> for pf.conf syntax.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In iptables there is a nice module called hashlimit. Being in love with OpenBSD and PF, I decided to find if this wonderful firewall has the same feature. As a minimal example, you can use this rule to allow =< 2 SSH connections per 60 seconds: pass in on $ext_if proto tcp from any to [&hellip;]\n<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,28],"class_list":["post-1171","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-openbsd","tag-pf"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1171"}],"version-history":[{"count":8,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1171\/revisions"}],"predecessor-version":[{"id":1179,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1171\/revisions\/1179"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}