拓扑图:
配置参数:
r2(config)#acc 1 per 12.1.1.3 0.0.0.0 //配置服务器的公网IP
r2(config)#ip nat po 1 192.168.1.2 192.168.1.3 net 255.255.255.0 type rotary //配置服务器的内网地址范围
r2(config)#ip nat inside destination list 1 pool 1 //配置目标NAT转换
r2(config)#end
测试:
r1#ping 12.1.1.1
Sending 5, 100-byte ICMP Echos to 12.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/48/80 ms
r1#ping 12.1.1.2
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/39/64 ms
r1#telnet 12.1.1.3
Trying 12.1.1.3 ... Open
Username: r3
Password:
r3#sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.2     YES manual up                    up     
r3#exi
r1#telnet 12.1.1.3
Trying 12.1.1.3 ... Open
Username: r4
Password:
r4#sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.3     YES manual up                    up     
r4#exi
r1#
r2#sh ip na tr
Pro Inside global      Inside local       Outside local      Outside global
tcp 12.1.1.3:23        192.168.1.2:23     12.1.1.1:11000     12.1.1.1:11000
tcp 12.1.1.3:23        192.168.1.3:23     12.1.1.1:11001     12.1.1.1:11001
r2#
下面是各设备的配置文件:
r3#sh run
Building configuration...
 
Current configuration : 686 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r3
!
boot-start-marker
boot-end-marker
!
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
no ip routing
!
!
no ip cef
!
!
ip ips po max-events 100
no ftp-server write-enable
!
!
!
!
!
!
!
!
!
!
!
!
!
!
username r3 privilege 15 password 0 abc
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 192.168.1.2 255.255.255.0
 no ip route-cache
 duplex auto
 speed auto
!
ip default-gateway 192.168.1.1
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!        
!
line con 0
line aux 0
line vty 0 4
 login local
!
!
end
 
r3# 
r4#sh run
Building configuration...
 
Current configuration : 686 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r4
!
boot-start-marker
boot-end-marker
!
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
no ip routing
!
!
no ip cef
!
!
ip ips po max-events 100
no ftp-server write-enable
!
!
!
!
!
!
!
!
!
!
!
!
!
!
username r4 privilege 15 password 0 abc
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 192.168.1.3 255.255.255.0
 no ip route-cache
 duplex auto
 speed auto
!
ip default-gateway 192.168.1.1
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!        
!
line con 0
line aux 0
line vty 0 4
 login local
!
!
end
 
r4# 
r5#sh run
Building configuration...
 
Current configuration : 1332 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r5
!
boot-start-marker
boot-end-marker
!
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
ip cef
!
!
ip ips po max-events 100
no ftp-server write-enable
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
!        
interface FastEthernet0/0
 no ip address
!        
interface FastEthernet0/1
 no ip address
!        
interface FastEthernet0/2
 no ip address
!
interface FastEthernet0/3
 no ip address
 shutdown
!
interface FastEthernet0/4
 no ip address
 shutdown
!
interface FastEthernet0/5
 no ip address
 shutdown
!
interface FastEthernet0/6
 no ip address
 shutdown
!
interface FastEthernet0/7
 no ip address
 shutdown
!
interface FastEthernet0/8
 no ip address
 shutdown
!
interface FastEthernet0/9
 no ip address
 shutdown
!
interface FastEthernet0/10
 no ip address
 shutdown
!
interface FastEthernet0/11
 no ip address
 shutdown
!
interface FastEthernet0/12
 no ip address
 shutdown
!
interface FastEthernet0/13
 no ip address
 shutdown
!
interface FastEthernet0/14
 no ip address
 shutdown
!
interface FastEthernet0/15
 no ip address
 shutdown
!
interface Vlan1
 no ip address
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
control-plane
!
!
!
!        
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
 
r5#sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  up                    up     
FastEthernet0/1            unassigned      YES unset  up                    up     
FastEthernet0/2            unassigned      YES unset  up                    up     
FastEthernet0/3            unassigned      YES unset  administratively down down   
FastEthernet0/4            unassigned      YES unset  administratively down down   
FastEthernet0/5            unassigned      YES unset  administratively down down   
FastEthernet0/6            unassigned      YES unset  administratively down down   
FastEthernet0/7            unassigned      YES unset  administratively down down   
FastEthernet0/8            unassigned      YES unset  administratively down down   
FastEthernet0/9            unassigned      YES unset  administratively down down   
FastEthernet0/10           unassigned      YES unset  administratively down down   
FastEthernet0/11           unassigned      YES unset  administratively down down   
FastEthernet0/12           unassigned      YES unset  administratively down down   
FastEthernet0/13           unassigned      YES unset  administratively down down   
FastEthernet0/14           unassigned      YES unset  administratively down down   
FastEthernet0/15           unassigned      YES unset  administratively down down   
Vlan1                      unassigned      YES unset  up                    up     
r5#
r1#sh run
Building configuration...
 
Current configuration : 769 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r1
!
boot-start-marker
boot-end-marker
!
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
ip cef
!
!
ip ips po max-events 100
no ftp-server write-enable
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Serial0/0
 ip address 12.1.1.1 255.255.255.0
 serial restart-delay 0
!
interface Serial0/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial0/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial0/3
 no ip address
 shutdown
 serial restart-delay 0
!
ip http server
no ip http secure-server
ip classless
!
!
!
!        
!
control-plane
!
!
!
!
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
 
r1#
r2#sh run
Building configuration...
 
Current configuration : 1157 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r2
!
boot-start-marker
boot-end-marker
!
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
ip cef
!
!
ip ips po max-events 100
no ftp-server write-enable
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Serial0/0
 ip address 12.1.1.2 255.255.255.0
 ip nat outside
 ip virtual-reassembly
 serial restart-delay 0
!
interface Serial0/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial0/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial0/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface FastEthernet1/0
 ip address 192.168.1.1 255.255.255.0
 ip nat inside
 ip virtual-reassembly
 duplex auto
 speed auto
!
interface FastEthernet2/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
ip http server
no ip http secure-server
ip classless
!
ip nat pool 1 192.168.1.2 192.168.1.3 netmask 255.255.255.0 type rotary
ip nat inside destination list 1 pool 1
!
!
access-list 1 permit 12.1.1.3
!
!
control-plane
!
!
!        
!
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
 
r2#