TOP图如上图
R1的配置:
Press Enter to Start
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R1
R1(config)#int e0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#ip nat inside
R1(config-if)#no shut
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
R1(config-if)#int s0
R1(config-if)#ip add 192.168.2.5 255.255.255.252
R1(config-if)#ip nat outside
R1(config-if)#clock rate 1000000
R1(config-if)#no shut
%LINK-3-UPDOWN: Interface Serial0, changed state to up
%LINK-3-UPDOWN: Interface Serial0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down
R1(config-if)#encapsulation hdlc
R1(config-if)#exit
R1(config)#access-list 1 permit 192.168.1.0 0.0.0 .255 //设置允许访问的内部IP地址列表
R1(config)#ip nat pool ssss 202.101.1.1 202.101.2.10 netmask 255.255.255.0 //配置全局IP地址池ssss
R1(config)#ip nat inside source list 1 pool ssss overload //蓝色部分和静态的NAT是一样的,只是内部地址改为list 1,而内部全局地址孜为了pool ssss
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 192.168.1.0
R1(config-router)#network 192.168.2.4
R1(config-router)#end
%LINK-3-UPDOWN: Interface Serial0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
R2的配置:
Press Enter to Start
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R2
R2(config)#int e0
R2(config-if)#ip add 202.101.6.1 255.255.255.0
R2(config-if)#no shut
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
R2(config-if)#int s0
R2(config-if)#ip add 192.168.2.6 255.255.255.252
R2(config-if)#no shut
%LINK-3-UPDOWN: Interface Serial0, changed state to up
R2(config-if)#exit
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 192.168.2.4
R2(config-router)#network 202.101.6.0
R2(config-router)#end
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//配置R2的telnet
R2(config)#line vty 0 4
R2(config-line)#login
R2(config-line)#password cisco
R2(config-line)#end
在R1和R2上查看NAT信息:
1、R1#sh ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp202.101.1.1:9392 192.168.1.2:9392 202.101.6.1:9392 202.101.6.1:9392
icmp202.101.1.1:9393 192.168.1.2:9393 202.101.6.1:9393 202.101.6.1:9393
icmp202.101.1.1:9394 192.168.1.2:9394 202.101.6.1:9394 202.101.6.1:9394
icmp202.101.1.1:9395 192.168.1.2:9395 202.101.6.1:9395 202.101.6.1:9395
icmp202.101.1.1:9396 192.168.1.2:9396 202.101.6.1:9396 202.101.6.1:9396
icmp202.101.1.1:9392 192.168.1.2:9392 202.101.6.2:9392 202.101.6.2:9392
icmp202.101.1.1:9393 192.168.1.2:9393 202.101.6.2:9393 202.101.6.2:9393
icmp202.101.1.1:9394 192.168.1.2:9394 202.101.6.2:9394 202.101.6.2:9394
icmp202.101.1.1:9395 192.168.1.2:9395 202.101.6.2:9395 202.101.6.2:9395
icmp202.101.1.1:9396 192.168.1.2:9396 202.101.6.2:9396 202.101.6.2:9396
icmp202.101.1.1:9392 192.168.1.3:9392 202.101.6.1:9392 202.101.6.1:9392
icmp202.101.1.1:9393 192.168.1.3:9393 202.101.6.1:9393 202.101.6.1:9393
icmp202.101.1.1:9394 192.168.1.3:9394 202.101.6.1:9394 202.101.6.1:9394
icmp202.101.1.1:9395 192.168.1.3:9395 202.101.6.1:9395 202.101.6.1:9395
icmp202.101.1.1:9396 192.168.1.3:9396 202.101.6.1:9396 202.101.6.1:9396
2、用host 1 telnet到R2,然后查看users:
telnet 202.101.6.1
show users