{"id":837,"date":"2008-03-26T01:00:00","date_gmt":"2008-03-25T16:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2008-03-26-1.html"},"modified":"2026-08-10T14:44:42","modified_gmt":"2026-08-10T05:44:42","slug":"2008-03-26-1","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2008-03-26-1.html","title":{"rendered":"pf \u3067\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0"},"content":{"rendered":"<p>\nFreeBSD \u3067 pf \u3092\u4f7f\u3063\u3066\u30eb\u30fc\u30bf\u3092\u4f5c\u308b\u30e1\u30e2\u3002<br \/>\n&nbsp;<br \/>\n\u76ee\u7684:<br \/>\n\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u304c\u4e8c\u3064\u3042\u308a\u3001\u305d\u308c\u305e\u308c\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306b\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3001\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3068\u3057\u3066\u5272\u308a\u5f53\u3066\u308b\u3068\u3059\u308b\u3002<br \/>\n\u5185\u90e8\u2192\u5916\u90e8\u306e\u901a\u4fe1\u306f IP \u30de\u30b9\u30ab\u30ec\u30fc\u30c9(NAPT)\u3067\u900f\u904e\u7684\u306b\u901a\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3001\u5916\u90e8\u2192\u5185\u90e8\u306e\u901a\u4fe1\u306f\u7279\u5b9a\u306e\u30dd\u30fc\u30c8\u306e\u307f NAT \u3067\u30b5\u30fc\u30d0\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3059\u308b\u3002<br \/>\n&nbsp;<br \/>\n\u9069\u7528\u4f8b:<br \/>\nA. FreeBSD \u3092\u30eb\u30fc\u30bf\u3068\u3057\u3066\u52d5\u4f5c\u3055\u305b\u308b\u3002<br \/>\nB. (\u5fdc\u7528) jail \u3092\u4eee\u60f3\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u5165\u308c\u3001\u5916\u3078\u306e\u901a\u4fe1\u3092\u5236\u5fa1\u3059\u308b\u3002<br \/>\n&nbsp;<\/p>\n<hr \/>\n<p>\n\u8a2d\u5b9a\u65b9\u6cd5(A):<br \/>\n&#8230;\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092 fxp0, \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092 fxp1 \u3068\u3057\u3066\u30eb\u30fc\u30bf\u3068\u3057\u3066\u8a2d\u5b9a\u3059\u308b\u5834\u5408<br \/>\n\/etc\/rc.conf:<\/p>\n<blockquote><p>defaultrouter=&#8221;192.168.1.1&#8243; # \u5916\u90e8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4<br \/>\n&nbsp;<br \/>\n# \u5916\u90e8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\nifconfig_fxp0=&#8221;inet 192.168.1.2 192.168.1.255 netmask 255.255.255.0&#8243;<br \/>\n# \u5185\u90e8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\nifconfig_fxp1=&#8221;inet 10.0.0.1 10.0.0.255 netmask 255.255.255.0&#8243;<br \/>\n&nbsp;<br \/>\n# pf \u3092\u6709\u52b9\u5316<br \/>\npf_enable=YES<br \/>\npf_rules=&#8221;\/etc\/pf.conf&#8221;<br \/>\npf_flags=&#8221;&#8221;<br \/>\npflog_enable=&#8221;YES&#8221;<br \/>\npflog_logfile=&#8221;\/var\/log\/pflog&#8221;<br \/>\npflog_flags=&#8221;&#8221;\n<\/p><\/blockquote>\n<p>\/etc\/pf.conf:\n<\/p>\n<blockquote><p># \u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\next_if=&#8221;fxp0&#8243; <br \/>\n# \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\nint_if=&#8221;fxp1&#8243;<br \/>\n####<br \/>\n&nbsp;<br \/>\ntable &lt;private> const { 10.0.0\/24 }<br \/>\n&nbsp;<br \/>\n# IP \u30de\u30b9\u30ab\u30ec\u30fc\u30c9<br \/>\nnat on $ext_if inet from ($int_if) to ! &lt;private> -> ($ext_if)<br \/>\n&nbsp;<br \/>\n# NAT \u8a2d\u5b9a\u3002\u5916\u304b\u3089\u306e http(80), https(443) \u306f\u5185\u90e8\u306e 10.0.0.5 \u306b\u3001smtp(25) \u306f\u5185\u90e8\u306e 10.0.0.6 \u306b\u5272\u308a\u5f53\u3066<br \/>\nrdr pass on $ext_if proto tcp from any to ($ext_if) port {80, 443} -> 10.0.0.5<br \/>\nrdr pass on $ext_if proto tcp from any to ($ext_if) port 25 -> 10.0.0.6<br \/>\n&nbsp;<br \/>\n# \u30d1\u30b1\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf: \u8aac\u660e\u3092\u7c21\u5358\u306b\u3059\u308b\u305f\u3081\u5168\u8a31\u53ef\u306b\u3002<br \/>\npass in quick all<br \/>\npass out quick all\n<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>\n\u8a2d\u5b9a\u65b9\u6cd5(B):<br \/>\n&#8230;\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092 fxp0, \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092 lo1 (\u30eb\u30fc\u30d7\u30d0\u30c3\u30af) \u3068\u3057\u3066 jail \u3092\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3067\u7ba1\u7406\u3059\u308b\u5834\u5408\u3002<br \/>\n\/etc\/rc.conf:\n<\/p>\n<blockquote><p>defaultrouter=&#8221;192.168.1.1&#8243; # \u5916\u90e8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4<br \/>\n&nbsp;<br \/>\n# \u5916\u90e8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\nifconfig_fxp0=&#8221;inet 192.168.1.2 192.168.1.255 netmask 255.255.255.0&#8243;<br \/>\n# \u5185\u90e8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\nifconfig_lo1=&#8221;inet 10.0.0.1 10.0.0.255 netmask 255.255.255.0&#8243;<br \/>\nifconfig_lo1_alias=&#8221;inet 10.0.0.2&#8243;<br \/>\nifconfig_lo1_alias=&#8221;inet 10.0.0.3&#8243;<br \/>\nifconfig_lo1_alias=&#8221;inet 10.0.0.4&#8243;<br \/>\nifconfig_lo1_alias=&#8221;inet 10.0.0.5&#8243;<br \/>\nifconfig_lo1_alias=&#8221;inet 10.0.0.6&#8243;<br \/>\n# : \u4ee5\u4e0b\u7565<br \/>\n&nbsp;<br \/>\n# pf \u3092\u6709\u52b9\u5316<br \/>\npf_enable=YES<br \/>\npf_rules=&#8221;\/etc\/pf.conf&#8221;<br \/>\npf_flags=&#8221;&#8221;<br \/>\npflog_enable=&#8221;YES&#8221;<br \/>\npflog_logfile=&#8221;\/var\/log\/pflog&#8221;<br \/>\npflog_flags=&#8221;&#8221;<br \/>\n&nbsp;<br \/>\n####<br \/>\n### Jail \u306e\u8a2d\u5b9a ###<br \/>\njail_enable=&#8221;YES&#8221;<br \/>\njail_list=&#8221;j1 j2 j3&#8243; # \u7acb\u3061\u4e0a\u3052\u308b jail \u306e\u540d\u524d\u306e\u30ea\u30b9\u30c8<br \/>\njail_set_hostname_allow=&#8221;NO&#8221;<br \/>\njail_sysvipc_allow=&#8221;YES&#8221;<br \/>\n## jail_list \u3067\u8a2d\u5b9a\u3057\u305f jail \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u305d\u308c\u305e\u308c\u306b\u3064\u3044\u3066\u8a2d\u5b9a ##<br \/>\n# j1: <br \/>\njail_j1_rootdir=&#8221;\/var\/jail\/j1&#8243;<br \/>\njail_j1_hostname=&#8221;jail_1&#8243;<br \/>\njail_j1_ip=&#8221;10.0.0.2&#8243;<br \/>\njail_j1_exec_start=&#8221;\/bin\/sh \/etc\/rc&#8221;<br \/>\njail_j1_exec_stop=&#8221;\/bin\/sh \/bin\/rc.shutdown&#8221;<br \/>\njail_j1_devfs_enable=&#8221;YES&#8221;<br \/>\njail_j1_fdescfs_enable=&#8221;NO&#8221;<br \/>\njail_j1_procfs_enable=&#8221;YES&#8221;<br \/>\njail_j1_mount_enable=&#8221;NO&#8221;<br \/>\n# j2, j3 \u3082\u540c\u69d8\u306b\u3002\n<\/p><\/blockquote>\n<p>\/etc\/pf.conf:\n<\/p>\n<blockquote><p># \u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\next_if=&#8221;fxp0&#8243; <br \/>\n# \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<br \/>\nint_if=&#8221;lo1&#8243;<br \/>\n####<br \/>\n# \u4ee5\u4e0b \u8a2d\u5b9a\u65b9\u6cd5 A \u3068\u307e\u3063\u305f\u304f\u540c\u3058<br \/>\ntable &lt;private> const { 10.0.0\/24 }<br \/>\n&nbsp;<br \/>\n# IP \u30de\u30b9\u30ab\u30ec\u30fc\u30c9<br \/>\nnat on $ext_if inet from ($int_if) to ! &lt;private> -> ($ext_if)<br \/>\n&nbsp;<br \/>\n# NAT \u8a2d\u5b9a\u3002\u5916\u304b\u3089\u306e http(80), https(443) \u306f\u5185\u90e8\u306e 10.0.0.5 \u306b\u3001smtp(25) \u306f\u5185\u90e8\u306e 10.0.0.6 \u306b\u5272\u308a\u5f53\u3066<br \/>\nrdr pass on $ext_if proto tcp from any to ($ext_if) port {80, 443} -> 10.0.0.5<br \/>\nrdr pass on $ext_if proto tcp from any to ($ext_if) port 25 -> 10.0.0.6<br \/>\n&nbsp;<br \/>\n# \u30d1\u30b1\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf: \u8aac\u660e\u3092\u7c21\u5358\u306b\u3059\u308b\u305f\u3081\u5168\u8a31\u53ef\u306b\u3002<br \/>\npass in quick all<br \/>\npass out quick all\n<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>\n\u53c2\u8003:<br \/>\nFreeBSD\u3067PacketFilter(pf)\u3092\u4f7f\u3046<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FreeBSD \u3067 pf \u3092\u4f7f\u3063\u3066\u30eb\u30fc\u30bf\u3092\u4f5c\u308b\u30e1\u30e2\u3002 &nbsp; \u76ee\u7684: \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u304c\u4e8c\u3064\u3042\u308a\u3001\u305d\u308c\u305e\u308c\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306b\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3001\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3068\u3057\u3066\u5272\u308a\u5f53\u3066\u308b\u3068\u3059\u308b\u3002 \u5185\u90e8\u2192\u5916\u90e8\u306e\u901a\u4fe1 &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2008-03-26-1.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">pf \u3067\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[141],"tags":[25],"class_list":["post-837","post","type-post","status-publish","format-standard","hentry","category-lifehack","tag-freebsd"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=837"}],"version-history":[{"count":1,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/837\/revisions"}],"predecessor-version":[{"id":1744,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/837\/revisions\/1744"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}