{"id":174946,"date":"2020-03-25T15:46:22","date_gmt":"2020-03-25T07:46:22","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=174946"},"modified":"2020-03-24T12:16:31","modified_gmt":"2020-03-24T04:16:31","slug":"network-address-translation","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/network-address-translation.html","title":{"rendered":"\u7f51\u7edc\u5730\u5740\u8f6c\u6362 NAT \u914d\u7f6e"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u6863\u8be6\u7ec6\u4ecb\u7ecd\u7f51\u7edc\u5730\u5740\u8f6c\u6362 NAT \u914d\u7f6e<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5b9e\u9a8c\u76ee\u6807<\/strong><\/div>\n

\u7406\u89e3 NAT \u7f51\u7edc\u5730\u5740\u8f6c\u6362\u7684\u539f\u7406\u53ca\u529f\u80fd
\n\u638c\u63e1\u9759\u6001 NAT \u7684\u914d\u7f6e\uff0c\u5b9e\u73b0\u5c40\u57df\u7f51\u8bbf\u95ee\u4e92\u8054\u7f51<\/p>\n

\u5b9e\u9a8c\u80cc\u666f<\/strong><\/div>\n

\u4f60\u662f\u67d0\u516c\u53f8\u7684\u7f51\u7edc\u7ba1\u7406\u5458\uff0c\u6b32\u53d1\u5e03\u516c\u53f8\u7684 WWW \u670d\u52a1\u3002\u73b0\u8981\u6c42\u5c06\u5185\u7f51 Web \u670d\u52a1\u5668 IP\u5730\u5740\u6620\u5c04\u4e3a\u5168\u5c40 IP \u5730\u5740\uff0c\u5b9e\u73b0\u5916\u90e8\u7f51\u7edc\u53ef\u4ee5\u8bbf\u95ee\u516c\u53f8\u5185\u90e8 Web \u670d\u52a1\u5668\u3002<\/p>\n

\u6280\u672f\u539f\u7406<\/strong><\/div>\n

\u7f51\u7edc\u5730\u5740\u8f6c\u6362 NAT\uff08Network Address Translation\uff09\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u7c7b\u578b Internet \u63a5\u5165\u65b9\u5f0f\u548c\u5404\u79cd\u7c7b\u578b\u7684\u7f51\u7edc\u4e2d\u3002\u539f\u56e0\u5f88\u7b80\u5355\uff0cNAT \u4e0d\u4ec5\u5b8c\u7f8e\u5730\u89e3\u51b3\u4e86 IP \u5730\u5740\u4e0d\u8db3\u7684\u95ee\u9898\uff0c\u800c\u4e14\u8fd8\u80fd\u591f\u6709\u6548\u5730\u907f\u514d\u6765\u81ea\u7f51\u7edc\u5916\u90e8\u7684\u653b\u51fb\uff0c\u9690\u85cf\u5e76\u4fdd\u62a4\u7f51\u7edc\u5185\u90e8\u7684\u8ba1\u7b97\u673a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5185\u90e8 IP \u5730\u5740\u662f\u65e0\u6cd5\u88ab\u8def\u7531\u5230\u5916\u7f51\u7684\uff0c\u5185\u90e8\u4e3b\u673a 10.1.1.1 \u8981\u4e0e\u5916\u90e8 Internet\u901a\u4fe1\uff0cIP \u5305\u5230\u8fbe NAT \u8def\u7531\u5668\u65f6\uff0cIP \u5305\u5934\u7684\u6e90\u5730\u5740 10.1.1.1 \u88ab\u66ff\u6362\u6210\u4e00\u4e2a\u5408\u6cd5\u7684\u5916\u7f51 IP\uff0c\u5e76\u5728 NAT \u8f6c\u53d1\u8868\u4e2d\u4fdd\u5b58\u8fd9\u6761\u8bb0\u5f55\u3002\u5f53\u5916\u90e8\u4e3b\u673a\u53d1\u9001\u4e00\u4e2a\u5e94\u7b54\u5230\u5185\u7f51\u65f6\uff0cNAT \u8def\u7531\u5668\u6536\u5230\u540e\uff0c\u67e5\u770b\u5f53\u524d NAT \u8f6c\u6362\u8868\uff0c\u7528 10.1.1.1 \u66ff\u6362\u6389\u8fd9\u4e2a\u5916\u7f51\u5730\u5740\u3002NAT \u5c06\u7f51\u7edc\u5212\u5206\u4e3a\u5185\u90e8\u7f51\u7edc\u548c\u5916\u90e8\u7f51\u7edc\u4e24\u90e8\u5206\uff0c\u5c40\u57df\u7f51\u4e3b\u673a\u5229\u7528 NAT \u8bbf\u95ee\u7f51\u7edc\u65f6\uff0c\u662f\u5c06\u5c40\u57df\u7f51\u5185\u90e8\u7684\u672c\u5730\u5730\u5740\u8f6c\u6362\u4e3a\u5168\u5c40\u5730\u5740\uff08\u4e92\u8054\u7f51\u5408\u6cd5\u7684 IP \u5730\u5740\uff09\u540e\u8f6c\u53d1\u6570\u636e\u5305\uff1b<\/p>\n

NAT \u5206\u4e3a\u4e24\u79cd\u7c7b\u578b\uff1aNAT\uff08\u7f51\u7edc\u5730\u5740\u8f6c\u6362\uff09\u548c NAPT\uff08\u7f51\u7edc\u7aef\u53e3\u5730\u5740\u8f6c\u6362 IP \u5730\u5740\u5bf9\u5e94\u4e00\u4e2a\u5168\u5c40\u5730\u5740\uff09\u3002
\n\u9759\u6001 NAT\uff1a\u5b9e\u73b0\u5185\u90e8\u5730\u5740\u4e0e\u5916\u90e8\u5730\u5740\u4e00\u5bf9\u4e00\u7684\u6620\u5c04\u3002\u73b0\u5b9e\u4e2d\uff0c\u4e00\u822c\u90fd\u7528\u4e8e\u670d\u52a1\u5668\uff1b
\n\u52a8\u6001 NAT\uff1a\u5b9a\u4e49\u4e00\u4e2a\u5730\u5740\u6c60\uff0c\u81ea\u52a8\u6620\u5c04\uff0c\u4e5f\u662f\u4e00\u5bf9\u4e00\u7684\u3002\u73b0\u5b9e\u4e2d\uff0c\u7528\u5f97\u6bd4\u8f83\u5c11\uff1b
\nNAPT\uff1a\u4f7f\u7528\u4e0d\u540c\u7684\u7aef\u53e3\u6765\u6620\u5c04\u591a\u4e2a\u5185\u7f51 IP \u5730\u5740\u5230\u4e00\u4e2a\u6307\u5b9a\u7684\u5916\u7f51 IP \u5730\u5740\uff0c\u591a\u5bf9\u4e00\u3002<\/p>\n

\u5b9e\u9a8c\u6b65\u9aa4<\/strong><\/div>\n

\u65b0\u5efa Packet Tracer \u62d3\u6251\u56fe<\/p>\n

\"\"<\/p>\n

\uff081\uff09R1 \u4e3a\u516c\u53f8\u51fa\u53e3\u8def\u7531\u5668\uff0c\u5176\u4e0e\u5916\u90e8\u8def\u7531\u5668\u4e4b\u95f4\u901a\u8fc7 V.35 \u7535\u7f06\u4e32\u53e3\u8fde\u63a5\uff0cDCE \u7aef\u8fde\u63a5\u5728 R1 \u4e0a\uff0c\u914d\u7f6e\u5176\u65f6\u949f\u9891\u7387 64000\uff1b
\n\uff082\uff09\u914d\u7f6e PC \u673a\u3001\u670d\u52a1\u5668\u53ca\u8def\u7531\u5668\u63a5\u53e3 IP \u5730\u5740\uff1b
\n\uff083\uff09\u5728\u5404\u8def\u7531\u5668\u4e0a\u914d\u7f6e\u9759\u6001\u8def\u7531\u534f\u8bae\uff0c\u8ba9 PC \u95f4\u80fd\u76f8\u4e92 Ping \u901a\uff1b
\n\uff084\uff09\u5728 R1 \u4e0a\u914d\u7f6e\u9759\u6001 NAT\u3002
\n\uff085\uff09\u5728 R1 \u4e0a\u5b9a\u4e49\u5185\u5916\u7f51\u7edc\u63a5\u53e3\u3002
\n\uff086\uff09\u9a8c\u8bc1\u4e3b\u673a\u4e4b\u95f4\u7684\u4e92\u901a\u6027\u3002<\/p>\n

\u5b9e\u9a8c\u8bbe\u5907<\/strong><\/div>\n
PC 1 \u53f0\uff1bServer-PT 1 \u53f0\uff1bSwitch_2950-24 1 \u53f0\uff1bRouter-PT 2 \u53f0\uff1b\u76f4\u8fde\u7ebf\uff1b\u4ea4\u53c9\u7ebf\uff1bDCE\u4e32\u53e3\u7ebf\r\n\r\nServer-PT\r\n\r\n192.168.1.2\r\n255.255.255.0\r\n192.168.1.1\r\n\r\nPC0\r\n\r\n222.0.2.2\r\n255.255.255.0\r\n222.0.2.1\r\n\r\nR1\r\n\r\nen\r\nconf t\r\nhost R1\r\nint fa 0\/0\r\nip address 192.168.1.1 255.255.255.0\r\nno shutdown\r\nint s 2\/0\r\nip address 222.0.1.1 255.255.255.0\r\nno shutdown\r\nclock rate 64000\r\n\r\nR2\r\n\r\nen\r\nconf t\r\nhost R2\r\nint s 2\/0\r\nip address 222.0.1.2 255.255.255.0\r\nno shut\r\nint fa 0\/0\r\nip address 222.0.2.1 255.255.255.0\r\nno shutdown\r\n\r\nR1\r\n\r\nexit;\r\nip route 222.0.2.0 255.255.255.0 222.0.1.2\r\n\r\nR2\r\n\r\nexit\r\nip route 192.168.1.0 255.255.255.0 222.0.1.1\r\nend\r\nshow ip route\r\n\r\nPC0\r\n\r\nCMD\r\nping 192.168.1.2 (success)\r\n\r\nWeb \u6d4f\u89c8\u5668\r\nhttp:\/\/192.168.1.2 (success)\r\n<\/pre>\n

\"\"<\/p>\n

\r\nR1\r\nint fa 0\/0\r\nip nat inside\r\nint s 2\/0\r\nip nat outside\r\nexit\r\nip nat inside source static 192.168.1.2 222.0.1.3\r\nend\r\nshow ip nat translations\r\n\r\nPC0\r\n\r\nWeb \u6d4f\u89c8\u5668\r\nhttp:\/\/222.0.1.3 (success)\r\n<\/pre>\n

\"\"<\/p>\n

\r\nR1\r\nshow ip nat translations\r\n<\/pre>\n
\u5b9e\u6218\u6f14\u7ec3<\/strong><\/div>\n
R1\r\n\r\nContinue with configuration dialog? [yes\/no]: n\r\n\r\n\r\nPress RETURN to get started!\r\n\r\n\r\n\r\nRouter>en\r\nRouter#conf t\r\nEnter configuration commands, one per line.  End with CNTL\/Z.\r\nRouter(config)#hostname R1\r\nR1(config)#int fa 0\/0\r\nR1(config-if)#ip add 192.168.1.1 255.255.255.0\r\nR1(config-if)#no shut\r\n\r\nR1(config-if)#\r\n%LINK-5-CHANGED: Interface FastEthernet0\/0, changed state to up\r\n\r\nR1(config-if)#int s 2\/0\r\nR1(config-if)#ip add 222.0.1.1 255.255.255.0\r\nR1(config-if)#no shut\r\n\r\n%LINK-5-CHANGED: Interface Serial2\/0, changed state to down\r\nR1(config-if)#clock rate 64000\r\nR1(config-if)#\r\n\r\nR2\r\n\r\nContinue with configuration dialog? [yes\/no]: n\r\n\r\n\r\nPress RETURN to get started!\r\n\r\n\r\n\r\nRouter>en\r\nRouter#conf t\r\nEnter configuration commands, one per line.  End with CNTL\/Z.\r\nRouter(config)#host R2\r\nR2(config)#int s 2\/0\r\nR2(config-if)#ip add 222.0.1.2 255.255.255.0\r\nR2(config-if)#no shut\r\n\r\n%LINK-5-CHANGED: Interface Serial2\/0, changed state to up\r\n\r\nR2(config-if)#int fa 0\/0\r\nR2(config-if)#ip add 222.0.2.1 255.255.255.0\r\nR2(config-if)#no shut\r\n\r\n%LINK-5-CHANGED: Interface FastEthernet0\/0, changed state to up\r\n\r\n%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0\/0, changed state to up\r\n\r\nR2(config-if)#\r\n\r\n\r\nR1\r\n\r\nR1(config-if)#exit\r\nR1(config)#\r\nR1(config)#ip route 222.0.2.0 255.255.255.0 222.0.1.2\r\n\r\nR2\r\n\r\nR2(config-if)#exit\r\nR2(config)#\r\nR2(config)#ip route 192.168.1.0 255.255.255.0 222.0.1.1\r\nR2(config)#end\r\nR2#\r\n%SYS-5-CONFIG_I: Configured from console by console\r\n\r\nR2#show ip route\r\nCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP\r\n       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area\r\n       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2\r\n       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP\r\n       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area\r\n       * - candidate default, U - per-user static route, o - ODR\r\n       P - periodic downloaded static route\r\n\r\nGateway of last resort is not set\r\n\r\nS    192.168.1.0\/24 [1\/0] via 222.0.1.1\r\nC    222.0.1.0\/24 is directly connected, Serial2\/0\r\nC    222.0.2.0\/24 is directly connected, FastEthernet0\/0\r\nR2#\r\n\r\nPC0\r\n\r\nCMD  ping 192.168.1.2 (success)\r\n\r\nPC>ipconfig\r\n\r\nIP Address......................: 222.0.2.2\r\nSubnet Mask.....................: 255.255.255.0\r\nDefault Gateway.................: 222.0.2.1\r\n\r\nPC>ping 192.168.1.2\r\n\r\nPinging 192.168.1.2 with 32 bytes of data:\r\n\r\nRequest timed out.\r\nReply from 192.168.1.2: bytes=32 time=19ms TTL=126\r\nReply from 192.168.1.2: bytes=32 time=18ms TTL=126\r\nReply from 192.168.1.2: bytes=32 time=23ms TTL=126\r\n\r\nPing statistics for 192.168.1.2:\r\n    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),\r\nApproximate round trip times in milli-seconds:\r\n    Minimum = 18ms, Maximum = 23ms, Average = 20ms\r\n\r\nPC>ping 192.168.1.2\r\n\r\nPinging 192.168.1.2 with 32 bytes of data:\r\n\r\nReply from 192.168.1.2: bytes=32 time=26ms TTL=126\r\nReply from 192.168.1.2: bytes=32 time=26ms TTL=126\r\nReply from 192.168.1.2: bytes=32 time=22ms TTL=126\r\nReply from 192.168.1.2: bytes=32 time=23ms TTL=126\r\n\r\nPing statistics for 192.168.1.2:\r\n    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),\r\nApproximate round trip times in milli-seconds:\r\n    Minimum = 22ms, Maximum = 26ms, Average = 24ms\r\n\r\nPC>\r\n\r\nWeb \u6d4f\u89c8\u5668\r\nhttp:\/\/192.168.1.2 (success)\r\n\r\n\r\nR1\r\n\r\nR1>en\r\nR1#conf t\r\nEnter configuration commands, one per line.  End with CNTL\/Z.\r\nR1(config)#int fa 0\/0\r\nR1(config-if)#ip nat inside\r\nR1(config-if)#int s 2\/0\r\nR1(config-if)#ip nat outside\r\nR1(config-if)#exit\r\nR1(config)#ip nat inside source static 192.168.1.2 222.0.1.3\r\nR1(config)#end\r\nR1#\r\n%SYS-5-CONFIG_I: Configured from console by console\r\n\r\nR1#show ip nat translations\r\nPro  Inside global     Inside local       Outside local      Outside global\r\n---  222.0.1.3         192.168.1.2        ---                ---\r\n\r\nR1#\r\n\r\nPC0\r\nWeb \u6d4f\u89c8\u5668\r\nhttp:\/\/222.0.1.3 (success)\r\n\r\nCMD ping 222.0.1.3\r\n\r\nPC>ipconfig\r\n\r\nIP Address......................: 222.0.2.2\r\nSubnet Mask.....................: 255.255.255.0\r\nDefault Gateway.................: 222.0.2.1\r\n\r\nPC>ping 222.0.1.3\r\n\r\nPinging 222.0.1.3 with 32 bytes of data:\r\n\r\nReply from 222.0.1.3: bytes=32 time=21ms TTL=126\r\nReply from 222.0.1.3: bytes=32 time=22ms TTL=126\r\nReply from 222.0.1.3: bytes=32 time=23ms TTL=126\r\nReply from 222.0.1.3: bytes=32 time=23ms TTL=126\r\n\r\nPing statistics for 222.0.1.3:\r\n    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),\r\nApproximate round trip times in milli-seconds:\r\n    Minimum = 21ms, Maximum = 23ms, Average = 22ms\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u7406\u89e3 NAT \u7f51\u7edc\u5730\u5740\u8f6c\u6362\u7684\u539f\u7406\u53ca\u529f\u80fd \u638c\u63e1\u9759\u6001 NAT \u7684\u914d\u7f6e\uff0c\u5b9e\u73b0\u5c40\u57df\u7f51\u8bbf\u95ee\u4e92\u8054\u7f51 \u4f60\u662f\u67d0\u516c\u53f8\u7684\u7f51\u7edc\u7ba1\u7406\u5458 […]<\/p>\n","protected":false},"author":63,"featured_media":174947,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-174946","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/174946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=174946"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/174946\/revisions"}],"predecessor-version":[{"id":175357,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/174946\/revisions\/175357"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/174947"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=174946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=174946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=174946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}