pc0:
ip地址:192.168.1.33
子网掩码:255.255.255.224
默认网关:192.168.1.63
pc1:
ip地址:192.168.1.34
子网掩码:255.255.255.224
默认网关:192.168.1.63
对Router0配置:
Router>enable
Router#configure terminal
Router(config)#hostname Router0
Router0(config)#interface fastEthernet 0/0
Router0(config-if)#ip address 192.168.1.63 255.255.255.224
Router0(config-if)#no shutdown
Router0(config-if)#exit
Router0(config)#interface fastEthernet 0/1
Router0(config-if)#ip address 202.96.1.1 255.255.255.0
Router0(config-if)#no shutdown
//配置动态路由
Router0(config)#router rip
Router0(config-router)#version 2
Router0(config-router)#no auto-summary
Router0(config-router)#network 192.168.1.32
Router0(config-router)#network 202.96.1.0
Router0(config-router)#exit
//配置内部全局地址池
Router0(config)#ip nat pool ceshi 200.100.1.1 200.100.1.100 netmask 255.255.255.0
//配置允许地址转换的内部本地地址范围
Router0(config)#access-list 1 permit 192.168.1.33 0.0.0.31
//配置本地地址与全局地址的映射关系
Router0(config)#ip nat inside source list 1 pool ceshi overload

Router0(config)#interface fastEthernet 0/0
//配置为内部接口
Router0(config-if)#ip nat inside
Router0(config-if)#exit
Router0(config)#interface fastEthernet 0/1
//配置为外部接口
Router0(config-if)#ip nat outside
//查看ping后的结果
Router0#debug ip nat
对Router1配置:
Router>enable
Router#configure terminal
Router(config)#hostname Router1
Router1(config)#interface fastEthernet 0/1
Router1(config-if)#ip address 202.96.1.2 255.255.255.0
Router1(config-if)#no shutdown
Router1(config-if)#exit
//配置loopback 0是为了测试能否ping通,它的作用相当于一台主机。
Router1(config)#interface loopback 0
Router1(config-if)#ip address 2.2.2.2 255.255.255.0
Router1(config)#router rip
Router1(config-router)#version 2
Router1(config-router)#no auto-summary
Router1(config-router)#network 202.96.1.0
Router1(config-router)#network 2.2.2.0
Router1(config-router)#end
 
在pc0上ping 2.2.2.2之后再查看Router0,结果如下:
Router0#debug ip nat
IP NAT debugging is on
Router0#
NAT: s=192.168.1.1->202.96.1.3, d=2.2.2.2[9]
NAT*: s=2.2.2.2, d=202.96.1.3->192.168.1.1[9]
NAT: s=192.168.1.1->202.96.1.3, d=2.2.2.2[10]
NAT*: s=2.2.2.2, d=202.96.1.3->192.168.1.1[10]
NAT: s=192.168.1.1->202.96.1.3, d=2.2.2.2[11]
NAT*: s=2.2.2.2, d=202.96.1.3->192.168.1.1[11]
NAT: s=192.168.1.1->202.96.1.3, d=2.2.2.2[12]
NAT*: s=2.2.2.2, d=202.96.1.3->192.168.1.1[12]
NAT: expiring 202.96.1.3 (192.168.1.1) 1 17 (17)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 18 (18)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 19 (19)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 20 (20)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 21 (21)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 22 (22)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 23 (23)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 24 (24)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 25 (25)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 26 (26)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 27 (27)
NAT: expiring 202.96.1.3 (192.168.1.1) 1 28 (28)