实验环境:两台cisco路由器,一台作为企业内部和外部的接口,另一路由器作为外网的路由器,在外网上有一台htt服务器。
 
本实验目的:让内网计算机通过一路由器的NAT功能实现访问外网的http服务器
 
企业内部路由器(router0)的配置如下:
Router#show running-config
Building configuration...
Current configuration : 837 bytes
!
version 12.2
no service password-encryption
!
hostname Router
!
!
!
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
 ip address 192.168.0.1 255.255.255.0
 ip nat inside                             #nat的内部接口
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial1/0
 ip address 172.0.0.1 255.255.0.0
  ip nat outside                        #nat的外部接口
 clock rate 64000
!
interface Serial1/1
 no ip address
 shutdown
!
interface Serial1/2
 no ip address
 shutdown
!
interface Serial1/3
 no ip address
 shutdown
!
router ospf 100                                     # 配置ospf路由协议
 log-adjacency-changes
 network 192.168.0.0 0.0.0.255 area 0
 network 172.0.0.0 0.0.255.255 area 0
!
ip nat pool wan 172.0.0.10 172.0.0.10 netmask 255.255.0.0          #配置nat的地址池
ip nat inside source list 1 pool wan overload       #把符合访问控制列表1中的网络转换
ip classless                                                                    成地址池中的网络
!
!
access-list 1 permit 192.168.0.0 0.0.0.255     #允许访问外网的网络
!
!
!
line con 0
line vty 0 4
 login
!
!
end
 
router1的配置如下:
Router#show running-config
Building configuration...
Current configuration : 678 bytes
!
version 12.4
no service password-encryption
!
hostname Router
!
!
!
!
!
ip ssh version 1
!
!
interface FastEthernet0/0
 ip address 10.0.0.1 255.0.0.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial1/0
 ip address 172.0.0.2 255.255.0.0
!
interface Serial1/1
 no ip address
 shutdown
!
interface Serial1/2
 no ip address
 shutdown
!
interface Serial1/3
 no ip address
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 200
 log-adjacency-changes
 network 10.0.0.0 0.255.255.255 area 0
 network 172.0.0.0 0.0.255.255 area 0
!
ip classless
!
!
!
!
!
line con 0
line vty 0 4
 login
!
!
end
在router1中的配置就简单了,就是ip配置,ospf路由协议的配置就行了。
 
然后进行ip nat的调试:debug  ip  nat
在内网的主机上访问外网的http服务器时在路由器上通过debug  ip   nat看到的内容
Router#debug ip nat
IP NAT debugging is on
Router#
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]
NAT*: s=10.0.0.10, d=172.0.0.10->192.168.0.10[1]
NAT: s=192.168.0.10->172.0.0.10, d=10.0.0.10[1]