A-A+

用小帆模拟器做的实现路由控制的实验

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

下面将使用小帆模拟器做的实验,为了实现路由控制的功能,下面是拓扑和配置命令行。

案例要求:有三个地区,省(R2),市(R1),县(R3) 县内部有一台3.100的pc机用虚拟机连接,在不同在网段,用三个路由器连接起来,实现的功能是省和市到县都没有路由,只有县到省和到市有路由,要用到nat转换。案例图如下:

1.路由器上做下面相同的的配置:

  1. R3(config)#line con 0 (进入控制端口)  
  2. R3(config-line)#no exec?  
  3. exec  exec-banner  exec-character-bits  exec-timeout  
  4. R3(config-line)#no exec-timeout(设置没有超时时间)  
  5. R3(config-line)#log?  
  6. logging  login  logout-warning    
  7.   synchronous  Synchronized message output  
  8. R3(config-line)#logging synch(设置日志同步)  

2.R1上的配置:

  1. Router#conf  
  2. Configuring from terminal, memory, or network [terminal]?   
  3. Enter configuration commands, one per line.  End with CNTL/Z.  
  4. Router(config)#hostname R1  
  5. R1(config)#int s1/0  
  6. R1(config-if)#ip add 192.168.4.1 255.255.255.0  
  7. R1(config-if)#int f0/0  
  8. R1(config-if)#ip add 192.168.1.254 255.255.255.0  
  9. R1(config-if)#loop  
  10. R1(config-if)#shu  
  11. R1(config-if)#no shu (loopback的端口也要开启)  
  12. R1>ping 192.168.4.2(测试直连的是否连通)  
  13. Type escape sequence to abort.  
  14. Sending 5, 100-byte ICMP Echos to 192.168.4.2, timeout is 2 seconds:  
  15. !!!!!  
  16. Success rate is 100 percent (5/5), round-trip min/avg/max = 8/30/52 ms  

3.R2上的配置:

  1. Router(config)#hostname R2  
  2. R2(config)#int s1/1  
  3. R2(config-if)#ip add 192.168.5.1 255.255.255.0  
  4. R2(config-if)#int f0/0  
  5. R2(config-if)#ip add 192.168.2.254 255.255.255.0  
  6. R2(config-if)#loop  
  7. R2(config-if)#shu  
  8. R2(config-if)#no shu  

4.R3上的配置:

  1. Router(config)#hostname R3  
  2. R3(config)#int s1/0  
  3. R3(config-if)#ip add 192.168.4.2 255.255.255.0  
  4. R3(config-if)#shu  
  5. R3(config-if)#no shu  
  6. R3(config)#int s1/1   
  7. R3(config-if)#ip add 192.168.5.2 255.255.255.0  
  8. R3#ping 192.168.4.1  
  9.   
  10. Type escape sequence to abort.  
  11. http://www.xiaoxiongboke.com   
  12. Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:  
  13. !!!!!  
  14. Success rate is 100 percent (5/5), round-trip min/avg/max = 32/54/100 ms  

5.要实现要求的功能还要在R3上做nat转换,要做的是在R1,R2上不做默认路由,只需要在R3上做默认路由即可,还要在此路由器上做访问控制列表,nat转换。

  1. R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.4.1   
  2. R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.5.1 (添加两条默认的路由)  
  3. Gateway of last resort is not set  
  4. C    192.168.4.0/24 is directly connected, Serial1/0  
  5. C    192.168.5.0/24 is directly connected, Serial1/1  
  6. S    192.168.1.0/24 [1/0] via 192.168.4.1  
  7. S    192.168.2.0/24 [1/0] via 192.168.5.1  
  8. C    192.168.3.0/24 is directly connected, FastEthernet0/0  

6.虚拟机用host-only连接,配置参数如下,刚开始ping不通1.254.和2.254.的网络,需要做nat转换。

7.设置内部外部接口

  1. R3(config-if)#int s1/0  
  2. R3(config-if)#ip nat outside()设置为外部接口  
  3. R3(config-if)#int s1/1  
  4. R3(config-if)#ip nat outside()设置为外部接口  
  5. R3(config-if)#int f0/0  
  6. R3(config-if)#ip nat in?  
  7. inside    
  8. R3(config-if)#ip nat inside(设置为内部接口)  
  9. R3(config)#ip nat inside source list 10 interface s1/0  

8.创建访问控制列表(此实验需要用扩展的,因为需要对两个地区的目的地址做控制,华为上做一个就行)

  1. Router(config)#access-list 100 permit ip 192.168.3.0 0.0.0.255 192.168.1.0 ?  
  2.   A.B.C.D  Destination wildcard bits  
  3. Router(config)#$ 100 permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255 (县到市做的控制)  
  4. Router(config)#access-list 101 permit ip 192.168.3.0 0.0.0.255 ?  
  5.   A.B.C.D  Destination address  
  6.   any      Any destination host  
  7.   host     A single destination host  
  8. Router(config)#$ 101 permit ip 192.168.3.0 0.0.0.255 192.168.2.0 0.0.0.255   (县到省做的控制)  
  9. Router(config)#ip nat inside source list 100 interface s1/0  overload(nat转换用到出口)  
  10. Router(config)#ip nat inside source list 101 interface s1/1  overload  

然后pc就能ping通了

ping 192.168.1.254 -t (一直ping)

ping 192.168.2.254 -t

标签:

给我留言