A-A+

思科单臂路由+动态NAT实验学习笔记

2015年11月24日 站长资讯 暂无评论

下面针对最基础的cisco单臂路由和动态NAT做一个实验,来学习IP配置信息、设置网关的方法,最后再检查是否成功。

实验拓扑如下:(省略)

IP配置信息

  1. PC1:ip-192.168.1.100/24 gw-192.168.1.254  
  2. PC2:ip-192.168.2.100/24 gw-192.168.2.254  
  3. SW1:VLAN 100、200  
  4. R3:F0/0.1 ip-192.168.1.254/24  
  5. F0/0.2 ip-192.168.2.254/24  
  6. S1/0 ip-200.200.200.1/30  
  7. R4:S0/1 ip-200.200.200.2/30  
  8. S0/2 ip-200.200.200.5/30  
  9. R5:S0/2 ip-200.200.200.6/30  
  10. F1/0 ip-8.8.8.254/24  
  11. PC3:ip-8.8.8.100/24 gw-8.8.8.254  

因为使用路由器充当PC机来使用所以要关闭路由功能、设置网关即可。配置如下:

  1. PC1:  
  2. PC1>en  
  3. PC1#config t  
  4. PC1(config)#no ip routing  
  5. PC1(config)#ip default-gateway 192.168.1.254  
  6. PC1(config)#int f0/0  
  7. PC1(config-if)#no shutdown  
  8. PC1(config-if)#description "PC1-Switch-F0/1"  
  9. PC1(config-if)#ip add 192.168.1.100 255.255.255.0  

PC2、PC3与上述配置相同只需要把IP信息更换即可,这样配置完后就可以当PC机进行ping测试了。

单臂路由配置

SW配置

Switch是使用3640路由器加载16口的交换模块,所以也要执行No ip routing命令关闭路由功能。

  1. SW1#en  
  2. SW1#config t  
  3. SW1(config)#no ip routing  
  4. SW1(config)#exit  
  5. SW1#vlan database  
  6. SW1(vlan)#vlan 100  
  7. SW1(vlan)#vlan 200  
  8. SW1(vlan)#exit  
  9. APPLY completed.  
  10. Exiting....  
  11. SW1#config t  
  12. Enter configuration commands, one per line. End with CNTL/Z.  
  13. SW1(config)#int f0/1  
  14. SW1(config-if)#sw mode access  
  15. SW1(config-if)#sw access vlan 100  
  16. SW1(config-if)#int f0/2  
  17. SW1(config-if)#sw mode access  
  18. SW1(config-if)#sw access vlan 200  
  19. SW1(config-if)#int f0/0  
  20. SW1(config-if)#sw mo trunk  
  21. SW1(config-if)#sw trunk allowed vlan all  

配置后毕后使用show vlan或者是show vlan-switch查看VLAN信息

R3配置

  1. R3#config t  
  2. Enter configuration commands, one per line. End with CNTL/Z.  
  3. R3(config)#int f0/0  
  4. R3(config-if)#no shutdown  
  5. R3(config-if)#int f0/0.1   
  6. R3(config-subif)#description "1.0-Gateway"  
  7. R3(config-subif)#encapsulation dot1Q 100  
  8. R3(config-subif)#ip add 192.168.1.254 255.255.255.0  
  9. R3(config-subif)#int f0/0.2  
  10. R3(config-subif)#description "2.0-Gateway"  
  11. R3(config-subif)#encapsulation dot1Q 200  
  12. R3(config-subif)#ip add 192.168.2.254 255.255.255.0  

配置完毕后检查是否成功

  1. PC1#ping 192.168.2.254  
  2.   
  3. Type escape sequence to abort.  
  4. Sending 5, 100-byte ICMP Echos to 192.168.2.254, timeout is 2 seconds:  
  5. !!!!!  
  6. Success rate is 100 percent (5/5), round-trip min/avg/max = 12/22/40 ms  

NAT配置

路由条目配置

R3:0.0.0.0 0.0.0.0 200.200.200.2

R4:8.8.8.0 255.255.255.0 200.200.200.6

R5:200.200.200.0 255.255.255.252 200.200.200.5

R3配置

  1. R3>en  
  2. R3#config t  
  3. R3(config)#int s1/0  
  4. R3(config-if)#ip add 200.200.200.1 255.255.255.252  
  5. R3(config-if)#description "Internet Interface"  
  6. R3(config)#ip route 0.0.0.0 0.0.0.0 200.200.200.2  

R4、R5接口IP配置与需要配置的路由与R3命令相同参数不同;

  1. R3(config)#access-list 1 permit 192.168.1.0 0.0.0.255  
  2. R3(config)#access-list 2 permit 192.168.2.0 0.0.0.255  
  3. R3(config)#ip nat pool nat100 200.200.200.1 200.200.200.1 netmask 255.255.255.252  
  4. R3(config)#ip nat pool nat200 200.200.200.1 200.200.200.1 netmask 255.255.255.252  
  5. R3(config)#ip nat inside source list 1 pool nat100  
  6. R3(config)#ip nat inside source list 2 pool nat200  
  7. R3(config)#int f0/0.1  
  8. R3(config-subif)#ip nat inside  
  9. R3(config-subif)#int f0/0.2  
  10. R3(config-subif)#ip nat inside  

R3(config-subif)#int s1/0

R3(config-if)#ip nat outside

动态NAT配置完毕,检查配置是否成功

  1. PC1#PING 8.8.8.100  
  2. Type escape sequence to abort.  
  3. Sending 5, 100-byte ICMP Echos to 8.8.8.100, timeout is 2 seconds:  
  4. !!!!!  
  5. Success rate is 100 percent (5/5), round-trip min/avg/max = 60/69/92 ms  

若出现从PC1无法Ping通,仔细检查R5路由是否存在。

标签:

给我留言