[学习笔记] R1的配置,R2的配置,R3的配置

R1的配置        R2的配置        R3的配置
!
hostname R1
!
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Serial1/0
ip address 13.1.1.1 255.255.255.0
no shut
!
interface Serial1/1
ip address 12.1.1.1 255.255.255.0
no shut
!
router rip
network 1.0.0.0
network 12.0.0.0
network 13.0.0.0
!        !

hostname R2
!
interface Serial1/0
ip address 12.1.1.2 255.255.255.0
no shut
!
interface Serial1/1
ip address 23.1.1.2 255.255.255.0
no shut
!
router rip
network 12.0.0.0
network 23.0.0.0
!
R3的配置
!
hostname R3
!
interface Serial1/0
ip address 23.1.1.3 255.255.255.0
no shut
!
interface Serial1/1
ip address 13.1.1.3 255.255.255.0
no shut
!
router rip
network 13.0.0.0
network 23.0.0.0
!
↓调试配置及监测步骤↓

(一)负载均衡

完成各个路由器的基本配置,我们来看看R1、R2、R3的路由表

R1#show ip route
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
R    23.0.0.0/8 [120/1] via 12.1.1.2, 00:00:20, Serial1/1
                 [120/1] via 13.1.1.3, 00:00:10, Serial1/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/1
     13.0.0.0/24 is subnetted, 1 subnets
C       13.1.1.0 is directly connected, Serial1/0

R2#show ip route
R    1.0.0.0/8 [120/1] via 12.1.1.1, 00:00:19, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
R    13.0.0.0/8 [120/1] via 12.1.1.1, 00:00:19, Serial1/0
                 [120/1] via 23.1.1.3, 00:00:25, Serial1/1

R3#show ip route
R    1.0.0.0/8 [120/1] via 13.1.1.1, 00:00:23, Serial1/1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/0
R    12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:09, Serial1/0
                 [120/1] via 13.1.1.1, 00:00:23, Serial1/1
     13.0.0.0/24 is subnetted, 1 subnets
C       13.1.1.0 is directly connected, Serial1/1
通过上面的路由表信息,我们可以看到,每个路由器学到箭头指着网络,分别来自两个下一跳地址,而且度量值都为1,出现这种现象是因为RIP基于跳数的负载均衡产生的。


补充回答: 下面我们以R1为例看看验证它的方法:

R1#show ip route 23.0.0.0
Routing entry for 23.0.0.0/8
  Known via "rip", distance 120, metric 1
  Redistributing via rip
  Last update from 13.1.1.3 on Serial1/0, 00:00:17 ago
  Routing Descriptor Blocks:
    12.1.1.2, from 12.1.1.2, 00:00:27 ago, via Serial1/1
      Route metric is 1, traffic share count is 1
  * 13.1.1.3, from 13.1.1.3, 00:00:17 ago, via Serial1/0
      Route metric is 1, traffic share count is 1
对目标路由的跟踪可以看到它是负载均衡的

R1#debug ip rip

*Mar  8 02:33:28.227: RIP: received v1 update from 13.1.1.3 on Serial1/0
*Mar  8 02:33:28.231:      23.0.0.0 in 1 hops
R1#----------------------省略部分信息------------------------
*Mar  8 02:33:48.275: RIP: received v1 update from 12.1.1.2 on Serial1/1
*Mar  8 02:33:48.279:      23.0.0.0 in 1 hops

由debug信息也可以看到接收23.0.0.0网络分别来自两个下一跳地址。


当然我也可以用traceroute和(扩展ping 的record选项来跟踪返回的路径)。

R1#traceroute 23.1.1.3
Type escape sequence to abort.
Tracing the route to 23.1.1.3
  1 12.1.1.2 108 msec
    13.1.1.3 112 msec
    12.1.1.2 44 msec
R1#traceroute 23.1.1.3
Type escape sequence to abort.
Tracing the route to 23.1.1.3
  1 13.1.1.3 76 msec
    12.1.1.2 88 msec *
R1#traceroute 23.1.1.3
Type escape sequence to abort.
Tracing the route to 23.1.1.3
  1 12.1.1.2 124 msec
    13.1.1.3 132 msec
    12.1.1.2 16 msec
