Pc0:
ip地址:192.168.1.2
子网掩码:255.255.255.0
默认网关:192.168.1.1
Pc1:
ip地址:192.168.1.3
子网掩码:255.255.255.0
默认网关:192.168.1.1
Pc2:
ip地址:192.168.1.4
子网掩码:255.255.255.0
默认网关:192.168.1.1
 

Router0
Router>enable
Router#configure terminal
Router(config)#hostname router0
router0(config)#interface fastEthernet 0/0
router0(config-if)#ip address 192.168.1.1 255.255.255.0
router0(config-if)#no shutdown
router0(config-if)#exit
router0(config)#interface fastEthernet 0/1
router0(config-if)#ip address 202.98.38.1 255.255.255.0
router0(config-if)#no shutdown
router0(config-if)#exit
router0(config)#router rip
router0(config-router)#version 2
router0(config-router)#no auto-summary
 
 
router0(config-router)#network 202.98.38.0
router0(config-router)#network 192.168.1.0
router0(config-if)#exit
router0(config)#ip nat inside source static 192.168.1.2 202.98.38.2
router0(config)#ip nat inside source static 192.168.1.3 202.98.38.3
router0(config)#ip nat inside source static 192.168.1.4 202.98.38.4
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
router0(config-if)#end
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.98.38.5 255.255.255.0
router1(config-if)#no shutdown
router1(config-if)#exit
router1(config)#interface loopback 0
router1(config-if)#ip address 2.2.2.2 255.255.255.0
router1#configure terminal
router1(config)#router rip
router1(config-router)#version 2
router1(config-router)#no auto-summary
router1(config-router)#network 2.2.2.0
router1(config-router)#network 202.98.38.0
 
Pc0上用ping 2.2.2.2ping通之后在Router0上可查看到(用router0#debug ip nat
命令):
NAT: s=192.168.1.2->202.98.38.2, d=2.2.2.2[0]
NAT: s=192.168.1.2->202.98.38.2, d=2.2.2.2[0]
NAT*: s=2.2.2.2, d=202.98.38.2->192.168.1.2[0]
NAT: s=192.168.1.2->202.98.38.2, d=2.2.2.2[0]
 
Pc1上用ping 2.2.2.2ping通之后在Router0上可查看到(用router0#debug ip nat
命令):
NAT: s=192.168.1.3->202.98.38.3, d=2.2.2.2[0]
NAT*: s=2.2.2.2, d=202.98.38.3->192.168.1.3[0]
NAT: s=192.168.1.3->202.98.38.3, d=2.2.2.2[0]
NAT*: s=2.2.2.2, d=202.98.38.3->192.168.1.3[0]
 
Pc2上用ping 2.2.2.2ping通之后在Router0上可查看到(用router0#debug ip nat
命令):
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[0]
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[0]
NAT*: s=2.2.2.2, d=202.98.38.4->192.168.1.4[0]
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[0]
NAT*: s=2.2.2.2, d=202.98.38.4->192.168.1.4[0]
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[0]
NAT*: s=2.2.2.2, d=202.98.38.4->192.168.1.4[0]