{"id":2974,"date":"2012-04-19T17:24:23","date_gmt":"2012-04-19T09:24:23","guid":{"rendered":"http:\/\/jpuyy.com\/?p=2974"},"modified":"2012-09-01T10:14:35","modified_gmt":"2012-09-01T02:14:35","slug":"iptables-dnat","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=2974","title":{"rendered":"iptables\u7684Destination NAT (DNAT)"},"content":{"rendered":"<p>Destination NAT (DNAT) \u5c06\u5185\u7f51\u7684\u7279\u5b9a\u670d\u52a1\u66b4\u9732\u5728\u5916\u7f51\uff0c\u800c\u4e0d\u7528\u76f4\u63a5\u628a\u5185\u7f51\u7535\u8111\u8fde\u5230\u5916\u7f51\u3002\u53ea\u8981\u6ca1\u6709\u66f4\u591a\u7684\u670d\u52a1\u540c\u65f6\u4f7f\u7528\u90a3\u4e2a\u7aef\u53e3\uff0c\u53ea\u9700\u4e00\u4e2a\u5916\u7f51\u7684\u8fde\u63a5\u5373\u53ef\u3002<\/p>\n<p>\u505a\u4e3agateway\u628a\u94fe\u63a5\u8f6c\u5411\u5230\u7279\u5b9a\u7aef\u53e3\u5230\u6307\u5b9a\u7684\u5185\u90e8\u7535\u8111\u548c\u7aef\u53e3\uff0c\u518d\u56de\u8f6c\u5230\u5916\u90e8\u7f51\u7edc\u3002<\/p>\n<p>\u56e0\u4e3aDNAT\u6d89\u53ca\u5230\u4fee\u6539\u5c01\u5305\u7684\u76ee\u6807\u5730\u5740\u548c\uff0f\u6216\u7aef\u53e3\u662f\u5728\u5b83\u4eec\u4ea4\u7ed9\u672c\u5730\u7a0b\u5e8f\u548c\u4ea4\u7ed9\u5176\u4ed6\u7535\u8111\u4e4b\u524d\u7684\uff0c\u6240\u4ee5\u5728nat\u8868\u4e2d\u8868\u73b0\u4e3aPREROUTIN\uff27\u94fe\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u8fdb\u5165\u7684\u8fde\u63a5\u4ece\u7f51\u5173\u768480\u7aef\u53e3\u5230\u5185\u90e8\u7f51\u7edc\u7684192.168.1.3\u76848080\u7aef\u53e3\uff0c\u53ef\u4ee5\u4f7f\u7528\u8fd9\u6837\u4e00\u6761\u89c4\u5219\uff1a<\/p>\n<pre>iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80\u3000-j DNAT --to-destination 192.168.1.3:8080<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Destination NAT (DNAT) \u5c06\u5185\u7f51\u7684\u7279\u5b9a\u670d\u52a1\u66b4\u9732\u5728\u5916\u7f51\uff0c\u800c\u4e0d\u7528\u76f4\u63a5\u628a\u5185\u7f51\u7535\u8111\u8fde\u5230\u5916\u7f51\u3002\u53ea\u8981\u6ca1\u6709\u66f4\u591a\u7684\u670d\u52a1\u540c\u65f6\u4f7f\u7528\u90a3\u4e2a\u7aef\u53e3\uff0c\u53ea\u9700\u4e00\u4e2a\u5916\u7f51\u7684\u8fde\u63a5\u5373\u53ef\u3002 \u505a\u4e3agateway\u628a\u94fe\u63a5\u8f6c\u5411\u5230\u7279\u5b9a\u7aef\u53e3\u5230\u6307\u5b9a\u7684\u5185\u90e8\u7535\u8111\u548c\u7aef\u53e3\uff0c\u518d\u56de\u8f6c\u5230\u5916\u90e8\u7f51\u7edc\u3002 \u56e0\u4e3aDNAT\u6d89\u53ca\u5230\u4fee\u6539\u5c01\u5305\u7684\u76ee\u6807\u5730\u5740\u548c\uff0f\u6216\u7aef\u53e3\u662f\u5728\u5b83\u4eec\u4ea4\u7ed9\u672c\u5730\u7a0b\u5e8f\u548c\u4ea4\u7ed9\u5176\u4ed6\u7535\u8111\u4e4b\u524d\u7684\uff0c\u6240\u4ee5\u5728nat\u8868\u4e2d\u8868\u73b0\u4e3aPREROUTIN\uff27\u94fe\u3002 \u4f8b\u5982\uff0c\u8fdb\u5165\u7684\u8fde\u63a5\u4ece\u7f51\u5173\u768480\u7aef\u53e3\u5230\u5185\u90e8\u7f51\u7edc\u7684192.168.1.3\u76848080\u7aef\u53e3\uff0c\u53ef\u4ee5\u4f7f\u7528\u8fd9\u6837\u4e00\u6761\u89c4\u5219\uff1a iptables -t nat -A PREROUTING -i eth1 -p tcp &#8211;dport 80\u3000-j DNAT &#8211;to-destination 192.168.1.3:8080<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[],"class_list":["post-2974","post","type-post","status-publish","format-standard","hentry","category-iptables"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2974"}],"version-history":[{"count":5,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2974\/revisions"}],"predecessor-version":[{"id":9059,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2974\/revisions\/9059"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}