{"id":322020,"date":"2021-02-05T14:32:47","date_gmt":"2021-02-05T06:32:47","guid":{"rendered":"http:\/\/4563.org\/?p=322020"},"modified":"2021-02-05T14:32:47","modified_gmt":"2021-02-05T06:32:47","slug":"%e8%83%bd%e7%94%a8-iptables-%e6%8a%8a%e6%b5%81%e9%87%8f%e8%bd%ac%e5%8f%91%e5%88%b0%e5%8f%a6%e4%b8%80%e5%8f%b0%e6%9c%ba%e5%99%a8%e7%9a%84%e6%9f%90%e4%b8%aa%e7%ab%af%e5%8f%a3%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=322020","title":{"rendered":"\u80fd\u7528 iptables \u628a\u6d41\u91cf\u8f6c\u53d1\u5230\u53e6\u4e00\u53f0\u673a\u5668\u7684\u67d0\u4e2a\u7aef\u53e3\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u80fd\u7528 iptables \u628a\u6d41\u91cf\u8f6c\u53d1\u5230\u53e6\u4e00\u53f0\u673a\u5668\u7684\u67d0\u4e2a\u7aef\u53e3\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vinsony <\/span>  <span><i><\/i> 12<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u662f\u8fd9\u6837\uff0c\u4e3b\u8def\u7531\u662f\u4e2a openwrt\uff0cIP 192.168.1.1\uff0c\u53e6\u5916\u4e00\u53f0\u673a\u5668 192.168.1.2 \u4e0a\u5f00\u4e86\u4e2a dokodemo-door\uff0c\u7aef\u53e3\u662f 12345 \u3002<\/p>\n<p>\u73b0\u5728\u60f3\u8ba9\u8def\u7531\u5668\u628a\u6d41\u91cf\u90fd\u8f6c\u53d1\u5230 192.168.1.2:12345 \u4e0a\u3002\u53c2\u8003\u7f51\u4e0a\u900f\u660e\u4ee3\u7406\u7684 iptables \u89c4\u5219\uff0c\u597d\u50cf\u90fd\u662f\u8f6c\u53d1\u7ed9\u672c\u5730\u7aef\u53e3\uff0c\u6211\u5c1d\u8bd5\u8fc7\u8f6c\u53d1\u7ed9\u53e6\u5916\u7684\u673a\u5668\uff0c\u4e0d\u6210\u529f\u3002<\/p>\n<p>\u6211\u4e0d\u60f3\u628a\u7f51\u5173\u6539\u5230 192.168.1.2 \u4e0a\uff0c\u4e0d\u77e5\u9053\u80fd\u4e0d\u80fd\u505a\u8fd9\u6837\u7684\u8f6c\u53d1\uff1f      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>21<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4969778\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : eason1874 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             iptables \u80fd\u505a\u7aef\u53e3\u8f6c\u53d1\u3002\u6211\u66fe\u7ecf\u7528\u8fd9\u4e2a\u8f6c\u53d1\u68af\u5b50\u6d41\u91cf\u5b9e\u73b0\u52a0\u901f\uff0c\u4f46\u662f\u6211\u5fd8\u8bb0\u600e\u4e48\u5199\u4e86\u3002<\/p>\n<p>\u4e0b\u8bf7\uff1a                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969779\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : richzhu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0b\u9762\u662f\u6211\u7528 iptables \u505a\u7684 SNAT<\/p>\n<p>-A POSTROUTING -s 192.168.0.0\/24 -j SNAT &#8211;to-source 192.168.0.150<\/p>\n<p>\u5177\u4f53\u4e5f\u53ef\u4ee5\u767e\u5ea6\u4e00\u4e0b SNAT \u7684\u914d\u7f6e                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969780\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 111111111111 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u731c !# \u8bf4\u7684\u662f\u8fd9\u4e2a<\/p>\n<p> sudo su<br \/> echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<br \/> iptables -t nat -A PREROUTING -p tcp &#8211;dport 8388 -j DNAT &#8211;to-destination US_VPS_IP:8388<br \/> iptables -t nat -A POSTROUTING -p tcp -d US_VPS_IP &#8211;dport 8388 -j SNAT &#8211;to-source JAPAN_VPS_IP<\/p>\n<p>https:\/\/github.com\/shadowsocks\/shadowsocks\/wiki\/Setup-a-Shadowsocks-relay                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969781\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xx6412223 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 SSH Tunneling \u4e5f\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969782\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jirajine <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u6837\u8f6c\u53d1\uff0c\u5c31\u5f97\u8003\u8651\u6d41\u91cf\u56de\u73af\u95ee\u9898\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969783\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nbweb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7ed9\u4f60\u53e6\u4e00\u4e2a\u65b9\u6848<\/p>\n<p>192.168.1.2\uff1a\u505a\u900f\u660e\u4ee3\u7406\uff0c\u518d\u591a\u505a\u4e00\u6b65\uff0c\u52a0\u4e2a dns \u670d\u52a1\u5668<br \/>192.168.1.1\uff1aopenwrt \u7684\u4e3b\u8def\u7531\uff0c\u628a dns \u670d\u52a1\u5668\u548c\u7f51\u5173\u8bbe\u7f6e\u4e3a 192.168.1.2<br \/>\u4ee5\u4e0a\u5b8c\u7f8e\u89e3\u51b3\uff0c\u4e0d\u7528\u8f6c\u53d1\u554a\uff0c\u6211\u5bb6\u73b0\u5728\u5c31\u662f\u8fd9\u4e48\u641e\u7684\uff0c\u76f8\u5f53\u4e8e 192.168.1.2 \u662f\u7f51\u5173\u3002<\/p>\n<p>dnsmasq-full \u914d\u5408 ipset \u53ef\u4ee5\u5b9e\u73b0\u5899\u5185\u5916\u5206\u6d41\uff0c\u5899\u5916\u7684\u8d70\u900f\u660e\u7f51\u5173\uff0c\u5899\u5185\u7684\u76f4\u63a5\u8d70\u8def\u7531\u5668\u51fa\u53bb\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969784\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : vinsony <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9 SNAT \u8c8c\u4f3c\u53ef\u884c\uff0c\u665a\u4e0a\u8bd5\u4e00\u4e0b\uff0c\u8c22\u8c22\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969785\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : vinsony <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @nbweb \u4f60\u662f\u5728 DHCP \u4e0b\u53d1\u7684\u65f6\u5019\uff0c\u7ed9\u5176\u4ed6\u7535\u8111\u8bbe\u7f6e\u8fd9\u4e2a dns \u670d\u52a1\u5668\u548c\u7f51\u5173\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969786\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rihkddd <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             # \u8f6c\u53d1\u811a\u672c\u5185\u5bb9 tcpproxy.sh<br \/>&#8212;&#8212;&#8212;-<br \/>#!\/bin\/sh<br \/># TCP Proxy using IPTables<br \/>echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<\/p>\n<p># Flush nat table<br \/>iptables -t nat -F<\/p>\n<p># tcpproxy LOCAL_IP LOCAL_PORT REMOTE_IP REMOTE_PORT<\/p>\n<p>function tcpproxy {<br \/> iptables -t nat -A PREROUTING &#8211;dst $1 -p tcp &#8211;dport $2 -j DNAT &#8211;to-destination $3:$4<br \/> iptables -t nat -A POSTROUTING &#8211;dst $3 -p tcp &#8211;dport $4 -j SNAT &#8211;to-source $1<br \/> iptables -t nat -A OUTPUT &#8211;dst $1 -p tcp &#8211;dport $2 -j DNAT &#8211;to-destination $3:$4<br \/>}<br \/>&#8212;&#8212;&#8212;&#8212;<\/p>\n<p># \u4f7f\u7528\u65b9\u6cd5<br \/>tcpproxy.sh 192.168.1.1 12345 192.168.1.2 12345                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969787\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : deorth <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u884c\uff0c\u6211\u8bd5\u8fc7\u4e86\u3002\u8de8\u673a\u5668\u900f\u660e\u4ee3\u7406\u6d41\u91cf\u8f6c\u53d1\u4f1a\u5bfc\u81f4\u539f\u76ee\u7684\u5730\u5740\u4e22\u5931                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969788\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : deorth <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ea\u80fd\u66f4\u6539 dhcp \u5206\u914d\u7684\u7f51\u5173                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969789\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ziseyinzi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             10 +1\uff0c\u76ee\u524d iptables \u505a\u4e0d\u5230\uff0cnftable \u8bb0\u5f97\u6709\u80fd\u505a\u5230\u7684\u8bbe\u8ba1\uff0c\u4f46\u662f\u8fd8\u6ca1\u5b9e\u73b0\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969790\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nbweb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vinsony \u4e0d\u662f\uff0c\u5176\u5b83\u7535\u8111\u81ea\u52a8\u83b7\u53d6 ip \u65f6\uff0c\u7f51\u5173\u548c dns \u5c31\u662f\u900f\u660e\u7f51\u5173\u7684\u5730\u5740\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969791\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pheyx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             iptables \u548c iproute \u642d\u914d\u53ef\u4ee5\u5b9e\u73b0\u3002\u770b https:\/\/tldp.org\/HOWTO\/TransparentProxy-6.html \u8fd9\u91cc\u7684\u7b2c 2 \u79cd\u65b9\u6cd5\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969792\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pheyx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u65b9\u6cd5\u4e0d\u7528\u4fee\u6539\u7f51\u5173\uff0c\u539f\u7406\u662f\u628a\u53bb\u5f80 12345 \u7aef\u53e3\u7684\u6d41\u91cf\u6253\u4e0a\u6807\u8bb0\uff0c\u7136\u540e\u8bbe\u5b9a ip rule \u4f7f\u8fd9\u4e9b\u6d41\u91cf\u8d70\u53e6\u4e00\u4e2a\u8def\u7531\u8868\u5230\u8fbe\u8fd0\u884c\u4ee3\u7406\u7684\u8bbe\u5907\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969793\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : linvon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             #14 #15 \u53ef\u89e3\uff0ciptables \u6253 mark\uff0c\u589e\u52a0\u8def\u7531\u8868\u6539\u8def\u7531<br \/>\u4f46\u4f60\u5168\u90e8\u6d41\u91cf\u90fd\u8f6c\u53d1\uff0c\u548c\u6539\u7f51\u5173\u53c8\u6709\u4ec0\u4e48\u533a\u522b\u5462                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969794\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zictos <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u4f7f\u7528 haproxy\uff0ciptables \u8bd5\u4e86\u4e0d\u7a33\u5b9a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969795\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qwerthhusn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 HAProxy \u5427\uff0c\u751a\u81f3 Nginx \u7684 stream \u4ee3\u7406\u90fd\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969796\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Ehco1996 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\u884c\u5de5\u5177<\/p>\n<p>https:\/\/github.com\/Ehco1996\/ehco<\/p>\n<p>\u63a8\u8350\u8bd5\u8bd5                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969797\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : julyclyde <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             SNAT+DNAT \u53ef\u4ee5\u3002haproxy\/nginx \u4e5f\u53ef\u4ee5\u3002\u4e0d\u8fc7\u4f1a\u4e22\u5931\u539f\u59cb\u7684\u5ba2\u6237\u7aef IP<br \/>\u5982\u679c\u8981\u4fdd\u7559\uff0c\u53ef\u4ee5\u5c1d\u8bd5 LVS FullNAT \u6a21\u5f0f+toa \u6a21\u5757                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4969798\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : laqow <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728 openwrt \u4e0a\u88c5 dokodemo-door                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u80fd\u7528 iptables \u628a\u6d41\u91cf\u8f6c\u53d1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/322020"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322020"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/322020\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322020"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}