通过多次重复traceroute测试的结果,我们可以看到阴影部分的第一跳地址是轮流在交换着,之所以这样,正是负载均衡的作用允许路由器有多条路径到达同一目标网络产生的。

下面看看用扩展ping 的record选项来跟踪返回的路径

R1#ping   
Protocol [ip]:
Target IP address: 23.1.1.3  #-------目标地址
Repeat count [5]: 2 #---由于默认ping 5个包会输出太多信息,所以改为ping 2个包
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y    #-------选择Yes使用扩展ping
Source address or interface: 1.1.1.1  #-----使用1.1.1.1为源地址
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]: r #----使用记录跟踪功能
Number of hops [ 9 ]:
Loose, Strict, Record, Timestamp, Verbose[RV]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 2, 100-byte ICMP Echos to 23.1.1.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
Packet has IP options:  Total option bytes= 39, padded length=40
Record route: <*>
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)

Reply to request 0 (60 ms).  Received packet has options
Total option bytes= 40, padded length=40
Record route:
   (13.1.1.1)
   (23.1.1.3)
   (13.1.1.3)
   (1.1.1.1) <*>
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
End of list

Reply to request 1 (120 ms).  Received packet has options
Total option bytes= 40, padded length=40
Record route:
   (12.1.1.1)
   (23.1.1.2)
   (23.1.1.3)
   (13.1.1.3)
   (1.1.1.1) <*>
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
End of list
Success rate is 100 percent (2/2), round-trip min/avg/max = 60/90/120 ms
通过上面ping的信息可以看到跟踪记录的信息是不同的,分别选择两条路径走的。这也证实了是负责均衡,如果不是负载均衡而是选择最优一条路径的话,跟踪记录的信息是相同的。
补充回答: (二) 度量控制


现在我们继续以R1为例看看度量控制的情况

1:R1到达目标网络23.0.0.0是负载均衡,现在就要让它不负载均衡,要令R1优先选择走R1(s1/1)为出口经由R2达到目标网络。

2:要达到这样的要求我们就可以通过命令offset-list来改变路由的度量值。

3:利用offest-list指定一个数值(0-16)来加大路由器的度量值。使路由器R1(s1/0)到R3(s1/1)的链路达到目标网络由原来的跳数是1跳增加到3跳。
4:
R1(config)#access-list 1 permit 23.0.0.0
R1(config)#router rip
R1(config-router)#offset-list 1 in 2 s1/0
首先是定义访问列表确定了要匹配的23.0.0.0的路由,而offset-list会“先检查从s1/0接口接收进来的RIP通告,如果存在和访问列表1指定的地址匹配的路由条目(23.0.0.0),那么就把该条路由的度量值加大2跳。”

5:通过上面的配置,我们来看看R1的相关信息

R1#show ip route
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
R    23.0.0.0/8 [120/1] via 12.1.1.2, 00:00:13, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/1
     13.0.0.0/24 is subnetted, 1 subnets
C       13.1.1.0 is directly connected, Serial1/0
从路由表看23.0.0.0的路由条目,现在只剩下了由R2学到的路由了。

R1#debug ip rip
RIP protocol debugging is on
R1#
*Mar  8 03:37:43.403: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (13.1.1.1)
*Mar  8 03:37:43.403: RIP: build update entries
*Mar  8 03:37:43.407:   network 1.0.0.0 metric 1
*Mar  8 03:37:43.407:   network 12.0.0.0 metric 1
*Mar  8 03:37:43.407:   network 23.0.0.0 metric 2
R1#
*Mar  8 03:37:45.983: RIP: received v1 update from 12.1.1.2 on Serial1/1
*Mar  8 03:37:45.987:      23.0.0.0 in 1 hops
*Mar  8 03:37:46.759: RIP: sending v1 update to 255.255.255.255 via Serial1/1 (12.1.1.1)
*Mar  8 03:37:46.759: RIP: build update entries
*Mar  8 03:37:46.763:   network 1.0.0.0 metric 1
*Mar  8 03:37:46.763:   network 13.0.0.0 metric 1
R1#
*Mar  8 03:37:55.995: RIP: received v1 update from 13.1.1.3 on Serial1/0
*Mar  8 03:37:55.999:      23.0.0.0 in 3 hops
从debug信息已经可以看到,目标网络23.0.0.0,由接口s1/1接收来自R2为1跳,而由接口s1/0接收来自R3为3跳。


