{"id":2566,"date":"2021-10-14T16:17:40","date_gmt":"2021-10-14T23:17:40","guid":{"rendered":"https:\/\/www.xh86.me\/?p=2566"},"modified":"2021-10-14T16:17:40","modified_gmt":"2021-10-14T23:17:40","slug":"%e5%8d%8e%e4%b8%ba%e8%ae%be%e5%a4%87acl%e4%b8%8enat%e6%8a%80%e6%9c%af","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=2566","title":{"rendered":"\u534e\u4e3a\u8bbe\u5907ACL\u4e0eNAT\u6280\u672f"},"content":{"rendered":"<p>NAT \u7f51\u7edc\u5730\u5740\u8f6c\u6362(Network Address Translation),\u662f\u4e00\u4e2a\u4e92\u8054\u7f51\u5de5\u7a0b\u4efb\u52a1\u7ec4\u7684\u6807\u51c6,\u5b83\u53ef\u4ee5\u5b9e\u73b0\u5185\u90e8\u79c1\u6709IP\u5730\u5740\u548c\u516c\u7f51IP\u5730\u5740\u7684\u8f6c\u6362,\u80fd\u591f\u8d77\u5230\u8282\u7ea6\u516c\u7f51IP\u5730\u5740\u7684\u4f5c\u7528,\u4ee5\u4e0b\u5c06\u4ecb\u7ecdNAT\u7684\u4e09\u79cd\u65b9\u5f0f,\u9759\u6001\u8f6c\u6362\u3001\u52a8\u6001\u8f6c\u6362\u548c\u7aef\u53e3\u590d\u7528\u6280\u672f.<\/p>\n<h2>\u534e\u4e3aACL\u8bbf\u95ee\u63a7\u5236<\/h2>\n<p>\u8def\u7531\u5668\u63a5\u53e3\u7684\u8bbf\u95ee\u63a7\u5236\u53d6\u51b3\u4e8e\u5e94\u7528\u5728\u5176\u4e0a\u7684ACL,\u6570\u636e\u5728\u8fdb\u51fa\u7f51\u7edc\u524d,\u8def\u7531\u5668\u4f1a\u6839\u636eACL\u5bf9\u5176\u8fdb\u884c\u5339\u914d,\u5339\u914d\u6210\u529f\u5c06\u5bf9\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4\u6216\u8005\u662f\u8f6c\u53d1,\u5339\u914d\u5931\u8d25\u5219\u4e22\u5f03\u6570\u636e\u5305,\u76ee\u524d\u4e3b\u8981\u6709\u4e09\u79cdACL\u63a7\u5236,\u6807\u51c6ACL,\u6269\u5c55ACL,\u547d\u540dACL,\u6211\u4eec\u53ea\u4ecb\u7ecd\u524d\u4e24\u79cd.<\/p>\n<p>\u5728\u8def\u7531\u5668\u4e0a\u5e94\u7528ACL\u65f6,\u53ef\u4ee5\u4e3a\u6bcf\u79cd\u534f\u8bae,\u6bcf\u4e2a\u7aef\u53e3,\u6bcf\u4e2a\u65b9\u5411,\u548c\u6bcf\u4e2a\u63a5\u53e3,\u914d\u7f6e\u4e00\u4e2aACL,\u4e00\u822c\u79f0\u4e3a3p\u539f\u5219.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"458\" class=\"wp-image-2567\" src=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/timeline-description-automatically-generated.jpeg\" alt=\"Timeline\n\nDescription automatically generated\" srcset=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/timeline-description-automatically-generated.jpeg 1100w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/timeline-description-automatically-generated-300x125.jpeg 300w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/timeline-description-automatically-generated-1024x426.jpeg 1024w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/timeline-description-automatically-generated-768x320.jpeg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>\u25c6\u6807\u51c6ACL\u914d\u7f6e\u25c6<\/h3>\n<p>\u6807\u51c6ALCL\u53ea\u80fd\u901a\u8fc7\u6e90\u5730\u5740\u8fdb\u884c\u8bbf\u95ee\u8fc7\u6ee4\u4e0e\u63a7\u5236,\u56e0\u6b64\u53ea\u80fd\u963b\u6b62\/\u5141\u8bb8\u6765\u81ea\u6307\u5b9aIP\u5730\u5740\u7684\u8bbf\u95ee\u8bf7\u6c42.<\/p>\n<p><strong>\u914d\u7f6e\u8def\u7531\u5668:<\/strong>\u00a0\u63a5\u7740\u914d\u7f6e\u8def\u7531\u5668,\u5f00\u542f\u8def\u7531\u5668\u7684Eth0\/0\/0\u548cEth0\/0\/1\u7aef\u53e3,\u5e76\u914d\u7f6e\u4e0a\u7f51\u5173\u5730\u5740.<\/p>\n<p>&lt;Huawei&gt; system-view<\/p>\n<p>[Huawei]interface GigabitEthernet 0\/0\/0<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/0] ip address 192.168.1.254 255.255.255.0<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/0] quit<\/p>\n<p>[Huawei]interface GigabitEthernet 0\/0\/1<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] ip address 192.168.2.254 255.255.255.0<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] quit<\/p>\n<p><strong>\u914d\u7f6e\u62d2\u7eddACL\u89c4\u5219:<\/strong>\u00a0\u8fd9\u91cc\u6211\u4eec\u5728\u8def\u7531\u5668\u4e0a\u914d\u7f6e\u4e00\u6761\u6807\u51c6\u7684ACL\u89c4\u5219,\u7981\u6b62PC1\u8bbf\u95eeServer1\u670d\u52a1\u5668.<\/p>\n<p>&lt;Huawei&gt;system-view<\/p>\n<p>[Huawei] acl 2000 \/\/ \u6307\u5b9a\u4e00\u4e2a\u5e8f\u53f7 2000-2999<\/p>\n<p>[Huawei-acl-basic-2000] rule deny source 192.168.1.1 0.0.0.0 \/\/ \u62d2\u7edd\u6e90\u5730\u5740\u8bbf\u95ee<\/p>\n<p>[Huawei-acl-basic-2000] rule deny source 192.168.1.1 0.0.0.255 \/\/ \u62d2\u7edd\u6574\u4e2a\u7f51\u6bb5<\/p>\n<p>[Huawei-acl-basic-2000] rule permit source 192.168.1.1 0.0.0.0 \/\/ \u5141\u8bb8\u6e90\u5730\u5740\u8bbf\u95ee<\/p>\n<p>[Huawei-acl-basic-2000] quit<\/p>\n<p>[Huawei] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] traffic-filter outbound acl 2000 \/\/ \u5728\u51fa\u53e3\u65b9\u5411\u5e94\u7528\u89c4\u5219<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] traffic-filter inbound acl 2000 \/\/ \u5728\u5165\u53e3\u65b9\u5411\u5e94\u7528\u89c4\u5219<\/p>\n<p><strong>\u6d4b\u8bd5\u8fc7\u6ee4\u6548\u679c:<\/strong>\u00a0\u914d\u7f6e\u5b8c\u89c4\u5219\u4ee5\u540e,\u6211\u4eec\u6d4b\u8bd5\u4e00\u4e0b\u6548\u679c,\u4f7f\u7528PC1\u65e0\u6cd5\u8bbf\u95eeServer1\u670d\u52a1\u5668\u800c\u662f\u7528PC2\u5219\u53ef\u4ee5\u8bbf\u95ee.<\/p>\n<p>PC1&gt; ping 192.168.2.1<\/p>\n<p>Request timeout!<\/p>\n<p>Request timeout!<\/p>\n<p>PC2&gt; ping 192.168.2.1<\/p>\n<p>From 192.168.2.1: bytes=32 seq=1 ttl=254 time=47 ms<\/p>\n<p>From 192.168.2.1: bytes=32 seq=1 ttl=254 time=47 ms<\/p>\n<p>\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u4e00\u70b9,\u5982\u679c\u4f60\u6709\u4e24\u4e2a\u8def\u7531\u5668\u76f8\u8fde,\u90a3\u4e48ACL\u89c4\u5219\u5e94\u8be5\u8bbe\u7f6e\u5728\u8ddd\u79bb\u9650\u5236\u7684\u76ee\u6807\u8f83\u8fd1\u7684\u8def\u7531\u5668\u4e0a,\u5426\u5219\u53ef\u80fd\u4f1a\u51fa\u73b0\u6709\u6548\u6570\u636e\u5728\u5230\u8fbe\u76ee\u6807\u4e4b\u524d\u5c31\u88ab\u8fc7\u6ee4\u6389\u4e86.<\/p>\n<p>&nbsp;<\/p>\n<h3>\u25c6\u62d3\u5c55ACL\u914d\u7f6e\u25c6<\/h3>\n<p>\u6807\u51c6ACL\u53ea\u80fd\u4f7f\u7528\u6e90\u5730\u5740\u4f5c\u4e3a\u5339\u914d\u6761\u4ef6,\u65e0\u6cd5\u5bf9\u8bbf\u95ee\u8fdb\u884c\u7cbe\u786e\u7684\u63a7\u5236,\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898,\u53ef\u4ee5\u91c7\u7528\u6269\u5c55ACL\u6765\u5bf9\u6570\u636e\u52a0\u4ee5\u9650\u5236,\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u914d\u7f6e\u6269\u5c55ACL,\u5176\u62d3\u6251\u7ed3\u6784\u56fe\u8fd8\u662f\u4f7f\u7528\u4e0a\u56fe.<\/p>\n<p><strong>\u914d\u7f6e\u8def\u7531\u5668:<\/strong>\u00a0\u63a5\u7740\u914d\u7f6e\u8def\u7531\u5668,\u5f00\u542f\u8def\u7531\u5668\u7684Eth0\/0\/0\u548cEth0\/0\/1\u7aef\u53e3,\u5e76\u914d\u7f6e\u4e0a\u7f51\u5173\u5730\u5740.<\/p>\n<p>&lt;Huawei&gt; system-view<\/p>\n<p>[Huawei]interface GigabitEthernet 0\/0\/0<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/0] ip address 192.168.1.254 255.255.255.0<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/0] quit<\/p>\n<p>[Huawei]interface GigabitEthernet 0\/0\/1<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] ip address 192.168.2.254 255.255.255.0<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] quit<\/p>\n<p><strong>\u914d\u7f6e\u7981\u6b62ICMP:<\/strong>\u00a0\u7981\u6b62192.168.1.1\u8bbf\u95ee192.168.2.1\u7684icmp\u534f\u8bae.<\/p>\n<p>&lt;Huawei&gt; system-view<\/p>\n<p>[Huawei] acl 3000<\/p>\n<p>[Huawei-acl-adv-3000] rule deny icmp source 192.168.1.1 0 destination 192.168.2.1 0<\/p>\n<p>[Huawei] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1]<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] traffic-filter outbound acl 3000<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] quit<\/p>\n<p>[Huawei] display acl all<\/p>\n<p>Total quantity of nonempty ACL number is 1<\/p>\n<p>rule 5 deny icmp source 192.168.1.1 0 destination 192.168.2.1 0 (27 matches)<\/p>\n<p><strong>\u7981\u6b62\u6307\u5b9a\u7aef\u53e3:<\/strong>\u00a0\u7981\u6b62TCP\u534f\u8bae,\u7684\u6e90\u5730\u5740192.168.1.1\u81f3\u76ee\u6807\u5730\u5740192.168.2.1,\u7aef\u53e3\u53f780\u7684\u534f\u8bae.<\/p>\n<p>&lt;Huawei&gt; system-view<\/p>\n<p>[Huawei] acl 3000<\/p>\n<p>[Huawei-acl-3000] rule deny tcp source 192.168.1.1 0 destination 192.168.2.1 0 destination-port eq 80<\/p>\n<p>[Huawei] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1]<\/p>\n<p>[Huawei-GigabitEthernet0\/0\/1] traffic-filter outbound acl 3000<\/p>\n<p>[Huawei]display acl all<\/p>\n<p>Total quantity of nonempty ACL number is 1<\/p>\n<p>rule 5 deny icmp source 192.168.1.1 0 destination 192.168.2.1 0 (27 matches)<\/p>\n<p><strong>\u6d4b\u8bd5\u8fc7\u6ee4\u6548\u679c:<\/strong>\u00a0\u914d\u7f6e\u5b8c\u89c4\u5219\u4ee5\u540e,\u6211\u4eec\u6d4b\u8bd5\u4e00\u4e0b\u6548\u679c,\u4f7f\u7528PC1\u65e0\u6cd5\u8bbf\u95eeServer1\u670d\u52a1\u5668\u800c\u662f\u7528PC2\u5219\u53ef\u4ee5\u8bbf\u95ee.<\/p>\n<p>PC1&gt; ping 192.168.2.1<\/p>\n<p>Request timeout!<\/p>\n<p>Request timeout!<\/p>\n<p>PC2&gt; ping 192.168.2.1<\/p>\n<p>From 192.168.2.1: bytes=32 seq=1 ttl=254 time=47 ms<\/p>\n<p>From 192.168.2.1: bytes=32 seq=1 ttl=254 time=47 ms<\/p>\n<p>\u4e0e\u6807\u51c6ACL\u76f8\u6bd4,\u6269\u5c55ACL\u80fd\u591f\u66f4\u52a0\u7cbe\u786e\u7684\u5339\u914d\u548c\u8fc7\u6ee4\u6570\u636e\u5305,\u56e0\u6b64\u6269\u5c55ACL\u7684\u653e\u7f6e\u4f4d\u7f6e\u5e94\u8be5\u79bb\u6e90\u5730\u5740\u8d8a\u8fd1\u8d8a\u597d,\u8fd9\u6837\u624d\u80fd\u591f\u6709\u6548\u7684\u63d0\u9ad8\u94fe\u8def\u7684\u4f7f\u7528\u6548\u7387.<\/p>\n<h2>\u534e\u4e3aNAT\u5730\u5740\u8f6c\u6362<\/h2>\n<p>NAT \u7f51\u7edc\u5730\u5740\u8f6c\u6362(Network Address Translation),\u662f\u4e00\u4e2a\u4e92\u8054\u7f51\u5de5\u7a0b\u4efb\u52a1\u7ec4\u7684\u6807\u51c6,\u5b83\u53ef\u4ee5\u5b9e\u73b0\u5185\u90e8\u79c1\u6709IP\u5730\u5740\u548c\u516c\u7f51IP\u5730\u5740\u7684\u8f6c\u6362,\u80fd\u591f\u8d77\u5230\u8282\u7ea6\u516c\u7f51IP\u5730\u5740\u7684\u4f5c\u7528,\u4ee5\u4e0b\u5c06\u4ecb\u7ecdNAT\u7684\u4e09\u79cd\u65b9\u5f0f,\u9759\u6001\u8f6c\u6362\u3001\u52a8\u6001\u8f6c\u6362\u548c\u7aef\u53e3\u590d\u7528\u6280\u672f.<\/p>\n<p>NAT\u6280\u672f\u4e2d\u6709\u56db\u79cd\u5730\u5740\u5373,\u5185\u90e8\u672c\u5730\u5730\u5740,\u5185\u90e8\u5168\u5c40\u5730\u5740,\u5916\u90e8\u672c\u5730\u5730\u5740,\u5916\u90e8\u5168\u5c40\u5730\u5740.<\/p>\n<p>&nbsp;<\/p>\n<h3>\u25c6\u914d\u7f6e\u9759\u6001NAT\u25c6<\/h3>\n<p>\u9759\u6001NAT\u662f\u6307\u5c06\u5185\u90e8\u672c\u5730\u5730\u5740\u4e0e\u5185\u90e8\u5168\u5c40\u5730\u5740\u8fdb\u884c\u5bf9\u5e94\u8f6c\u6362,\u67d0\u4e2a\u672c\u5730\u5730\u5740\u53ea\u80fd\u8f6c\u6362\u4e3a\u67d0\u4e2a\u5168\u5c40\u5730\u5740,\u901a\u8fc7\u914d\u7f6e\u9759\u6001NAT\u53ef\u4ee5\u5b9e\u73b0\u5185\u90e8\u7f51\u7edc\u5bf9\u5916\u90e8\u7f51\u7edc\u7684\u8bbf\u95ee,\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u5916\u90e8\u7f51\u7edc\u5bf9\u5185\u90e8\u7f51\u7edc\u4e2d\u67d0\u4e2a\u8bbe\u5907\u7684\u8bbf\u95ee.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"633\" class=\"wp-image-2568\" src=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/diagram-description-automatically-generated-23.jpeg\" alt=\"Diagram\n\nDescription automatically generated\" srcset=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/diagram-description-automatically-generated-23.jpeg 1000w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/diagram-description-automatically-generated-23-300x190.jpeg 300w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/diagram-description-automatically-generated-23-768x486.jpeg 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p><strong>\u914d\u7f6e\u8def\u7531\u5668:<\/strong>\u00a0\u914d\u7f6e\u8def\u7531\u5668,\u5f00\u542fR1\u8def\u7531\u5668\u7684Eth0\/0\/0\u548cSer0\/0\/0\u7aef\u53e3,\u5e76\u914d\u7f6e\u4e0a\u7f51\u5173\u5730\u5740.<\/p>\n<p># &#8212;-\u914d\u7f6eR1\u8def\u7531\u5668&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>&lt;R1&gt; system-view<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/0<\/p>\n<p>[R1-GigabitEthernet0\/0\/0] ip address 192.168.1.1 255.255.255.0<\/p>\n<p>[R1-Ethernet0\/0\/0] quit<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] ip address 10.10.10.1 255.0.0.0<\/p>\n<p>[R1-Ethernet0\/0\/0] quit<\/p>\n<p># &#8212;-\u914d\u7f6eR2\u8def\u7531\u5668&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>&lt;R2&gt; system-view<\/p>\n<p>[R2] interface GigabitEthernet 0\/0\/0<\/p>\n<p>[R2-GigabitEthernet0\/0\/0] ip address 10.10.10.2 255.0.0.0<\/p>\n<p>[R2-Ethernet0\/0\/0] quit<\/p>\n<p><strong>\u914d\u7f6e\u9759\u6001NAT:<\/strong>\u00a0\u5728\u8def\u7531\u5668R1\u4e0a\u914d\u7f6e\u9759\u6001NAT,\u5c06\u79c1\u6709\u5730\u5740\u8f6c\u4e3a\u5168\u5c40\u5730\u5740(\u5185\u7f51\u5730\u5740&#8211;&gt;\u5916\u7f51\u5730\u5740).<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] nat static enable \/\/\u542f\u7528\u9759\u6001nat<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] quit<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] nat static global 10.10.10.20 inside 192.168.1.2<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] nat static global 10.10.10.20 inside 192.168.1.2<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] nat static global 10.10.10.20 inside 192.168.1.2<\/p>\n<p><strong>\u67e5\u8be2NAT\u914d\u7f6e:<\/strong>\u00a0\u914d\u7f6e\u5b8c\u6210\u540e,\u4f7f\u7528display nat static \u547d\u4ee4\u53ef\u4ee5\u67e5\u8be2\u7aef\u53e3\u60c5\u51b5.<\/p>\n<p>[R1] display nat static<\/p>\n<p>Static Nat Information:<\/p>\n<p>Interface : GigabitEthernet0\/0\/1<\/p>\n<p>Global IP\/Port : 10.10.10.20\/&#8212;-<\/p>\n<p>Inside IP\/Port : 192.168.1.2\/&#8212;-<\/p>\n<p>Protocol : &#8212;-<\/p>\n<p>VPN instance-name : &#8212;-<\/p>\n<p>Acl number : &#8212;-<\/p>\n<p>Netmask : 255.255.255.255<\/p>\n<p>Description : &#8212;-<\/p>\n<p>Total : 1<\/p>\n<p><strong>\u6d4b\u8bd5\u901a\u4fe1\u60c5\u51b5:<\/strong>\u00a0\u6b64\u65f6\u5728PC1\u4e3b\u673a\u53efPing\u901aR2\u8def\u7531\u5668.<\/p>\n<p>PC1&gt; ping 10.10.10.2<\/p>\n<p>Ping 10.10.10.2: 32 data bytes, Press Ctrl_C to break<\/p>\n<p>From 10.10.10.2: bytes=32 seq=1 ttl=254 time=47 ms<\/p>\n<p>&#8212; 10.10.10.2 ping statistics &#8212;<\/p>\n<p>1 packet(s) transmitted<\/p>\n<p>1 packet(s) received<\/p>\n<p>0.00% packet loss<\/p>\n<p>round-trip min\/avg\/max = 47\/47\/47 ms<\/p>\n<p>&nbsp;<\/p>\n<h3>\u25c6\u914d\u7f6e\u52a8\u6001NAT\u25c6<\/h3>\n<p>\u52a8\u6001NAT\u662f\u6307\u5185\u90e8\u672c\u5730\u5730\u5740\u4e0e\u5185\u90e8\u5168\u5c40\u5730\u5740\u8fdb\u884c\u8f6c\u6362\u65f6,\u5185\u90e8\u5730\u5740\u53ef\u4ee5\u968f\u673a\u8f6c\u6362\u4e3a\u6307\u5b9a\u7684\u5916\u90e8\u5168\u5c40\u5730\u5740,\u6b64\u8fc7\u7a0b\u662f\u52a8\u6001\u5206\u914d\u7684\u4e0d\u9700\u8981\u8ba4\u4e3a\u5e72\u9884,\u4ece\u800c\u51cf\u5c11\u4e86\u914d\u7f6e\u7684\u5de5\u4f5c\u91cf.<\/p>\n<p>\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f,\u914d\u7f6e\u52a8\u6001NAT\u53ea\u80fd\u5b9e\u73b0\u5185\u90e8\u7f51\u7edc\u5bf9\u4e92\u8054\u7f51\u7684\u8bbf\u95ee,\u65e0\u6cd5\u5b9e\u73b0\u4e92\u8054\u7f51\u4e2d\u7684\u4e3b\u673a\u5bf9\u5185\u90e8\u7f51\u7edc\u4e2d\u7684\u4e3b\u673a\u7684\u8bbf\u95ee,\u5b83\u662f\u4e00\u79cd\u5355\u5411\u7684NAT\u6280\u672f.<\/p>\n<p>\u52a8\u6001NAT\u662f\u5728\u51fa\u53e3\u8def\u7531\u5668\u4e0a\u505a\u4e86\u4e00\u4e2a\u5730\u5740\u6c60,\u5185\u7f51PC\u8bbf\u95ee\u5916\u7f51\u65f6\u4f1a\u4ece\u5730\u5740\u6c60\u5185\u83b7\u53d6\u4e00\u4e2a\u516c\u7f51IP,\u6b64\u79cd\u6280\u672f\u4e5f\u65e0\u6cd5\u8282\u7ea6\u516c\u7f51IP\u5730\u5740\u8d44\u6e90,\u63a5\u4e0b\u6765\u8fd8\u662f\u4f7f\u7528\u4e0a\u9762\u7684\u62d3\u6251\u56fe,\u4f46\u9700\u8981\u6e05\u7a7a\u89c4\u5219.<\/p>\n<p><strong>\u914d\u7f6e\u8def\u7531\u5668:<\/strong>\u00a0\u914d\u7f6e\u8def\u7531\u5668,\u5f00\u542fR1\u8def\u7531\u5668\u7684Eth0\/0\/0\u548cSer0\/0\/0\u7aef\u53e3,\u5e76\u914d\u7f6e\u4e0a\u7f51\u5173\u5730\u5740.<\/p>\n<p># &#8212;-\u914d\u7f6eR1\u8def\u7531\u5668&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>&lt;R1&gt; system-view<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/0<\/p>\n<p>[R1-GigabitEthernet0\/0\/0] ip address 192.168.1.1 255.255.255.0<\/p>\n<p>[R1-Ethernet0\/0\/0] quit<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] ip address 10.10.10.1 255.0.0.0<\/p>\n<p>[R1-Ethernet0\/0\/0] quit<\/p>\n<p># &#8212;-\u914d\u7f6eR2\u8def\u7531\u5668&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>&lt;R2&gt; system-view<\/p>\n<p>[R2] interface GigabitEthernet 0\/0\/0<\/p>\n<p>[R2-GigabitEthernet0\/0\/0] ip address 10.10.10.2 255.0.0.0<\/p>\n<p>[R2-Ethernet0\/0\/0] quit<\/p>\n<p><strong>\u914d\u7f6e\u52a8\u6001NAT:<\/strong>\u00a0\u5728\u8def\u7531\u5668R1\u4e0a\u914d\u7f6e\u52a8\u6001NAT,\u5c06\u79c1\u6709\u5730\u5740\u8f6c\u4e3a\u5168\u5c40\u5730\u5740(\u5185\u7f51\u5730\u5740&#8211;&gt;\u5916\u7f51\u5730\u5740).<\/p>\n<p>[R1] nat address-group 1 10.10.10.20 10.10.10.40 \/\/ \u521b\u5efa\u516c\u7f51\u5730\u5740\u6c60<\/p>\n<p>[R1] acl 2000 \/\/ \u5b9a\u4e49\u8bbf\u95ee\u63a7\u5236\u5217\u8868<\/p>\n<p>[R1-acl-basic-2000] rule permit source 192.168.1.0 0.0.0.255 \/\/ \u5b9a\u4e49ACL\u5217\u8868<\/p>\n<p>[R1-acl-basic-2000] quit<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/1<\/p>\n<p>\/\/ \u5c06ACL\u4e0e\u5730\u5740\u6c60\u5173\u8054,no-pat\u8868\u793a\u4e0d\u53ef\u53cd\u590d\u4f7f\u7528<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] nat outbound 2000 address-group 1 no-pat<\/p>\n<p>\/\/ \u5c06ACL\u4e0e\u5730\u5740\u6c60\u5173\u8054,\u53ef\u53cd\u590d\u4f7f\u7528<\/p>\n<p>[R1-GigabitEthernet0\/0\/1] nat outbound 2000 address-group 1<\/p>\n<p><strong>\u62d3\u5c55(\u7aef\u53e3\u6620\u5c04):<\/strong>\u00a0\u5c06\u5185\u7f51\u7684192.168.1.1:8080\u6620\u5c04\u5230\u5916\u7f51\u768410.10.10.1:80,\u914d\u7f6e\u5982\u4e0b.<\/p>\n<p>[R1] interface GigabitEthernet 0\/0\/1<\/p>\n<p>[R1] nat server protocol tcp global 10.10.10.1 80 inside 192.168.1.1 8080<\/p>\n<p><strong>\u6d4b\u8bd5\u901a\u4fe1\u60c5\u51b5:<\/strong>\u00a0\u6b64\u65f6\u5728PC1\u4e3b\u673a\u53efPing\u901aR2\u8def\u7531\u5668.<\/p>\n<p>PC1&gt; ping 10.10.10.2<\/p>\n<p>Ping 10.10.10.2: 32 data bytes, Press Ctrl_C to break<\/p>\n<p>From 10.10.10.2: bytes=32 seq=1 ttl=254 time=47 ms<\/p>\n<p>&#8212; 10.10.10.2 ping statistics &#8212;<\/p>\n<p>1 packet(s) transmitted<\/p>\n<p>1 packet(s) received<\/p>\n<p>0.00% packet loss<\/p>\n<p>round-trip min\/avg\/max = 47\/47\/47 ms<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NAT \u7f51\u7edc\u5730\u5740\u8f6c\u6362(Network Address Translation),\u662f\u4e00\u4e2a\u4e92\u8054\u7f51\u5de5\u7a0b\u4efb\u52a1\u7ec4\u7684\u6807\u51c6, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-2566","post","type-post","status-publish","format-standard","hentry","category-hw"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2566"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2566\/revisions"}],"predecessor-version":[{"id":2569,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2566\/revisions\/2569"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}