{"id":3009,"date":"2012-04-23T16:39:33","date_gmt":"2012-04-23T08:39:33","guid":{"rendered":"http:\/\/jpuyy.com\/?p=3009"},"modified":"2014-11-06T17:39:29","modified_gmt":"2014-11-06T09:39:29","slug":"iptables-dnat-target","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=3009","title":{"rendered":"iptables\u7684DNAT target"},"content":{"rendered":"<p>Destination Network Address Translation (DNAT)\u662f\u901a\u8fc7\u4fee\u6539\u5305\u7684\u76ee\u6807\u5730\u5740\u548c\/\u6216\u7aef\u53e3\u5b9e\u73b0\u7684\u3002\u5982\u679c\u76ee\u6807\u5730\u5740\u662f\u591a\u4e2a\uff0c\u8fd9\u4e9b\u5730\u5740\u5c31\u4f1a\u88ab\u5206\u79bb\u3002\u8fde\u63a5\u8ddf\u8e2a\u4fe1\u606f\u786e\u4fdd\u5305\u7684\u6bcf\u4e00\u4e2a\u5730\u5740\u8d70\u5411\u540c\u4e00\u4e3b\u673a\u548c\u7aef\u53e3\u3002<\/p>\n<p>\u9009\u9879<\/p>\n<pre>--to-destination a1[-a2][:p1-p2]<\/pre>\n<p>a1\u548ca2\u6807\u660e\u4e86\u76ee\u6807\u5730\u5740\uff0cp1\u548cp2\u6807\u660e\u4e86\u7aef\u53e3\u8303\u56f4\u3002<\/p>\n<p>DNAT target\u53ea\u5728nat\u8868\u7684PREROUTHING\u548cOUTPUT\u94fe\u4e2d\u53ef\u6709<\/p>\n<p>\u5982\uff1a\u4ece80\u7aef\u53e3\u8fdb\u6765\u7684\u5305\u4f20\u5230\u5185\u90e8\u76d1\u542c\u7684\u7535\u8111192.168.1.80<\/p>\n<pre>iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.80<\/pre>\n<p>\u6ce8\u610f\uff1a\u5f53\u4f7f\u7528\u8fd9\u79cdDNAT\u65f6\uff0c\u5c06\u5185\u5916DNS\u533a\u5206\uff0c\u624d\u53ef\u4ee5\u4f7f\u5185\u7f51\u7684\u4e3b\u673a\u4f7f\u7528\u5185\u90e8\u5730\u5740\u8bbf\u95ee\u5916\u7f51\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Destination Network Address Translation (DNAT)\u662f\u901a\u8fc7\u4fee\u6539\u5305\u7684\u76ee\u6807\u5730\u5740\u548c\/\u6216\u7aef\u53e3\u5b9e\u73b0\u7684\u3002\u5982\u679c\u76ee\u6807\u5730\u5740\u662f\u591a\u4e2a\uff0c\u8fd9\u4e9b\u5730\u5740\u5c31\u4f1a\u88ab\u5206\u79bb\u3002\u8fde\u63a5\u8ddf\u8e2a\u4fe1\u606f\u786e\u4fdd\u5305\u7684\u6bcf\u4e00\u4e2a\u5730\u5740\u8d70\u5411\u540c\u4e00\u4e3b\u673a\u548c\u7aef\u53e3\u3002 \u9009\u9879 &#8211;to-destination a1[-a2][:p1-p2] a1\u548ca2\u6807\u660e\u4e86\u76ee\u6807\u5730\u5740\uff0cp1\u548cp2\u6807\u660e\u4e86\u7aef\u53e3\u8303\u56f4\u3002 DNAT target\u53ea\u5728nat\u8868\u7684PREROUTHING\u548cOUTPUT\u94fe\u4e2d\u53ef\u6709 \u5982\uff1a\u4ece80\u7aef\u53e3\u8fdb\u6765\u7684\u5305\u4f20\u5230\u5185\u90e8\u76d1\u542c\u7684\u7535\u8111192.168.1.80 iptables -t nat -A PREROUTING -i eth0 -p tcp &#8211;dport 80 -j DNAT &#8211;to-destination 192.168.1.80 \u6ce8\u610f\uff1a\u5f53\u4f7f\u7528\u8fd9\u79cdDNAT\u65f6\uff0c\u5c06\u5185\u5916DNS\u533a\u5206\uff0c\u624d\u53ef\u4ee5\u4f7f\u5185\u7f51\u7684\u4e3b\u673a\u4f7f\u7528\u5185\u90e8\u5730\u5740\u8bbf\u95ee\u5916\u7f51\u3002 &nbsp; &nbsp;<\/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":[23],"class_list":["post-3009","post","type-post","status-publish","format-standard","hentry","category-iptables","tag-summary"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3009","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=3009"}],"version-history":[{"count":3,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3009\/revisions"}],"predecessor-version":[{"id":6813,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3009\/revisions\/6813"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}