{"id":122,"date":"2022-09-03T06:27:55","date_gmt":"2022-09-02T22:27:55","guid":{"rendered":"https:\/\/andy9999678.me\/blog\/?p=122"},"modified":"2023-02-13T16:20:49","modified_gmt":"2023-02-13T08:20:49","slug":"%e4%bd%bf%e7%94%a8-shorewall-zone-%e9%85%8d%e7%bd%ae%e8%bd%af%e8%b7%af%e7%94%b1%e4%b8%8a%e7%89%b9%e5%ae%9a%e6%9c%ba%e5%99%a8%e7%9a%84%e6%b5%81%e9%87%8f%e8%bd%ac%e5%8f%91","status":"publish","type":"post","link":"https:\/\/andy9999678.me\/blog\/archives\/122","title":{"rendered":"\u4f7f\u7528 Shorewall zone \u914d\u7f6e\u8f6f\u8def\u7531\u4e0a\u7279\u5b9a\u673a\u5668\u7684\u6d41\u91cf\u8f6c\u53d1"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u80cc\u666f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bb6\u91cc\u7684\u8f6f\u8def\u7531\u4e00\u76f4\u4e00\u53f0\u662f\u8dd1\u7740 ArchLinux \u7684 x86 \u8bbe\u5907\u3002\u6700\u521d\u662f\u53c2\u7167\u7740 <a rel=\"noreferrer noopener\" href=\"https:\/\/wiki.archlinux.org\/title\/Router\" target=\"_blank\">Arch Wiki: Router<\/a> \u7684\u9875\u9762\u4e00\u6b65\u4e00\u6b65\u914d\u7f6e\uff0c\u8f6c\u53d1 \/ \u8def\u7531 \/ \u9632\u706b\u5899\u76f8\u5173\u7684\u529f\u80fd\u5c31\u6cbf\u7740 wiki \u7684\u6559\u5b66\u9009\u62e9\u4e86 <a rel=\"noreferrer noopener\" href=\"https:\/\/wiki.archlinux.org\/title\/Shorewall\" target=\"_blank\">Shorewall<\/a>\uff0c\u800c\u6ca1\u6709\u9009\u62e9\uff08\u5728\u6211\u770b\u6765\u5b66\u4e60\u6210\u672c\u66f4\u9ad8\u7684\uff09iptables\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53bb\u5e74\u641e\u4e86\u4e00\u4e2a\u65b0\u7684 Apple TV\uff0c\u5c31\u6709\u4e86\u8ba9\u5c40\u57df\u7f51\u91cc\u9762\u7279\u5b9a\u8bbe\u5907\u7684\u6d41\u91cf\u8f6c\u53d1\u5230\u4ee3\u7406\u4e0a\u7684\u9700\u6c42\u3002\u6298\u817e\u4e00\u6bb5\u65f6\u95f4\u4e0b\u6765\u53d1\u73b0 Shorewall \u4e0a\u914d\u7f6e\u7c7b\u4f3c\u7684\u4e8b\u60c5\u5e76\u4e0d\u662f\u5f88\u96be\uff0c\u57fa\u4e8e\u914d\u7f6e\u6587\u4ef6\u7684 Shorewall \u5728\u914d\u7f6e\u597d\u4e4b\u540e\u4e5f\u6bd4\u8f83\u597d\u7ef4\u62a4\uff0c\u56e0\u6b64\u628a\u76f8\u5173\u914d\u7f6e\u7684\u8fc7\u7a0b\u8bb0\u5f55\u4e0b\u6765\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/shorewall.org\/manpages\/shorewall-zones.html\">Shorewall \u91cc\u9762\u7684 zone \u529f\u80fd<\/a> \u53ef\u4ee5\u5f88\u597d\u89e3\u51b3\u6211\u7684\u9700\u6c42\uff0c\u540e\u9762\u7684\u5185\u5bb9\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u5728 Shorewall \u91cc\u9762\u589e\u52a0 zone \u5e76\u914d\u7f6e\u8f6c\u53d1\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u914d\u7f6e &#8211; \u8f6c\u53d1\u6d41\u91cf\u4e4b\u524d<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Shorewall \u6700\u57fa\u672c\u7684\u8f6f\u8def\u7531\u914d\u7f6e\u53ef\u4ee5\u53c2\u8003\u4ed6\u4eec\u7684\u5b98\u65b9\u6587\u6863\uff08<a href=\"https:\/\/shorewall.org\/two-interface.htm\" target=\"_blank\" rel=\"noreferrer noopener\">Basic Two-interfaces Firewall<\/a>\uff09\uff0c\u6216\u8005 <a href=\"https:\/\/wiki.archlinux.org\/title\/Shorewall\">Arch Wiki<\/a>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u8fd9\u91cc\u53ea\u7528\u6765\u5c55\u793a\u540e\u9762 zone \u914d\u7f6e\u7684\u57fa\u7840\uff1a <code>\/etc\/shorewall\/zones<\/code> \u6587\u4ef6\u91cc\u9762\u6709\u4e24\u4e2a\u57fa\u672c\u7684 zone \u5bf9\u5e94\u5c40\u57df\u7f51 <code>loc<\/code> \uff08\u5b9e\u9645\u4e3a <code>10.0.0.1\/24<\/code>\uff09\u548c\u5916\u7f51 <code>net<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># content of \/etc\/shorewall\/zones\n\n#ZONE   TYPE    OPTIONS                 IN                      OUT\n#                                       OPTIONS                 OPTIONS\nfw      firewall\nnet     ipv4\nloc     ipv4<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53e6\u5916\u4e5f\u9700\u8981\u6309\u7167\u4e0a\u9762\u7684\u6559\u7a0b\uff0c\u81f3\u5c11\u914d\u7f6e\u597d <code>rules<\/code>\uff0c<code>masq<\/code>\uff08\u6216\u8005\u53eb\u505a <code>snat<\/code>\uff0c\u5982\u679c\u4f7f\u7528\u66f4\u65b0 Shorewall  \u7248\u672c\uff09\u8fd9\u4e9b\u6587\u4ef6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u914d\u7f6e &#8211; \u65b0\u589e\u4e00\u4e2a zone \u4e13\u95e8\u653e\u7f6e\u8981\u8f6c\u53d1\u6d41\u91cf\u7684\u8bbe\u5907<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u5206\u6210\u4e24\u90e8\u5206\uff0c\u4e00\u4e2a\u662f\u65b0\u7684 zone \u7684\u5b9a\u4e49\uff0c\u53e6\u4e00\u4e2a\u662f\u6709\u4e86 zone \u5b9a\u4e49\u4e4b\u540e\u7684\u8f6c\u53d1\u89c4\u5219\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">zone \u7684\u5b9a\u4e49<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u9700\u8981\u65b0\u5b9a\u4e49\u4e00\u4e2a\u5728 <code>loc<\/code> \u91cc\u9762\u7684\u65b0\u533a\u57df\uff0c\u5047\u8bbe\u53eb\u505a <code>new<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># additional content of \/etc\/shorewall\/zones\n\nnew:loc         ipv4<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u6587\u6863\uff0c\u5192\u53f7\u540e\u9762\u7684 <code>loc<\/code> \u6307\u7684\u662f <code>parent_zone<\/code>\uff0c\u8bf4\u660e\u6211\u4eec\u65b0\u7684 zone \u662f\u5728\u5185\u7f51 <code>loc<\/code> \u91cc\u9762\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fdb\u4e00\u6b65\u6211\u4eec\u9700\u8981\u6307\u5b9a <code>loc<\/code> \u7684\u54ea\u4e00\u90e8\u5206\u5728 <code>new<\/code> \u533a\u57df\u91cc\u9762\uff0c\u8fd9\u91cc\u9700\u8981\u4fee\u6539 Shorewall \u7684 <code>hosts<\/code> \u6587\u4ef6\uff0c\u6211\u81ea\u5df1\u53ea\u6dfb\u52a0\u4e86\u4e00\u4e2a IP \u5730\u5740\uff08\u9884\u7559\u7ed9\u6211\u7684 Apple TV\uff09\u3002\u6309\u7167\u6587\u6863\uff0c\u8fd9\u91cc\u53ef\u4ee5\u5199\u6210 IP \u5730\u5740\u6bb5\u6bd4\u5982 <code>10.0.0.201-10.0.0.220<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># content of \/etc\/shorewall\/hosts\n\n#ZONE           HOSTS                           OPTIONS\nnew             enp4s0:10.0.0.201\n\n# change `enp4s0` to your interface name of `loc`\n# you can change to `enp4s0:10.0.0.201-10.0.0.220` to include more IPs (devices).<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u8f6c\u53d1\u89c4\u5219<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u6838\u5fc3\u7684\u90e8\u5206\u662f\u8f6c\u53d1\u89c4\u5219\uff0c\u8fd9\u91cc\u7684\u89c4\u5219\u5e76\u4e0d\u4e00\u5b9a\u662f\u7b26\u5408\u5927\u5bb6\u9700\u6c42\u7684\u3002\u6211\u8bbe\u7f6e\u7684\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TCP \u8bf7\u6c42\u8f6c\u53d1\u5230\u6211\u4eec\u51c6\u5907\u597d\u7684 redir \/ clash \u4ee3\u7406\u4e0a\u9762 <code>10.0.0.1:8883<\/code><\/li>\n\n\n\n<li>DNS \u8bf7\u6c42\uff0853 \u7aef\u53e3\u7684 UDP\uff09\u8f6c\u53d1\u5230\u6211\u4eec\u4e13\u95e8\u4e3a Apple TV \u51c6\u5907\u7684\u5185\u7f51 DNS \u4e0a <code>10.0.0.1:8053<\/code><\/li>\n\n\n\n<li>\u5185\u7f51\u6d41\u91cf\u9700\u8981\u6b63\u5e38\u76f4\u901a\uff0c\u4e0d\u8981\u8d70\u8f6c\u53d1<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\u6211\u4eec\u8fd9\u91cc\u6211\u4eec\u4fee\u6539 <code>rules<\/code>\u6587\u4ef6\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># additional content of \/etc\/shorewall\/rules\n\n# redirect outside zone (apple tv) to locally 8883 port transparent redsocks proxy\n# ACTION        SOURCE  DEST                    PROTO   DPORT   SPORT   ORIGDEST\nACCEPT+         new     all                     TCP     -       -       10.0.0.0\/24\n# ACCEPT+         new     net                     TCP     -       -       192.168.1.0\/24\nREDIRECT        new     8883                    TCP\nREDIRECT        new     8053                    UDP     53<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u95ee\u9898 &#8211; \u8c01\u6765\u63a5\u53d7\u8f6c\u53d1\uff1f<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 <a href=\"https:\/\/github.com\/darkk\/redsocks\">redsocks<\/a> \u628a\u4e00\u4e2a socks \u4ee3\u7406\u8f6c\u6362\u4e3a\u900f\u660e\u4ee3\u7406\uff08\u6211\u4e0d\u77e5\u9053\u8fd9\u91cc\u7528\u8bcd\u662f\u5426\u51c6\u786e\uff09\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Clash \u63d0\u4f9b\u7684 redir \u7aef\u53e3\uff0c\u8fd9\u91cc\u4e0d\u518d\u7279\u522b\u5c55\u5f00\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136\uff0c\u65e2\u7136\u6211\u4eec\u5728\u914d\u7f6e\u6587\u4ef6\u4e0a\u5e0c\u671b Apple TV \u6709 10.0.0.201 \u8fd9\u4e2a IP \u5730\u5740\uff0c\u5c31\u9700\u8981\u6211\u4eec\u901a\u8fc7\u624b\u52a8\u4fee\u6539 Apple TV \u8bbe\u7f6e\uff0c\u6216\u8005\u4fee\u6539 DHCP \u670d\u52a1\u5668\u914d\u7f6e\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u914d\u7f6e\u597d\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u770b\u5230 Apple TV \u7684\u6d41\u91cf\u88ab\u8f6c\u53d1\u5230\u6211\u4eec\u5047\u8bbe\u597d\u7684\u670d\u52a1\u4e0a\u9762\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u540e\u7eed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u8fd9\u6837\u914d\u7f6e\uff0c\u4e00\u4e9b\u4e0d\u597d\u4fee\u6539\u4ee3\u7406\u8bbe\u7f6e\u7684\u8bbe\u5907\u90fd\u53ef\u4ee5\u901a\u8fc7\u8fd9\u79cd\u529e\u6cd5\u6765\u6307\u5b9a\u5f3a\u884c\u8f6c\u53d1\u3002\u65b0\u7684\u8bbe\u5907\u53ea\u9700\u8981\u4fee\u6539 DHCP Server \u8bbe\u7f6e\u843d\u5728\u8f6c\u53d1\u7684 IP \u5730\u5740\u533a\u95f4\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540e\u7eed\u6211\u4f1a\u8003\u8651\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u662f\u5426\u53ef\u4ee5\u628a VLAN \u878d\u5408\u8fdb\u914d\u7f6e\uff1f\uff08\u9700\u8981\u6211\u7684\u4ea4\u6362\u673a\u914d\u7f6e\u597d VLAN\uff09<\/li>\n\n\n\n<li>\u662f\u5426\u53ef\u4ee5\u8ba9\u7279\u5b9a AP \u7684\u8bbe\u5907\u8fdb\u5165\u5230\u6211\u65b0\u589e\u7684 zone \u91cc\u9762\uff1f\uff08\u53ef\u80fd\u53ef\u4ee5\u9760\u6539\u5584 DHCP Server \u89e3\u51b3\uff09<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u5bb6\u91cc\u7684\u8f6f\u8def\u7531\u4e00\u76f4\u4e00\u53f0\u662f\u8dd1\u7740 ArchLinux \u7684 x86 \u8bbe\u5907\u3002\u6700\u521d\u662f\u53c2\u7167\u7740 Arch Wiki: R &hellip; <a href=\"https:\/\/andy9999678.me\/blog\/archives\/122\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u4f7f\u7528 Shorewall zone \u914d\u7f6e\u8f6f\u8def\u7531\u4e0a\u7279\u5b9a\u673a\u5668\u7684\u6d41\u91cf\u8f6c\u53d1<\/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":[7],"tags":[],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":5,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":229,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts\/122\/revisions\/229"}],"wp:attachment":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}