R1#show ip route 23.0.0.0
Routing entry for 23.0.0.0/8
  Known via "rip", distance 120, metric 1
  Redistributing via rip
  Last update from 12.1.1.2 on Serial1/1, 00:00:04 ago
  Routing Descriptor Blocks:
  * 12.1.1.2, from 12.1.1.2, 00:00:04 ago, via Serial1/1
      Route metric is 1, traffic share count is 1

R1#traceroute 23.1.1.3
Type escape sequence to abort.
Tracing the route to 23.1.1.3
  1 12.1.1.2 92 msec 56 msec 48 msec
  2 23.1.1.3 44 msec *  76 msec

R1#traceroute 23.1.1.3
Type escape sequence to abort.
Tracing the route to 23.1.1.3
  1 12.1.1.2 112 msec 64 msec 16 msec
  2 23.1.1.3 24 msec *  68 msec
从上面的结果可以看到,R1优先选择经由R2的路径到达目标网络,接受跳数较少的23.0.0.0路由条目。
以上实现的就是offset-list的作用了,当然offset-list还有其它的一些功能,例如:我们除了可以控制入站接收的度量值之外,还可以控制出站宣告的路由更新度量。

补充回答: (三) 同源与否

1: 我们先来验证同源的情况,这里只利用R1和R2两台路由,所以先把R1的s1/0断开方便我们测试。
R1(config)#int s1/0
R1(config-if)#shutdown

2: 我们以R1的loopback 0接口,1.0.0.0网络作为源,通过在R1的s1/1接口,控制出站宣告的路由更新的度量值,来观察R2的接收情况。

现在看看正常情况下R2的路由表:
R2#show ip route
R    1.0.0.0/8 [120/1] via 12.1.1.1, 00:00:24, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0

现在增加R1的s1/1出口的度量值:
R1(config)#access-list 2 permit 1.0.0.0
R1(config)#router rip
R1(config-router)#offset-list 2 out 3 s1/1

增加了度量值后,再看看R2的路由表:
R2#show ip route
R    1.0.0.0/8 [120/4] via 12.1.1.1, 00:00:20, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
和没有增加度量值时的路由表对比,发现R2现在的路由表已经安装了度量值较大的1.0.0.0路由条目。

再看看R1、R2的debug信息:
R1#debug ip rip
*Mar  8 05:19:20.799: RIP: sending v1 update to 255.255.255.255 via Serial1/1 (12.1.1.1)
*Mar  8 05:19:20.799: RIP: build update entries
*Mar  8 05:19:20.803:   network 1.0.0.0 metric 4

R2#debug ip rip
*Mar  8 05:20:42.967: RIP: received v1 update from 12.1.1.1 on Serial1/0
*Mar  8 05:20:42.971:      1.0.0.0 in 4 hops
R2#
*Mar  8 05:20:52.359: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (12.1.1.2)
*Mar  8 05:20:52.359: RIP: build update entries
*Mar  8 05:20:52.359:   network 23.0.0.0 metric 1
R2#
*Mar  8 05:20:55.187: RIP: sending v1 update to 255.255.255.255 via Serial1/1 (23.1.1.2)  #-----发送给R3
*Mar  8 05:20:55.187: RIP: build update entries
*Mar  8 05:20:55.191:   network 1.0.0.0 metric 5
*Mar  8 05:20:55.191:   network 12.0.0.0 metric 1
由debug信息可以看到,R2接受更高度量值的。所以来自同源的路由总是会接收更新的,不管度量增大还是小,这时我们也观察到R2在接收到度量值发生变化的路由时,立即发送flash update 给R3。这说明一点,当度量变化时发送的是flash update(瞬间更新) ,而不是triggered update(触发更新)。



4:现在我们来验证一下不同源的情况,先看看R3的路由表,再在R1、R2、R3打开debug ip rip,然后开启R1的S1/0端口,使R1恢复与R3的连通。

