舒畅 发表于 2018-7-20 10:30:32

cisco的路由器上rip的被动接口,单播更新,水平分隔

  cisco的路由器上rip的被动接口,单播更新,水平分隔
  实验拓扑图
  在这个配置中要注意一点,在给r1,r7和r8的e0/0接口配置ip地址的时候,需要把他们全部调做全双工模式。
  sw1(config)#int f0/1
  sw1(config-if)#no shutdown
  sw1(config-if)#speed 100//设置带宽为100m,不这么设置,下面那条命令配置不上去
  sw1(config-if)#duplex full //设置为全双工模式
  sw1(config-if)#exit
  其他两个sw1的接口按照上面一样的配置
  在路由器上也要配置
  r7(config)#inte e0/0
  r7(config)#ip add 10.10.10.3 255.255.255.248
  r7(config-if)#duplex full//配置为全双工模式
  r7(config)#no shutdown
  r7(config-if)#exit
  其他路由器也按照上面一样的配置
  按照拓扑图配置命令
  r1(config)#router rip
  r1(config-router)#version 2
  r1(config-router)#no auto-summary
  r1(config-router)#network 10.0.0.0
  r1(config-router)#network 192.168.1.0
  r1(config-router)#network 192.168.2.0
  r1(config-router)#exit
  其他的路由器命令和这大概相同
  配置完后去查看路由表
  r1#show ip route
  R    192.168.40.0/24 via 192.168.2.2, 00:00:06, Serial1/1
   via 192.168.1.2, 00:00:06, Serial1/0
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  R    192.168.50.0/24 via 10.10.10.2, 00:00:20, Ethernet0/0
  C    192.168.1.0/24 is directly connected, Serial1/0
  C    192.168.2.0/24 is directly connected, Serial1/1
  R    192.168.70.0/24 via 10.10.10.3, 00:00:09, Ethernet0/0
  r2#show ip route
  C    192.168.40.0/24 is directly connected, Loopback0
  10.0.0.0/29 is subnetted, 1 subnets
  R       10.10.10.0 via 192.168.2.1, 00:00:25, Serial1/1
   via 192.168.1.1, 00:00:29, Serial1/0
  R    192.168.50.0/24 via 192.168.2.1, 00:00:22, Serial1/1
   via 192.168.1.1, 00:00:22, Serial1/0
  C    192.168.1.0/24 is directly connected, Serial1/0
  C    192.168.2.0/24 is directly connected, Serial1/1
  R    192.168.70.0/24 via 192.168.2.1, 00:00:25, Serial1/1
   via 192.168.1.1, 00:00:29, Serial1/0
  r7#show ip route
  R    192.168.40.0/24 via 10.10.10.1, 00:00:05, Ethernet0/0
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  R    192.168.50.0/24 via 10.10.10.2, 00:00:16, Ethernet0/0
  R    192.168.1.0/24 via 10.10.10.1, 00:00:05, Ethernet0/0
  R    192.168.2.0/24 via 10.10.10.1, 00:00:05, Ethernet0/0
  C    192.168.70.0/24 is directly connected, Loopback0
  r8#show ip route
  R    192.168.40.0/24 via 10.10.10.1, 00:00:22, Ethernet0/0
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  C    192.168.50.0/24 is directly connected, Loopback0
  R    192.168.1.0/24 via 10.10.10.1, 00:00:22, Ethernet0/0
  R    192.168.2.0/24 via 10.10.10.1, 00:00:22, Ethernet0/0
  R    192.168.70.0/24 via 10.10.10.3, 00:00:02, Ethernet0/0
  此时可以发现所有的路由器都已经学到了这个网络上其他网段上的路由条目,并且建立了自己的路由表
  如果r1不想把他的信息给r7和r8,可以在r1的e0/0接口设置为被动接口.
  r1(config)#router rip//要在协议底下配置被动接口
  r1(config-router)#passive-interface e0/0//配置为被动接口
  此时清空r7和r8的路由表在看看其路由表中的信息
  R7#clear ip route *
  r7#show ip route
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  R    192.168.50.0/24 via 10.10.10.2, 00:00:02, Ethernet0/0
  C    192.168.70.0/24 is directly connected, Loopback0
  r8#clear ip route *
  r8#show ip route
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  C    192.168.50.0/24 is directly connected, Loopback0
  R    192.168.70.0/24 via 10.10.10.3, 00:00:01, Ethernet0/0
  我门可以发现在r7和r8上面已经没有了r1右边网段的路由条目了,这是因为在r1的e0/1接口上配置了被动接口,是的r1路由上的信息不再从这个接口发送出去
  此时清空一下r1的路由表,在查看r1上面的路由信息
  R1#clear ip route *
  r1#show ip route
  R    192.168.40.0/24 via 192.168.2.2, 00:00:00, Serial1/1
   via 192.168.1.2, 00:00:29, Serial1/0
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  R    192.168.50.0/24 via 10.10.10.2, 00:00:01, Ethernet0/0
  C    192.168.1.0/24 is directly connected, Serial1/0
  C    192.168.2.0/24 is directly connected, Serial1/1
  R    192.168.70.0/24 via 10.10.10.3, 00:00:11, Ethernet0/0
  可以发现r1上面的路由信息没有变化,证明在r1的e0/0口还是能够接受rip信息的,这就是被动接口
  但是如果我只是不想给r7路由信息,但是和r8关系好,又想给r8路由信息,那怎么办呢?
  这就要靠单播更新了
  在r1上配置如下mingl
  r1(config)#router rip   //也是要在协议底下配置
  r1(config-router)#passive-interface e0/0//被动接口后配置单播更新
  r1(config-router)#neighbor 10.10.10.2//单播更新给r8
  此时在显示r8的路由信息
  r8#show ip route
  R    192.168.40.0/24 via 10.10.10.1, 00:00:22, Ethernet0/0
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  C    192.168.50.0/24 is directly connected, Loopback0
  R    192.168.1.0/24 via 10.10.10.1, 00:00:22, Ethernet0/0
  R    192.168.2.0/24 via 10.10.10.1, 00:00:22, Ethernet0/0
  R    192.168.70.0/24 via 10.10.10.3, 00:00:03, Ethernet0/0
  我们能够发现,r8又能学到r1路由器右边的网段了,这是因为r1给了r8单播更新的信息,我们可以看到此时r7依然还是原路由条目
  r7#show ip route
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  R    192.168.50.0/24 via 10.10.10.2, 00:00:01, Ethernet0/0
  C    192.168.70.0/24 is directly connected, Loopback0
  这就是单播更新了,即一个接口连接了几台路由器,但是只想给其中的某几台路由器发送更新消息的话可以使用单播更新.
  但是此时r7和r8关系很好,r8想把从r1上学到的路由条目传给r7由于有水平分割怎么办呢?
  可以关闭r8上面的默认水平分隔。
  r8(config)#inter e0/0
  r8(config-if)#no ip split-horizon
  此时再在r7上去查看路由表
  r7#show ip route
  R    192.168.40.0/24 via 10.10.10.2, 00:00:02, Ethernet0/0
  10.0.0.0/29 is subnetted, 1 subnets
  C       10.10.10.0 is directly connected, Ethernet0/0
  R    192.168.50.0/24 via 10.10.10.2, 00:00:02, Ethernet0/0
  R    192.168.1.0/24 via 10.10.10.2, 00:00:02, Ethernet0/0
  R    192.168.2.0/24 via 10.10.10.2, 00:00:02, Ethernet0/0
  C    192.168.70.0/24 is directly connected, Loopback0
  在r7和r8上面上开启debug命令
  r8#
  *Mar1 03:15:05.375: RIP: sending v2 update to 224.0.0.9 via Loopback0 (192.168.50.1)
  *Mar1 03:15:05.375: RIP: Update contains 5 routes
  *Mar1 03:15:05.379: RIP: Update queued
  *Mar1 03:15:05.379: RIP: Update sent via Loopback0
  *Mar1 03:15:05.383: RIP: ignored v2 packet from 192.168.50.1 (sourced from one of our addresses)//由于是同一个接口发出去的,loopback接口,又发回来给自己所以是非法的
  r8#
  *Mar1 03:15:10.415: RIP: sending v2 update to 224.0.0.9 via Ethernet0/0 (10.10.10.2)//给r7发送路由信息
  *Mar1 03:15:10.415: RIP: Update contains 6 routes//包含了6条路由信息,证明水平分隔已经关闭,不然他只会从这个接口发送的路由信息没有6条
  *Mar1 03:15:10.419: RIP: Update queued
  *Mar1 03:15:10.419: RIP: Update sent via Ethernet0/0
  r8#
  *Mar1 03:15:17.527: RIP: received v2 update from 10.10.10.1 on Ethernet0/0//证明r8还是能够从r7上收到路由信息的。
  *Mar1 03:15:17.531: RIP: Update contains 3 routes
  r7#
  *Mar1 03:10:11.103: RIP: received v2 update from 10.10.10.2 on Ethernet0/0//从r8接受日抛包
  *Mar1 03:10:11.107: RIP: Update contains 6 routes//包中有6条路由信息,证明关闭了水平分隔
  *Mar1 03:10:11.259: RIP: sending v2 update to 224.0.0.9 via Loopback0 (192.168.70.1)
  *Mar1 03:10:11.259: RIP: Update contains 5 routes
  *Mar1 03:10:11.263: RIP: Update queued
  *Mar1 03:10:11.263: RIP: Update sent via Loopback0
  *Mar1 03:10:11.267: RIP: ignored v2 packet from 192.168.70.1 (sourced from one of our addresses)
  r7#
  *Mar1 03:10:25.207: RIP: sending v2 update to 224.0.0.9 via Ethernet0/0 (10.10.10.3)
  *Mar1 03:10:25.207: RIP: Update contains 1 routes//从这里可以看到,r7上面没有关闭水平分隔,发出去的路由条数只有1条
  *Mar1 03:10:25.211: RIP: Update queued
  *Mar1 03:10:25.211: RIP: Update sent via Ethernet0/0
  r7#
  总结
  使我对rip的动态路由协议有了一个很好的了解和实践,特别是其中的被动接口,单播更新和水平分隔
页: [1]
查看完整版本: cisco的路由器上rip的被动接口,单播更新,水平分隔