配置动态NAT(案例)

问题
在R1通过动态NAT实现企业内网192.168.0.0/24转换为公网地址201.1.1.2-201.1.1.5,访问200.1.1.10
方案
网络拓扑如图-2所示:

图-2在这里插入图片描述
步骤
实现此案例需要按照如下步骤进行。
步骤一:动态NAT配置
1)删除静态NAT配置
tarena-R1(config)#no ip nat inside source static 192.168.0.10 201.1.1.2
tarena-R1(config)#no ip nat inside source static 192.168.0.20 201.1.1.3
2)在R1上配置包括内网所有IP地址的ACL
tarena-R1(config)#access-list 1 permit 192.168.0.0 0.0.0.255
3)在R1上配置合法的IP地址池
地址池是向ISP(Internet服务提供商,如电信、联通)申请得到的,内网主机(上一步ACL中所包含的IP地址)到外网的访问,内网地址将被动态的、随机的转换为这些合法地址。
tarena-R1(config)#ip nat pool natpool 201.1.1.2 201.1.1.5 netmask 255.255.255.0
4)关联ACL和合法的IP地址池
tarena-R1(config)#ip nat inside source list 1 pool natpool
5)在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
6)分别在两台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>
7)在R1上查看NAT转换表
转换表中的对应关系是动态的,如192.168.0.10被转换为201.1.1.2,但是下一次对外网的访问很有可能被转换为其他地址。
tarena-R1#show ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 201.1.1.2:21 192.168.0.10:21 200.1.1.10:21 200.1.1.10:21
icmp 201.1.1.2:22 192.168.0.10:22 200.1.1.10:22 200.1.1.10:22
icmp 201.1.1.2:23 192.168.0.10:23 200.1.1.10:23 200.1.1.10:23
icmp 201.1.1.2:24 192.168.0.10:24 200.1.1.10:24 200.1.1.10:24
icmp 201.1.1.3:21 192.168.0.20:21 200.1.1.10:21 200.1.1.10:21
icmp 201.1.1.3:22 192.168.0.20:22 200.1.1.10:22 200.1.1.10:22
icmp 201.1.1.3:23 192.168.0.20:23 200.1.1.10:23 200.1.1.10:23
icmp 201.1.1.3:24 192.168.0.20:24 200.1.1.10:24 200.1.1.10:24

猜你喜欢

转载自blog.csdn.net/xiaozhedeitzhilu/article/details/90604950