{"id":365,"date":"2025-07-15T00:00:50","date_gmt":"2025-07-14T15:00:50","guid":{"rendered":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/?p=365"},"modified":"2026-06-13T01:40:22","modified_gmt":"2026-06-12T16:40:22","slug":"dragonflybsd-pf","status":"publish","type":"post","link":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/2025\/07\/15\/dragonflybsd-pf\/","title":{"rendered":"DragonflyBSD\u306eFireWall\uff1apf \u8a2d\u5b9a\u307e\u3068\u3081"},"content":{"rendered":"<p>\u3055\u3066\uff0cDragonFly BSD\u30b5\u30fc\u30d0\u306b\u9632\u5fa1\u529b\u3092\u3064\u3051\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff0e\u6bb4\u3089\u308c\u308b\u524d\u306b\u9632\u3052\uff01\u305d\u308c\u304c\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u306e\u304a\u4ed5\u4e8b\u3067\u3059\uff0e<\/p>\n<p>DragonFly BSD\u304c\u8a87\u308b\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u3068\u3044\u3048\u3070\u2015\u2015\u305d\u3046\uff0cpf\uff08Packet Filtering\uff09\uff0e<\/p>\n<p>OpenBSD\u3067\u751f\u307e\u308c\uff0cFreeBSD\u306b\u3082\u79fb\u690d\u3055\u308c\uff0c\u305d\u3057\u3066DragonFly BSD\u306b\u3082\u3084\u3063\u3066\u304d\u305f\uff0c\u5805\u7262\u304b\u3064\u67d4\u8edf\u306a\u30d1\u30b1\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u6a5f\u69cb\u3067\u3059\uff0e<\/p>\n<p><\/p>\n<h3>\ud83d\udd0d pf\u306f\u305d\u3082\u305d\u3082\u3044\u308b\u306e\u304b\uff1f<\/h3>\n<p>pf\u3092\u4f7f\u3046\u306b\u306f\uff0c\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u3061\u3083\u3093\u3068\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\uff0e<\/p>\n<p>DragonFly BSD\u3067\u306f\uff0cpf\u306f\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\uff08.ko\uff09\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\uff0c\u307e\u305a\u306f\u305d\u306e\u6709\u7121\u3092\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046<\/p>\n<pre><code>ls \/boot\/kernel\/pf.ko<\/code><\/pre>\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308c\u3070\uff0cpf\u306f\u5b58\u5728\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\uff0e\u306a\u3051\u308c\u3070\u2026\u2026\u307e\u3041\u8abf\u3079\u3066<\/p>\n<p><\/p>\n<h3>\u2699\ufe0f pf\u3092\u30ed\u30fc\u30c9\u3057\u3066\u6709\u52b9\u5316<\/h3>\n<p>\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u5b58\u5728\u3059\u308c\u3070\uff0c\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059<\/p>\n<pre><code>sudo kldload pf<\/code><\/pre>\n<p>\u3053\u306e\u77ac\u9593\uff0c\u9759\u304b\u306b\/dev\/pf\u304c\u51fa\u73fe\u3057\u3066\u3044\u308b\u306f\u305a\u3067\u3059<\/p>\n<pre><code>ls \/dev\/pf<\/code><\/pre>\n<p>\u3053\u308c\u3067\u30ab\u30fc\u30cd\u30eb\u304cpf\u3092\u8a8d\u8b58\u3057\u305f\u72b6\u614b\u306b\u306a\u3063\u3066\u3044\u307e\u3059\uff0e\u7d9a\u3044\u3066\uff0cpf\u672c\u4f53\u3092\u8d77\u52d5\u3057\u307e\u3059<\/p>\n<pre><code>sudo pfctl -e<\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3067\u300cpf\u300d\u304c\u52d5\u4f5c\u72b6\u614b\u306b\u306a\u308a\u307e\u3059\uff0e\u3042\u3068\u306f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\uff08\/etc\/pf.conf\uff09\u3092\u66f8\u3044\u3066\uff0c\u30eb\u30fc\u30eb\u3092\u9069\u7528\u3059\u308b\u3060\u3051\uff01<\/p>\n<p><\/p>\n<h3>\ud83e\udde0 \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240\u3068\u6700\u4f4e\u9650\u306e\u5185\u5bb9<\/h3>\n<p>pf\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306f \/etc\/pf.conf \u306b\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\uff0e<\/p>\n<p>pf\u306e\u57fa\u672c\u7684\u306a\u8a18\u8ff0\u30eb\u30fc\u30eb\u3092\u307e\u3068\u3081\u307e\u3059\uff0e<\/p>\n<p><strong>1\uff0eset \u30bb\u30af\u30b7\u30e7\u30f3\uff1apf\u306e\u52d5\u4f5c\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong><\/p>\n<pre><code>set skip on lo0<\/code><\/pre>\n<p>\u2192 lo0\uff08\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\uff09\u3067\u306f\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3092\u30b9\u30ad\u30c3\u30d7\uff0e\u81ea\u5206\u81ea\u8eab\u3068\u306e\u901a\u4fe1\u3092\u90aa\u9b54\u3057\u306a\u3044\u305f\u3081\u306e\u9244\u5247\uff0e<\/p>\n<p>\u3053\u308c\u3092\u66f8\u304d\u5fd8\u308c\u3066 localhost \u306b\u63a5\u7d9a\u3067\u304d\u305a\u306b\u6570\u6642\u9593\u30cf\u30de\u308b\u3053\u3068\u304c\u306a\u3044\u3088\u3046\u306b\uff0e\uff0e<\/p>\n<p><\/p>\n<p><strong>2\uff0e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5225\u540d<\/strong><\/p>\n<pre><code>ext_if = \"em0\"<\/code><\/pre>\n<p>\u2192 \u5916\u90e8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u5225\u540d\u3092\u3064\u3051\u307e\u3059\uff0e\u3053\u3046\u3057\u3066\u304a\u3051\u3070\uff0c\u3042\u3068\u3067\u30eb\u30fc\u30eb\u306b\u66f8\u304f\u3068\u304d\u306b\u4fbf\u5229\uff01<\/p>\n<p><\/p>\n<p><strong>3\uff0e\u30eb\u30fc\u30eb\u306e\u7a2e\u985e\u3068\u8a18\u8ff0\u69cb\u9020<\/strong><\/p>\n<p>\u57fa\u672c\u69cb\u6587\uff1a<\/p>\n<pre><code>[block|pass] [in|out] on [\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9] [proto] [from] [to] [port] [\u30aa\u30d7\u30b7\u30e7\u30f3]<\/code><\/pre>\n<p>\u4f8b\u3048\u3070\uff1a<\/p>\n<pre><code>pass in on $ext_if proto tcp from any to any port 22 keep state<\/code><\/pre>\n<p>\u2192 \u3053\u308c\u306f\u300c\u5916\u90e8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\uff0c\u4efb\u610f\u306eIP\u304b\u3089\u306eTCP\u63a5\u7d9a\u3067\uff0c\u30dd\u30fc\u30c822\uff08SSH\uff09\u3092\u8a31\u53ef\u300d\u3068\u3044\u3046\u30eb\u30fc\u30eb\u3067\u3059\uff0e<\/p>\n<p><\/p>\n<p><strong>4\uff0e\u72b6\u614b\u8ffd\u8de1\uff08keep state\uff09<\/strong><\/p>\n<pre><code>pass out on $ext_if inet proto tcp to any port 80 keep state<\/code><\/pre>\n<p>\u2192 \u3053\u306e\u300ckeep state\u300d\u304c\u3042\u308b\u3068\uff0c\u3053\u3061\u3089\u304b\u3089\u306eHTTP\u30a2\u30af\u30bb\u30b9\u306b\u5bfe\u3059\u308b\u623b\u308a\u306e\u30d1\u30b1\u30c3\u30c8\u306f\u8a31\u53ef\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<p>\u3064\u307e\u308a\uff0c\u4e00\u5ea6\u901a\u3057\u305f\u3089\u623b\u308a\u306f\u4fe1\u983c\u3059\u308b\u3068\u3044\u3046\u767a\u60f3\uff0e<\/p>\n<p><\/p>\n<p><strong>5\uff0e\u30c6\u30fc\u30d6\u30eb\u306e\u6d3b\u7528\uff08IP\u30a2\u30c9\u30ec\u30b9\u7fa4\u306e\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\uff09<\/strong><\/p>\n<pre><code>table &lt;badguys&gt; persist file \"\/etc\/badhosts.txt\"\r\nblock in quick from &lt;badguys&gt; to any<\/code><\/pre>\n<p>\u2192 badguys \u3068\u3044\u3046\u540d\u524d\u3067\uff0c\u30d6\u30e9\u30c3\u30af\u30ea\u30b9\u30c8IP\u7fa4\u3092\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059\uff0e\u300c\u3068\u308a\u3042\u3048\u305aNG\u306a\u3084\u3064\u5168\u90e8\u5f3e\u304f\u300d\u305f\u3081\u306e\u738b\u9053\uff0e<\/p>\n<p><\/p>\n<h3>\ud83d\udd01 \u8d77\u52d5\u6642\u306bpf\u3092\u81ea\u52d5\u3067\u6709\u52b9\u306b\u3057\u305f\u3044<\/h3>\n<p>\u624b\u52d5\u3067pf\u3092\u8d77\u52d5\u3057\u3066\u3044\u308b\u3068\uff0c\u30ea\u30d6\u30fc\u30c8\u306e\u305f\u3073\u306b\u6253\u3061\u76f4\u3059\u3053\u3068\u306b\u306a\u3063\u3066\u3081\u3093\u3069\u304f\u3055\u3044\uff01<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\uff0c\u8d77\u52d5\u6642\u306b\u81ea\u52d5\u7684\u306bpf\u3092\u6709\u52b9\u306b\u3059\u308b\u8a2d\u5b9a\u3092\u5165\u308c\u3066\u304a\u304d\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p>DragonFly BSD\u3067\u306f \/etc\/rc.conf \u306b\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u3067OK<\/p>\n<pre><code>pf_enable=\"YES\"<\/code><\/pre>\n<p>\u3053\u308c\u3067\u6b21\u56de\u306e\u30d6\u30fc\u30c8\u304b\u3089\u306f\uff0c\u52dd\u624b\u306bpf\u304c\u30ed\u30fc\u30c9\uff06\u8d77\u52d5\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff0e\u305f\u3060\u3057\uff0c\u3042\u304f\u307e\u3067pf.ko\u304c\u5b58\u5728\u3057\u3066\u3044\u3066\uff0c\u304b\u3064\u30ed\u30fc\u30c9\u53ef\u80fd\u306a\u72b6\u614b\u3067\u3042\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\uff0e<\/p>\n<p><\/p>\n<h3>\ud83c\udf81 \u5b9f\u8df5\u7684\u306a pf.conf \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/h3>\n<pre><code># pf.conf - Basic Server Setup\r\n\r\next_if = \"em0\"          # \u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\r\nlocal_net = \"192.168.1.0\/24\"\r\n\r\n# \u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u306f\u9664\u5916\r\nset skip on lo0\r\n\r\n# \u5168\u30d6\u30ed\u30c3\u30af\u304c\u57fa\u672c\u59ff\u52e2\r\nblock all\r\n\r\n# \u5916\u90e8\u304b\u3089\u306eSSH\u3060\u3051\u901a\u3059\r\npass in on $ext_if proto tcp from any to any port 22 keep state\r\n\r\n# \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u304b\u3089\u306e\u3059\u3079\u3066\u306e\u51fa\u529b\u306f\u8a31\u53ef\r\npass out on $ext_if from any to any keep state\r\n\r\n# DHCP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u7528\r\npass in on $ext_if proto udp from any port 67 to any port 68 keep state<\/code><\/pre>\n<p>quick \u3092\u4ed8\u3051\u308b\u3068\u300c\u305d\u308c\u4ee5\u964d\u306e\u30eb\u30fc\u30eb\u306f\u7121\u8996\u3057\u3066\u5373\u9069\u7528\u300d\u3055\u308c\u307e\u3059\uff0e\u30d4\u30f3\u30dd\u30a4\u30f3\u30c8\u906e\u65ad\u306b\u4fbf\u5229\u3067\u3059\u304c\u4f7f\u3044\u65b9\u6ce8\u610f\uff01<\/p>\n<p><\/p>\n<h3>\ud83e\uddea pf \u30eb\u30fc\u30eb\u306e\u78ba\u8a8d\uff06\u53cd\u6620\u65b9\u6cd5<\/h3>\n<pre><code>sudo pfctl -nf \/etc\/pf.conf    # \u6587\u6cd5\u30c1\u30a7\u30c3\u30af\u3060\u3051\r\nsudo pfctl -f \/etc\/pf.conf     # \u8a2d\u5b9a\u306e\u8aad\u307f\u8fbc\u307f\r\nsudo pfctl -e                  # pf \u306e\u6709\u52b9\u5316\uff08\u6700\u521d\u306e\u307f\uff09\r\nsudo pfctl -sr                 # \u73fe\u5728\u306e\u30eb\u30fc\u30eb\u78ba\u8a8d<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>FireWall\u300cpf\u300d\u306e\u8a2d\u5b9a\u65b9\u6cd5\u3067\u3059\uff0e<br \/>\n\u96e3\u3057\u3059\u304e\u308b\u306e\u3067\u307e\u3068\u3081\u3066\u304a\u304d\u307e\u3059\uff0e<\/p>\n","protected":false},"author":2,"featured_media":367,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"common","vkexunit_cta_each_option":"","_lightning_design_setting":{"layout":"default"},"footnotes":""},"categories":[5],"tags":[28,27],"class_list":["post-365","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dragonflybsd","tag-dragonflybsd","tag-pf"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/posts\/365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/comments?post=365"}],"version-history":[{"count":1,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"predecessor-version":[{"id":366,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/posts\/365\/revisions\/366"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/media\/367"}],"wp:attachment":[{"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sgt.tailc1292c.ts.net\/wordpress\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}