问题 在R1通过PAT配置实现企业内网192.168.0.0/24复用f0/1端口 方案 网络拓扑如图-3所示: 图-3 步骤 实现此案例需要按照如下步骤进行。 步骤一:基于端口的PAT配置限制 1)删除动态NAT配置 tarena-R1(config)#no ip nat inside source list 1 tarena-R1(config)#no ip nat pool natpool tarena-R1(config)#no access-list 1 2)在R1上配置包括内网所有IP地址的ACL tarena-R1(config)#access-list 1 permit 192.168.0.0 0.0.0.255 3)关联ACL和路由器连接互联网的端口 该命令最后加上的overload表示复用。 tarena-R1(config)#ip nat inside source list 1 interface f0/1 overload 4)在R1上配置NAT内、外端口 tarena-R1(config)#interface f0/0 tarena-R1(config-if)#ip nat inside tarena-R1(config-if)#interface f0/1 tarena-R1(config-if)#ip nat outside 5)分别在两台PC机上测试到外网主机的通信 PC1测试如下所示: PC>ipconfig FastEthernet0 Connection:(default port) Link-local IPv6 Address…: FE80::2E0:F7FF:FED6:54CC IP Address…: 192.168.0.10 Subnet Mask…: 255.255.255.0 Default Gateway…: 192.168.0.1 PC>ping 200.1.1.10 Pinging 200.1.1.10 with 32 bytes of data: Reply from 200.1.1.10: bytes=32 time=1ms TTL=126 Reply from 200.1.1.10: bytes=32 time=0ms TTL=126 Reply from 200.1.1.10: bytes=32 time=1ms TTL=126 Reply from 200.1.1.10: bytes=32 time=0ms TTL=126 Ping statistics for 200.1.1.10: Packets: Sent = 4, Received = 2, Lost = 2 (50% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms PC> PC2测试如下所示: PC>ipconfig FastEthernet0 Connection:(default port) Link-local IPv6 Address…: FE80::2D0:BAFF:FE98:9E29 IP Address…: 192.168.0.20 Subnet Mask…: 255.255.255.0 Default Gateway…: 192.168.0.1 PC>ping 200.1.1.10 Pinging 200.1.1.10 with 32 bytes of data: Reply from 200.1.1.10: bytes=32 time=0ms TTL=126 Reply from 200.1.1.10: bytes=32 time=1ms TTL=126 Reply from 200.1.1.10: bytes=32 time=0ms TTL=126 Reply from 200.1.1.10: bytes=32 time=1ms TTL=126 Ping statistics for 200.1.1.10: Packets: Sent = 4, Received = 2, Lost = 2 (50% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms PC> 6)在R1上查看NAT转换表 tarena-R1#show ip nat translations Pro Inside global Inside local Outside local Outside global icmp 201.1.1.1:25 192.168.0.10:25 200.1.1.10:25 200.1.1.10:25 icmp 201.1.1.1:26 192.168.0.10:26 200.1.1.10:26 200.1.1.10:26 icmp 201.1.1.1:27 192.168.0.10:27 200.1.1.10:27 200.1.1.10:27 icmp 201.1.1.1:28 192.168.0.10:28 200.1.1.10:28 200.1.1.10:28 icmp 201.1.1.1:1024 192.168.0.20:25 200.1.1.10:25 200.1.1.10:1024 icmp 201.1.1.1:1025 192.168.0.20:26 200.1.1.10:26 200.1.1.10:1025 icmp 201.1.1.1:1026 192.168.0.20:27 200.1.1.10:27 200.1.1.10:1026 icmp 201.1.1.1:1027 192.168.0.20:28 200.1.1.10:28 200.1.1.10:1027 输出结果显示,所有的内网IP地址在访问外网前均被转换成了路由器端口的IP地址
