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)#ip nat pool ceshi 202.98.38.2 202.98.38.4 netmask 255.255.255.0
router0(config)#access-list 1 permit 192.168.1.0 0.0.0.255
router0(config)#ip nat inside source list 1 pool ceshi
router0(config)#interface fastEthernet 0/0
router0(config-if)#ip address 192.168.1.1 255.255.255.0
router0(config-if)#ip nat inside
router0(config-if)#no shutdown
router0(config-if)#exit
router0(config)#interface f0/1
router0(config-if)#ip address 202.98.38.1 255.255.255.0
router0(config-if)#ip nat outside
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 192.168.1.0
router0(config-router)#network 202.98.38.0
router0(config-router)#end
router0#debug ip routing
 
 
Router>enable
Router#configure terminal
Router(config)#hostname router1
router1(config)#interface fastEthernet 0/0
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(config-if)#exit
router1(config)#router rip
router1(config-router)#version 2
router1(config-router)#no auto-summary
router1(config-router)#network 202.98.38.0
router1(config-router)#network 2.2.2.2
 
 
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[1]
NAT*: s=2.2.2.2, d=202.98.38.2->192.168.1.2[1]
NAT: s=192.168.1.2->202.98.38.2, d=2.2.2.2[1]
NAT*: s=2.2.2.2, d=202.98.38.2->192.168.1.2[1]
Pc1上用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[1]
NAT*: s=2.2.2.2, d=202.98.38.2->192.168.1.2[1]
NAT: s=192.168.1.2->202.98.38.2, d=2.2.2.2[1]
NAT*: s=2.2.2.2, d=202.98.38.2->192.168.1.2[1]
Pc2上用ping 2.2.2.2ping通之后在Router0上可查看到(用router0#debug ip nat
命令):
NNAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[3]
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[3]
NAT*: s=2.2.2.2, d=202.98.38.4->192.168.1.4[3]
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[3]
NAT*: s=2.2.2.2, d=202.98.38.4->192.168.1.4[3]
NAT: s=192.168.1.4->202.98.38.4, d=2.2.2.2[3]
NAT*: s=2.2.2.2, d=202.98.38.4->192.168.1.4[3]