(1)
R3#show ip route
R    1.0.0.0/8 [120/5] via 23.1.1.2, 00:00:24, Serial1/0  #-----来自R2
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/0
R    12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:24, Serial1/0
可以看路由表中学到的1.0.0.0路由条目是来自R2

(2)
R1#debug ip rip
R2#debug ip rip
R3#debug ip rip

(3)
R1(config)#int s1/0
R1(config-if)#no shutdown

(4)
现在看看R2、R3路由表和debug信息
R2#show ip route
R    1.0.0.0/8 [120/2] via 23.1.1.3, 00:00:11, Serial1/1  #----来自R3
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
R    13.0.0.0/8 [120/1] via 12.1.1.1, 00:00:23, Serial1/0
                [120/1] via 23.1.1.3, 00:00:11, Serial1/1


R3#show ip route
R    1.0.0.0/8 [120/1] via 13.1.1.1, 00:00:10, Serial1/1  #---来自R1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/0
R    12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:20, Serial1/0
                [120/1] via 13.1.1.1, 00:00:10, Serial1/1
     13.0.0.0/24 is subnetted, 1 subnets
C       13.1.1.0 is directly connected, Serial1/1
现在R2的1.0.0.0路由条目是来自R3的为2跳,而R3的1.0.0.0路由条目是来自R1的为1跳。再看看看debug信息

R2#debug ip rip
*Mar  8 05:45:50.131: RIP: received v1 update from 23.1.1.3 on Serial1/1 #----来自R3
*Mar  8 05:45:50.135:      1.0.0.0 in 2 hops
*Mar  8 05:45:50.139:      13.0.0.0 in 1 hops
R2#
*Mar  8 05:46:11.387: RIP: received v1 update from 12.1.1.1 on Serial1/0 #----来自R2
*Mar  8 05:46:11.391:      1.0.0.0 in 4 hops
*Mar  8 05:46:11.391:      13.0.0.0 in 1 hops

R3#debug ip rip
*Mar  8 05:48:49.479: RIP: received v1 update from 13.1.1.1 on Serial1/1
*Mar  8 05:48:49.483:      1.0.0.0 in 1 hops
*Mar  8 05:48:49.483:      12.0.0.0 in 1 hops
*Mar  8 05:48:49.483:      23.0.0.0 in 2 hops
R3#
*Mar  8 05:49:08.627: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (23.1.1.3) #---发送去R2
*Mar  8 05:49:08.627: RIP: build update entries
*Mar  8 05:49:08.631:   network 1.0.0.0 metric 2 #----网络1.0.0.0发给R2度量值为2
*Mar  8 05:49:08.631:   network 13.0.0.0 metric 1
由路由表和debug信息可以看到R2选择1.0.0.0的路由条目是度量值更少的,这说明接收了从不同源的路由更新时会选择度量值更小的路由。



在R1与R3相连的接口(S1/0)增加2跳看看:
R1(config)#router rip
R1(config-router)#offset-list 2 out 2 s1/0

R3#debug ip rip
*Mar  8 06:15:49.706: RIP: received v1 update from 13.1.1.1 on Serial1/1
*Mar  8 06:15:49.710:      1.0.0.0 in 3 hops
*Mar  8 06:15:49.710:      12.0.0.0 in 1 hops
*Mar  8 06:15:49.710:      23.0.0.0 in 2 hops
R3#
*Mar  8 06:16:01.530: RIP: sending v1 update to 255.255.255.255 via Serial1/0 (23.1.1.3)
*Mar  8 06:16:01.530: RIP: build update entries
*Mar  8 06:16:01.534:   network 1.0.0.0 metric 4
*Mar  8 06:16:01.534:   network 13.0.0.0 metric 1

R2#show ip route
R    1.0.0.0/8 [120/4] via 23.1.1.3, 00:00:12, Serial1/1  #---来自R3
                   [120/4] via 12.1.1.1, 00:00:13, Serial1/0  #---来自R1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
R    13.0.0.0/8 [120/1] via 12.1.1.1, 00:00:13, Serial1/0
                [120/1] via 23.1.1.3, 00:00:12, Serial1/1
实验结果 证明确实负载均衡了!
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值