{"id":2345,"date":"2022-05-27T10:07:53","date_gmt":"2022-05-27T02:07:53","guid":{"rendered":"https:\/\/dasmz.com\/?p=2345"},"modified":"2022-07-10T10:06:07","modified_gmt":"2022-07-10T02:06:07","slug":"%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86%ef%bc%8ciptables%e6%8a%80%e6%9c%af-2022-5-27","status":"publish","type":"post","link":"https:\/\/dasmz.com\/?p=2345","title":{"rendered":"\u900f\u660e\u4ee3\u7406\uff0ciptables\u6280\u672f 2022-5-27"},"content":{"rendered":"\n<p><strong>\u6bb5\u843d1\u3001\u9700\u6c42\u8bf4\u660e<\/strong><\/p>\n\n\n\n<p>\u914d\u7f6e\u900f\u660e\u4ee3\u7406\uff0c\u53ef\u6839\u636eIP\u5730\u57df\uff0c\u8fdb\u884c\u8def\u7531\u5b9a\u5411\u3002<\/p>\n\n\n\n<p>\u672c\u6559\u7a0b\uff0c\u5bf9\u521d\u5b66\u8005\u6709<strong>\u76f8\u5f53\u7684\u96be\u5ea6<\/strong>\uff0c\u9700\u8981\u5bf9iptables\u89c4\u5219\u719f\u7ec3\u4e8e\u5fc3\uff0c\u6709\u5dee\u9519\uff0c\u6574\u4e2a\u7f51\u7edc\u53ef\u80fd\u51fa\u73b0\u4f60\u65e0\u6cd5\u9884\u6599\u7684\u6545\u969c\u3002<\/p>\n\n\n\n<p>GeoIP CN\u7684\u76ee\u6807\u5730\u5740\uff0c\u76f4\u8fde<\/p>\n\n\n\n<p>Local\uff0c\u672c\u5730\u5730\u5740\uff0c\u4fdd\u7559\u5730\u5740\uff0c\u76f4\u8fde<\/p>\n\n\n\n<p>Node Server\uff0c\u76f4\u8fde<\/p>\n\n\n\n<p>\u5176\u4ed6\uff0c\u8d70 socks5:\/\/127.0.0.1:10808<\/p>\n\n\n\n<p><strong>\u6bb5\u843d2\u3001\u57fa\u7840\u8bbe\u65bd<\/strong><\/p>\n\n\n\n<p>\u7cfb\u7edf\u73af\u5883 Ubuntu 20.04 LTS<\/p>\n\n\n\n<p>GeoIP CN\u7684IP CIDR\u5730\u5740\u6e05\u5355<\/p>\n\n\n\n<p>ipset \u5de5\u5177\u96c6<\/p>\n\n\n\n<p>node server 1\u679a<\/p>\n\n\n\n<p><strong>\u6bb5\u843d3\u3001iptables\u57fa\u7840\u77e5\u8bc6<\/strong><\/p>\n\n\n\n<p>\u7565<\/p>\n\n\n\n<p><strong>\u6bb5\u843d4\u3001\u914d\u7f6e\u65b9\u5f0f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u521b\u5efa\u81ea\u5b9a\u4e49\u7684chain\u94fe\niptables -t nat -N V2FLY                 # \u5728NAT\u8868\u521b\u5efa\u94fe\niptables -t mangle -N V2FLY              # \u5728MANAGE\u8868\u521b\u5efa\u94fe\n\n# \u8ba9\u4f60\u7684V2FLY\u670d\u52a1\u5668IP\u8d70\u76f4\u8fdedirect\niptables -t nat -A V2FLY -d AA.BB.CC.DD -j RETURN    # \u8fd9\u91cc\u6307\u5b9aNodeServer\u5730\u5740\uff0creturn \u7ee7\u7eed\u6267\u884c\u81ea\u5b9a\u4e49\u7684\u52a8\u4f5c\n\n# \u8ba9\u4f60\u7684\u5c40\u57df\u7f51IP\u53ca\u5176\u4ed6\u672c\u5730\u53ca\u4fdd\u7559\u5730\u5740\u8d70direct\n# Ignore LANs and any other addresses you'd like to bypass the proxy\n# See Wikipedia and RFC5735 for full list of reserved networks.\n# See ashi009\/bestroutetb for a highly optimized CHN route list.\niptables -t nat -A V2FLY -d 0.0.0.0\/8 -j RETURN\niptables -t nat -A V2FLY -d 10.0.0.0\/8 -j RETURN\niptables -t nat -A V2FLY -d 127.0.0.0\/8 -j RETURN\niptables -t nat -A V2FLY -d 169.254.0.0\/16 -j RETURN\niptables -t nat -A V2FLY -d 172.16.0.0\/12 -j RETURN\niptables -t nat -A V2FLY -d 192.168.0.0\/16 -j RETURN\niptables -t nat -A V2FLY -d 224.0.0.0\/4 -j RETURN\niptables -t nat -A V2FLY -d 240.0.0.0\/4 -j RETURN\n\n# \u5176\u4ed6\u6d41\u91cf\u90fd\u91cd\u5b9a\u5411\u5230\u4f60\u7684\u672c\u5730\u7684V2FLY-CLIENT\u672c\u5730\u7aef\u53e3\niptables -t nat -A V2FLY -p tcp -j REDIRECT --to-ports 10808\n\n# \u5176\u4ed6\u4e00\u4e9bDNS\u6d41\u91cf\n# Add any UDP rules\nip route add local default dev lo table 100\nip rule add fwmark 1 lookup 100\niptables -t mangle -A V2FLY -p udp --dport 53 -j TPROXY --on-port 10808 --tproxy-mark 0x01\/0x01\n\n# \u5e94\u7528\u89c4\u5219\uff0c\u5c06\u81ea\u5b9a\u4e49\u7684\u94fe\u52a0\u5165\u5230\u4f20\u7edf\u7684\u94fe\u4e2d\niptables -t nat -A PREROUTING -p tcp -j V2FLY\niptables -t mangle -A PREROUTING -j V2FLY\n\n# \u542f\u52a8\u5ba2\u6237\u7aef V2FLY-CLIENT \u8fdb\u7a0b\u5e38\u9a7b\n\/usr\/bin\/v2ray\/v2ray -config \/etc\/config\/V2FLY.json <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -t nat -I PREROUTING -p tcp -m set --match-set redrock dst -j REDIRECT --to-ports 8848\niptables -t nat -I OUTPUT -p tcp -m set --match-set redrock dst -j REDIRECT --to-ports 8848<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6bb5\u843d1\u3001\u9700\u6c42\u8bf4\u660e \u914d\u7f6e\u900f\u660e\u4ee3\u7406\uff0c\u53ef\u6839\u636eIP\u5730\u57df\uff0c\u8fdb\u884c\u8def\u7531\u5b9a\u5411\u3002 \u672c\u6559\u7a0b\uff0c\u5bf9\u521d\u5b66\u8005\u6709\u76f8\u5f53\u7684\u96be\u5ea6\uff0c\u9700\u8981\u5bf9iptab [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/2345"}],"collection":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2345"}],"version-history":[{"count":13,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/2345\/revisions"}],"predecessor-version":[{"id":2578,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/2345\/revisions\/2578"}],"wp:attachment":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}